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)
Issues with "outreg2" sum(log)Hello everyone, I have an issue trying to use the "outreg2" command in Stata. My code is the follow…
pvar for stata 16 and 17Hello, i downloaded the pvar package from abrigo 2016, but when i was trying to use the command pvar…
Looping over all string variables in datasetI have a dataset with a large number of variables (500+) and I am just realizing now that for many (…
coefplot for two RegressionsAll, I am trying to plot coefficients for two regressions in the same plot. using the following code…
Betta coefficient changingDear all as you can see below the beta coefficients if leasehold change when adding a variable. How …
Subscribe to:
Post Comments (Atom)
0 Response to Stata correct identification of coefficients after regression (loop)
Post a Comment