How to Weight Only a Part of a Data File

From Q
Jump to navigation Jump to search

Sometimes it is desirable to only weight a part of data file. For example, data may have been collected in two regions, and it may be appropriate to weight only one of those regions. The basic process is to set up a weight such that the calculations are done separately for the weighted and non-weighted part of the sample, and to then use a JavaScript variable to remove the weighting from the part of the sample which does not need to be weighted.

If any of the following are true:

  1. The unweighted group doesn't have respondents in all the target categories supplied
  2. The sample sizes of the weighted/unweighted respondents should match before and after weighting the data

You will need to use the To Apply Different Weighting Structures To Sub-Samples process, which is more robust.

Part 1 - Create a filter to identify the sample to be weighted

The first step is to create a variable which separates the part of the sample you want to weight from the total sample.

  1. Create a filter which represents the respondents to be weighted, calling this filter Sample to be weighted.
  2. In the Variables and Questions tab, change the Name for the filter to weighted.

Part 2 - Set up the weight variable

Next, you need to set up the weight. This is the same as a normal weight, but incorporates the variable you made above.

  1. In the Variables and Questions tab, right-click and select Insert Variables > Weight.
  2. Set up your weight in the normal way, as though you were setting targets for the total sample. For more info on setting targets, see Construct Weight.
  3. In the Recompute for Each menu, select your Sample to be weighted filter.
  4. Click OK.
  5. Change the Name of the newly-created variable to totalWeight.


Placing the Sample to be weighted variable into the Recompute for Each menu causes the weight to be calculated separately for the part of the sample that you want to weight and for the part of the sample that you don't want to weight. While we won't use the weight values that are calculated for the part of the sample which will remain un-weighted, Q does require that a valid weight value be computed for all parts of the sample.

Part 3 - Reset the values for the un-weighted part of the sample

Finally, you can use a formula to reset the weight values for the part of the sample that does not need to be weighted. This is done by assigning a value of 1 in place of the weight values that were calculated in the last section.

  1. In the Variables and Questions tab, right-click on the row number to the left of totalWeight and select Insert Variable(s) > JavaScript Formula > Numeric.
  2. Change the Label of Partial Weight.
  3. Enter the Expression: if (weighted) totalWeight; else 1
  4. Press OK.
  5. Press the yellow W for the variable in the Tags column.

Your weight is now ready to use.