Hello,
I have used the following code to create a bar plot showing the mean time in medium-to-vigorous physical activity (MVPA) split up by gender und Walkscore (a measure of the walkability of a neighborhood). I was wondering whether it is possible to plot the p-value of a ttest into the graph? Either manually or by automatically transferring it from the output of the ttest (preferred). Thanks a lot for your hints in advance.
collapse (mean) mmvpa_all=mvpa_all (sd) sdmvpa_all=mvpa_all (count) n=mvpa_all, by(girl ws_half) cw
gen himvpa_all=mmvpa_all + invttail(n-1,0.025)*(sdmvpa_all/sqrt(n))
gen lomvpa_all=mmvpa_all - invttail(n-1,0.025)*(sdmvpa_all/sqrt(n))
gen girlws=girl if ws_half==1
replace girlws=girl+3 if ws_half==2
twoway (bar mmvpa_all girlws if girl==0) ///
(bar mmvpa_all girlws if girl==1) ///
(rcap himvpa_all lomvpa_all girlws, lc(black)), ///
legend(row(1) order(1 "Male" 2 "Female")) ///
xlabel(0.5 "Low" 3.5 "High", noticks) ///
xtitle("Walkscore") ytitle("Mean Time in MVPA")
I have used the following code to create a bar plot showing the mean time in medium-to-vigorous physical activity (MVPA) split up by gender und Walkscore (a measure of the walkability of a neighborhood). I was wondering whether it is possible to plot the p-value of a ttest into the graph? Either manually or by automatically transferring it from the output of the ttest (preferred). Thanks a lot for your hints in advance.
collapse (mean) mmvpa_all=mvpa_all (sd) sdmvpa_all=mvpa_all (count) n=mvpa_all, by(girl ws_half) cw
gen himvpa_all=mmvpa_all + invttail(n-1,0.025)*(sdmvpa_all/sqrt(n))
gen lomvpa_all=mmvpa_all - invttail(n-1,0.025)*(sdmvpa_all/sqrt(n))
gen girlws=girl if ws_half==1
replace girlws=girl+3 if ws_half==2
twoway (bar mmvpa_all girlws if girl==0) ///
(bar mmvpa_all girlws if girl==1) ///
(rcap himvpa_all lomvpa_all girlws, lc(black)), ///
legend(row(1) order(1 "Male" 2 "Female")) ///
xlabel(0.5 "Low" 3.5 "High", noticks) ///
xtitle("Walkscore") ytitle("Mean Time in MVPA")
Comment