I am using a large dataset (5000+) survey data with weights accounting for demographics that were underrepresented (e.g. accounting for a lack of younger participants).
I am using linear regression to find associates of my dependent variable. I have employed a stepwise regression model, including only those that remain significant within each model. My command currently is the following:
svy: regress depvar1 indvar1 indvar2 ...indvar16
I have a model that includes variables measured in different ways (continuous, categorical, dummy etc.), meaning coefficients are tricky to interpret. So I would like to report on the beta.
Unfortunately the beta option does not work when using the svy command, though I did find the following work around:
https://www.statalist.org/forums/for...-weighted-data
When I employ the above workaround (see do file below), I get an error at: st_matrix (“betas”, sx:/sy):*bx) “<istmt>: 3200 conformability error”, which means “A matrix, vector, or scalar has the wrong number of rows and/or columns for what is required. Adding a 2 x 3 matrix to a 1 x 4 would result in this error.”
I can't seem to find the source of the error in the code, and it appears to have worked for other people, so I'm at a bit of a loss.
I use stata 15, can download add ons if needed. Any additional info needed, let me know!
Any help would be greatly appreciated.
my do file:
local var1 /* outcome */
local var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var 12 var13 var14 var15 var16 length weight /* predictors */
svyset [pw = weight]
* Get coefficients *
svy: regress var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var 12 var13 var14 var15 var16
matrix b = e(b)
* Get SDs of y and predictors *
svy: mean var1
estat sd
matrix sy = r(sd)
svy: mean var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var 12 var13 var14 var15 var16
estat sd
matrix sx = r(sd)
*Compute standardized coefficients *
mata:
sy = st_matrix("sy")
sx = st_matrix("sx")'
b = st_matrix("b")
bx = b[1 ,1..(cols(b)-1)]'
st_matrix("betas",(sx:/sy):*bx)
end
Related Posts with Using response weights (svy) on a linear regression (regress) but want beta values
how to calculate the loop for variables?I need to calculate the second row variable minus the first row variable, the fourth row variable mi…
Is DiD possible for examining effect of a continuous treatment on a continuous outcome among single group dependent sample?Hi Statalist, I'm new to the forum and a novice Stata user. I'm studying the effect of a continuou…
Asymmetric predictors in dynamic panel models?Hi all, In a longitudinal analysis, I suspect that the impact of an increase in a predictor variabl…
Problem graphing by several variablesHello ! My name is Hans Huber and I was wondering if someone could help me making a certain type of…
Problem graphing by many variablesHello ! My name is Hans Huber and I was wondering if someone could help me making a certain type of…
Subscribe to:
Post Comments (Atom)
0 Response to Using response weights (svy) on a linear regression (regress) but want beta values
Post a Comment