0

I would like to calculate the SDs of Quartiles in one code using a weighted analysis with the survey package.

With the means of the Quartiles it works like this:

svyby(~ x, by = ~as.factor(var_in_quartiles), design = weights, FUN = svymean)

With output:

  as.factor(WAISTquart)     x        se
1                     1 1.467615 0.05541616
2                     2 1.389899 0.06070003
3                     3 1.294789 0.04032355
4                     4 1.156874 0.02414524

If I try this with svysd to get SDs i get the error:

Error: $ operator is invalid for atomic vectors

Anyone know a solution? Or just recalulate the SDs with the given SEs?

H. berg
  • 471
  • 1
  • 3
  • 11
  • [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making an R question that folks can help with. That includes a sample of data, all necessary code, and a clear explanation of what you're trying to do and what hasn't worked. – camille Dec 30 '19 at 16:12
  • Never mind I already found the answer and its really easy, just add all the variables you want to konw the SDs from with '+' sign! see: https://rdrr.io/cran/jtools/man/svysd.html – H. berg Dec 30 '19 at 19:57

0 Answers0