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
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
Comment