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
multiple regression when significant difference between groups within 1 regression?Hi there, I am studying the effect of becoming a parent on the earnings of fathers versus mothers. …
Putexcel, Save Multiple Tables into One ExcelHello everyone, I am a beginner in Stata and encountered a problem while using putexcel. I ran: bys…
How to draw Chinese map in stata?Dear statalisits, I recently puzzeled by using stata to draw Chinese map. "How to draw Chinese map i…
Can someone help?! Can not get the mean of observations vertically! (with missing values)I have several financial metrics for about 60,000 stocks (+2.5M observations), and a sample of my Re…
Merging two panel datasetI am facing problem to merge the individual data set e.g Dataset 1: prepaid data for location 1 has…
Subscribe to:
Post Comments (Atom)
0 Response to Using response weights (svy) on a linear regression (regress) but want beta values
Post a Comment