It is often desirable to choose the weighted sample size (Population) that is shown when a weight is applied to a table. For example, you may wish to have weights specified such that the Base Population matches the known population size of the country in which the study was conducted.
If you use the default settings when creating a weight in Q, the Base Population will match the Base n. The methods below can be used to choose the desired weighted sample size.
Methods
Method 1
When creating the weight in Q, you can set targets by Population numbers rather than percentages.
- Select Create > Variables and Questions > Variables > Weight.
- Set the Make weights sum to value sample size .
- Select your Adjustment Variable(s)
- Under the Target are section, click Population/Count.
- Set your weight targets as normal, but instead of specifying targets as percentages, specify counts such that they add up to the desired population number.
Method 2
When the weights have been set up already, either in Q or in the raw data, then a JavaScript Variable can be created to adjust the weights. This approach is only applicable when you are weighting up to a single population total, and when the number of cases is not going to change (in other cases it is better to use the method above):
- In the Variables and Questions tab, right-click and select Insert Variables > JavaScript Formulas > Numeric.
- In the Expression use the formula: my_weight * 600 / 602
- Replace my_weight with the Variable Name of your existing weight variable.
- Replace 600 with the desired weighted sample size.
- Replace 602 with the current sample size in your data file.
- Change the Label to something appropriate, for example - Population Adjusted Weight.
- Click OK.
Method 3
You can also create an R variable to adjust the population of subgroups in your weight. If you'd like your groups' populations to equal the groups sample size within the unweighted data, you can combine the individual weights and gross up/down the respondent-level weights to balance out the sample size. For example, if you need to have different weighting for USA and Canada, and they make up 300 and 600 respondents respectively, but each has a population of 100 in your weight -- you can use the following code to adjust the weighted populations for USA and Canada back to 300 and 600 while still retaining the specific weighting within each country. See [How To Apply Different Weighting Structures To Sub-Samples] for full example.
On the Variables and Questions tab, right click and select Insert Variable(s) > R Variable to use for your weight and paste in the code below. Replace YourGroupVariable on line 2 with the name of the group variable from your dataset, replace 1, 2, 3, etc with each group's label, and add/remove groups as needed.
# identify group variable
group = YourGroupVariable
#create empty combined weight variable
combweight = rep(NA,length(group))
#for each group, reference the correct individual weight and gross up based on subgroup sample size
combweight[group == "1"] = weight1[group == "1"] * sum(group == "1",na.rm=T)/100
combweight[group == "2"] = weight2[group == "2"] * sum(group == "2",na.rm=T)/100
combweight[group == "3"] = weight3[group == "3"] * sum(group == "3",na.rm=T)/100
combweight[group == "4"] = weight2[group == "4"] * sum(group == "4",na.rm=T)/100
#return final result
combweight
Next
How to Configure a Weight from Variable(s)