Hello,
First time poster (and < 1 year Stata user) so feel free to suggest improvements for posting etiquette!
Here's my question: how can I calculate higher moments (in particular, Pearson's moment coefficient of skewness) for variables in such a way that it accounts for inverse probability survey weights)?
I'm working with survey data (Stata 14.1 on Mac OS X 10.11.2) but do not know how to incorporate svy or pweight into commands that generate higher moments for survey variables.
The following code runs but does not account for survey weights (pweights)
Code:
summarize incentive if aco_analytic_X1 == 1, detail
Meanwhile, when I enter
Code:
svy: summarize incentive if aco_analytic_X1 == 1, detail
I've tried Nick Cox's -moments- but it appears that it does not support pweight. When I enter:
Code:
moments incentive if aco_analytic_X1 == 1 [pweight=fwt]
In an ideal world, I would incorporate such code into the overall command framework that I'm using for my analysis. I'm using a loop structure with -putexcel- to create summary statistics (mean and sd) into an excel document.
Code:
******************************************************************************** ** Table 1. Summary descriptives ** ******************************************************************************** ************ Summarize DVs from respective analytic samples ******************** putexcel set table1, replace loc row = 2 local n = 0 foreach x in $dv { if `x'_analytic_X1 == 1 { local n = `n' + 1 svy: mean `x' estat sd putexcel A`row'=("`x'") B`row'=matrix(e(b)) C`row'=matrix(r(sd)) loc row = `row' + 1 } } *************** Summarize covariates from ACO analytic sample ****************** putexcel A1=("variable") B1=("mean") C1=("sd") loc row = 6 local n = 0 foreach x in $X1 { if aco_analytic_X1 == 1 { local n = `n' + 1 svy: mean `x' estat sd putexcel A`row'=("`x'") B`row'=matrix(e(b)) C`row'=matrix(r(sd)) loc row = `row' + 1 } }
Thanks!
Adam
Comment