Dear all,
I am currently working on a dataset (with information on time allocated from people to many different activities, collected with 3 surveys over 3 years) where I have to run many regressions. The explanatory var are always the 3 years (year_1, year_2, year_3) while the dependent is changing (every regression has a different activity as dependent var), Moreover, I am also running all these different regression on different subsamples of the dataset (i.e., only male aged in same range). Finally, after the estimation, I want to perform a linear hypothesis test on the difference between the estimated values of the coefficients of the first and last year.
I am using a loop I found.
In this loop I refer to some local I create in this same do-file, which are:1) "variables", containing the activities (in the example belolw, it actually contains only one activity); 2)"surveys" which contains year_1, year_2 and year_3; 3) "sample" (which I rewrite here before the loop cause it is a local defined different from what I am used to, because it is not selecting a group of variables but a group of observations, in this case only males in the second age class).
local sample = "if sex==1 & age_2"
local i = 1
foreach var of varlist `variables' {
quietly reg `var' `survey' [aw=weight_tot] `sample', noc
local addstat = _b[year_3]-_b[year_1]
lincom _b[year_3]-_b[year_1]
local coef=r(estimate)
local se=r(se)
local t=`coef'/`se'
local pval=2*ttail(e(df_r),abs(`t'))
if `i'==2 {
outreg2 `survey' using UnpaidWork_3554_Male01-03.xls, ctitle(`var')bdec(2) se nor2 noaster addstat("Change01-03",`addstat', "P Value01-03",`pval') append
}
if `i'==1 {
outreg2 `survey' using UnpaidWork_3554_Male01-03.xls, title(35-54 Male) ctitle(`var') bdec(2) se nor2 noaster addstat("Change01-03",`addstat', "P Value01-03",`pval') replace
local i=2
}
}
Since I found this loop, I would like to be sure about what it is doing when saying "local coef=r(estimate)". It is taking the estimated difference of my hipothesis test identified by " lincom _b[survey_03]-_b[survey_01]", isn't it?
Thank you a lot in advance!!
Related Posts with Stata correct identification of coefficients after regression (loop)
Difference between dates in monthI have dates %tdD_m_Y format and I want to create an indicator if they are exactly one month apart, …
Bootstraping the CPS from IPUMS using bsampleHello, I'm working with the basic CPS as provided by IPUMS. I need to bootstrap the data to comput…
How can I get difference between two dates in daysHello, I want to get the difference between these two dates (Fenddt - Rptdt) in days at a new variab…
Part-time Stata ADO programmer neededExperienced Stata ADO & mata programmer needed for part-time work on multiverse robustness analy…
Iterations in ARDL modelsDear Stata users, I am conducting a study using a panel of 48 countries over 1981-2018. The followi…
Subscribe to:
Post Comments (Atom)
0 Response to Stata correct identification of coefficients after regression (loop)
Post a Comment