I have a list of coefficient and standard error averages (following my previous post 1576600-table-after-tuples-forval to be more exact). I've run a new model taking one of the variables out and I would like to see how my (average) coefficients changed. I was hoping to use command -suest- to see if my column b in model 1 is significantly different from my column b on model 2.
Model 1:
Code:
set seed 12345
. set obs 100
number of observations (_N) was 7, now 100
. local dvar y
. gen `dvar' = runiformint(0, 1)
. local always_vars x1 x2 x3
. foreach a of local always_vars {
2. gen `a' = rnormal()
3. }
. local tlist w1 w2 w3 w4
. foreach t of local tlist {
2. gen `t' = rnormal()
3. }
.
. local nvars: word count `tlist'
.
. local ntuples = 0
.
. forvalues i = 1/`nvars' {
2. forvalues j = `=`i'+1'/`nvars' {
3. local v1: word `i' of `tlist'
4. local v2: word `j' of `tlist'
5. local ++ntuples
6. local tuple`ntuples' `v1' `v2'
7. }
8. }
.
.
.
.
. tempfile results
.
. capture postutil clear
.
. local results_vars
. foreach v of varlist `always_vars' `tlist' {
2. local results_vars `results_vars' b_`v' se_`v'
3. }
.
. local initial
. foreach v of varlist `always_vars' {
2. local initial `initial' (_b[`v']) (_se[`v'])
3. }
.
. postfile handle `results_vars' using `results'
.
.
. forvalues i = 1/`ntuples' {
2. display `"`tuple`i''"'
3. quietly regress `dvar' `always_vars' `tuple`i'', vce(robust)
4. if c(rc) == 0 {
5. local topost `initial'
6. foreach v of local tlist {
7. if strpos("`e(cmdline)'", "`v'") {
8. local topost `topost' (_b[`v']) (_se[`v'])
9. }
10. else {
11. local topost `topost' (.) (.)
12. }
13. }
14. post handle `topost'
15. }
16. else if inlist(c(rc), 2000, 2001) { // NO, OR TOO FEW OBSERVATIONS
17. continue
18. }
19. else { // REGRESSION FAILED DUE UNEXPECTED PROBLEM: ABORT
20. display as error "Unexpected error with `tuple`i''"
21. exit(c(rc))
22. }
23.
. }
w1 w2
w1 w3
w1 w4
w2 w3
w2 w4
w3 w4
.
. postclose handle
.
. use `results', clear
.
.
. local critical_value_5 = invnormal(0.975)
.
. foreach v in `always_vars' `tlist' {
2. gen byte sig05_`v' = abs(b_`v'/se_`v') > `critical_value_5' ///
> if !missing(b_`v', se_`v')
3. order sig05_`v', after(se_`v')
4. }
(3 missing values generated)
(3 missing values generated)
(3 missing values generated)
(3 missing values generated)
.
.
. collapse (mean) _all
.
. gen one = 1
.
. reshape long b_ se_ sig05_, i(one) j(varname) string
(note: j = w1 w2 w3 w4 x1 x2 x3)
Data wide -> long
-----------------------------------------------------------------------------
Number of obs. 1 -> 7
Number of variables 22 -> 5
j variable (7 values) -> varname
xij variables:
b_w1 b_w2 ... b_x3 -> b_
se_w1 se_w2 ... se_x3 -> se_
sig05_w1 sig05_w2 ... sig05_x3 -> sig05_
-----------------------------------------------------------------------------
.
. rename *_ *
.
. drop one
.
. list, noobs clean
varname b se sig05
w1 -.0421191 .045018 0
w2 -.0723879 .0540686 0
w3 .0286007 .0493419 0
w4 .0096308 .0488577 0
x1 -.0032636 .0469172 0
x2 .0817245 .0491854 0
x3 -.0240363 .0476184 0
est store m1Model 2 (The same code as model 1 but without w4 on the tlist):
Code:
list, noobs clean
varname b se sig05
w2 -.0424746 .0449553 0
w3 -.0717693 .054142 0
w4 .0291465 .0490506 0
x1 -.0063258 .0469255 0
x2 .0796 .0493231 0
x3 -.025599 .047796 0
est store m2Code:
suest m1 m2 estimation sample of the model saved under m1 could not be restored
Thank you in advance
0 Response to Suest after a list?
Post a Comment