Weight to multiple target characteristics

Weight to multiple target characteristics

The weighting examples above are applicable when you only want to apply one weight scheme to the project at a time. However, you might want to weight to multiple target characteristics. We can do this using Random Iterative Method, also known as RIM weighting or raking.

For example, a survey sample may have set quotas to equally sample physicians and nurses , but in the target market nurses may be 70% of customers.

Gender Survey  Population
Physician 50% 30%
Nurse 50% 70%

Similarly, the distribution of region in the survey may differ from the target population.

Region Survey sample Population
East 40% 30%
West 60% 70%

It is possible to calculate one weight scheme that adjusts the distribution for more than one variable.  This is a little more complex, as setting weights for one variable may affect the distribution of other correlated variables.   

For this you can use an iterative algorithm called "Rim weighting", described here and also in the accordion below. This gist shows a function that calculates weights for selected variables, and runs in a data process .


Example RIM weighting algorithm

Protobi.get_tables(["main", "OE"], function(err, data) {
    if (err) return callback(err);
    
    Protobi.get_elements(function(err, protobi) {
        if (err) return callback(err);
    
        var rows= data["main"] //primary data file
        protobi.setData(rows);
        
        Protobi.calculate_rim_weights(
            protobi, 
            'weight', {
            "s3":{
               "1":0.49,
               "2":0.51
            },
            "s2":{
                "0":0.84,
                "1":0.16
            },
            "region":{
                "Northeast":0.17,
                "Midwest":0.21,
                "West":0.24,
                "South":0.38,
            }
        })
    return callback (null, rows)
    })
})
Delete


Support

Weighting can get complex and each firm has its own approaches. Our support team is ready to help you with your specific goals. We can help you setup code that does what you need and show you how to modify it from there. Please contact us at support@protobi.com.