I would like to know how to capture confidence interval for mean difference. I have two groups- intervention and control. After conducting ttest, I want to get the result of confidence interval for mean difference. I know ttest result shows 'differ' but I have more than 10 variables and don't want to copy and past the result from screen.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(cost_strip cost_monitoring) byte rand_trt 0 0 1 0 128.205 0 .87 0 1 .29 0 1 0 167.055 0 0 168.35 0 .58 177.415 0 0 164.465 0 0 181.3 0 .29 185.185 0 1.45 0 1 .29 182.595 0 .29 0 1 .29 0 1 .29 0 1 0 189.07 0 .29 0 1 0 0 1 0 120.435 0 0 167.055 0 .58 186.48 0 .29 0 1 0 0 1 .29 170.94 0 0 0 1 .29 186.48 0 0 0 1 .29 0 1 .29 0 1 0 0 1 end
Code:
global X cost_strip cost_monitoring
foreach x of global X {
{
qui sum `x' if rand_trt==0
gen int`x'= r(mean)
qui sum `x' if rand_trt==1
scalar con`x' = r(mean)
gen diff = int`x' - con`x'
qui ci mean diff
scalar c = r(lb)
scalar d = r(ub)
}
*di "`x' " _skip(10) %12.1f c _skip(10) %12.1f d _skip(10)
}
Many thanks in advance.
BW
Kim
0 Response to confidence interval for mean difference
Post a Comment