Hi all,
I'm trying to make a t-test table showing:
Group 1 Group 2 Difference T-test p-value
I'm using the following program:
capt prog drop myttests
*! version 1.0.0 14aug2007 Ben Jann
program myttests, eclass
version 8
syntax varlist [if] [in], by(varname) [ * ]
marksample touse
markout `touse' `by'
tempname mu_1 mu_2 d d_t d_p
foreach var of local varlist {
qui ttest `var' if `touse', by(`by') `options'
mat `mu_1' = nullmat(`mu_1'), r(mu_1)
mat `mu_2' = nullmat(`mu_2'), r(mu_2)
mat `d' = nullmat(`d' ), r(mu_1)-r(mu_2)
mat `d_t' = nullmat(`d_t' ), r(t)
mat `d_p' = nullmat(`d_p' ), r(p)
}
foreach mat in mu_1 mu_2 d d_se d_t d_p {
mat coln ``mat'' = `varlist'
}
tempname b V
mat `b' = `mu_1'*0
mat `V' = `b''*`b'
eret post `b' `V'
eret local cmd "myttests"
foreach mat in mu_1 mu_2 d d_t d_p {
eret mat `mat' = ``mat''
}
end
use "${root}/${output}/total_merge.dta"
myttests pcapcons totcons, by(hh_rem)
ereturn list
esttab, nomtitle nonumbers noobs ///
cells("mu_1 mu_2 d_t d_p")
It seems to work well until I get the following error:
. myttests pcapcons totcons, by(hh_rem)
pcapcons not found
r(111);
Can anyone see what I'm doing wrong here? pcapcons is clearly in the list of variables and I've tried to both copy in and write it out in the do-file... I really have no idea what's going on.
Thank you very much in advance!
I'm trying to make a t-test table showing:
Group 1 Group 2 Difference T-test p-value
I'm using the following program:
capt prog drop myttests
*! version 1.0.0 14aug2007 Ben Jann
program myttests, eclass
version 8
syntax varlist [if] [in], by(varname) [ * ]
marksample touse
markout `touse' `by'
tempname mu_1 mu_2 d d_t d_p
foreach var of local varlist {
qui ttest `var' if `touse', by(`by') `options'
mat `mu_1' = nullmat(`mu_1'), r(mu_1)
mat `mu_2' = nullmat(`mu_2'), r(mu_2)
mat `d' = nullmat(`d' ), r(mu_1)-r(mu_2)
mat `d_t' = nullmat(`d_t' ), r(t)
mat `d_p' = nullmat(`d_p' ), r(p)
}
foreach mat in mu_1 mu_2 d d_se d_t d_p {
mat coln ``mat'' = `varlist'
}
tempname b V
mat `b' = `mu_1'*0
mat `V' = `b''*`b'
eret post `b' `V'
eret local cmd "myttests"
foreach mat in mu_1 mu_2 d d_t d_p {
eret mat `mat' = ``mat''
}
end
use "${root}/${output}/total_merge.dta"
myttests pcapcons totcons, by(hh_rem)
ereturn list
esttab, nomtitle nonumbers noobs ///
cells("mu_1 mu_2 d_t d_p")
It seems to work well until I get the following error:
. myttests pcapcons totcons, by(hh_rem)
pcapcons not found
r(111);
Can anyone see what I'm doing wrong here? pcapcons is clearly in the list of variables and I've tried to both copy in and write it out in the do-file... I really have no idea what's going on.
Thank you very much in advance!