0

I have a question regarding R and surveydata. In my data (N=5,017) I assigned a weightfactor to all respondents which are calculated by combining 3 factors: neighbourhood (N=14), age (N=3) and gender (N=2). With: max = 6.2, min = 0.3 and mean = 1. We feel like the weight of 6.2 is too high. So I found a function to trim weights: trimWeights (survey). It seems that the function indeed trims the weights within the set limits (max = 3.0, min = 0.33). However, between 3 and 6.2 (almost) everyone gets the trimmed weight of 3. In my believe the weights should be distributed equally within the total dataset, with mean = 1.

Example of the dataset:

R Original weightfactor Trimmed weightfactor
1 6.193072 3
2 6.026637 3
3 4.688075 3
4 3.318347 3
5 3.235760 2.875892
6 2.638860 2.672271
7 2.175128 2.236251

Does anyone know how to distribute the trimmed weights more equally towards the original weights? Maybe I miss some argument within the function or is there another function in another package that can dissolve this? Thanks in advance!! :)

Code:

trimmed_1 <- trimWeights(svy.data,lower=0.33, upper=3) 

I tried the arguments compress & strict, but that doesn't work.

jrcalabrese
  • 2,184
  • 3
  • 10
  • 30
  • 1
    The function is doing what is intended: if you trim the weighs with an upper limit of 3, the weights that were previously greater than 3 will mostly end up equal to 3. If you look at the code, you can see that writing a function to do something different wouldn't be that hard. – Thomas Lumley Mar 11 '23 at 00:33

0 Answers0