Hi,
I am new to Stata. I need to export the pvalues that I have computed using ritest (randomization inference), which I have saved in a matrix, to the final regression table alongside the std errors and coefficients. The following is the code I have for now.
Ideally, the output should be in the following format (the values in square brackets is what I need)
I am new to Stata. I need to export the pvalues that I have computed using ritest (randomization inference), which I have saved in a matrix, to the final regression table alongside the std errors and coefficients. The following is the code I have for now.
Code:
... eststo: quietly areg GAD7_line_average_el CBT_el IHT_el GAD7_line_average, absorb(factcode) robust sum GAD7_line_average_el if PC==1 estadd scalar Control_Mean = r(mean) * Randomization Inference GAD-7 * ritest CBT _b[CBT], reps(100) seed(125) strata(factcode): quietly areg GAD7_line_average_el CBT_el IHT_el GAD7_line_average, absorb(factcode) robust matrix pvalues_CBT_GAD7 = r(p) mat colnames pvalues_CBT_GAD7 = "Prevalence of Anxiety (GAD-7>=8)" mat rownames pvalues_CBT_GAD7 = "Skills Training" ritest IHT _b[IHT], reps(100) seed(125) strata(factcode): quietly areg GAD7_line_average_el CBT_el IHT_el GAD7_line_average, absorb(factcode) robust matrix pvalues_IHT_GAD7 = r(p) mat colnames pvalues_IHT_GAD7 = "Prevalence of Anxiety (GAD-7>=8)" mat rownames pvalues_IHT_GAD7 = "Health Education" ** Regressing PHQ9 ** eststo: quietly areg PHQ9_line_average_el CBT_el IHT_el PHQ9_line_average, absorb(factcode) robust sum PHQ9_line_average_el if PC==1 estadd scalar Control_Mean = r(mean) * Randomization Inference PHQ-9 * ritest CBT _b[CBT], reps(100) seed(125) strata(factcode): quietly areg PHQ9_line_average_el CBT_el IHT_el PHQ9_line_average, absorb(factcode) robust matrix pvalues_CBT_PHQ9 = r(p) mat colnames pvalues_CBT_PHQ9 = "Prevalence of Depression (PHQ-9>=10)" mat rownames pvalues_CBT_PHQ9 = "Skills Training" ritest IHT _b[IHT], reps(100) seed(125) strata(factcode): quietly areg PHQ9_line_average_el CBT_el IHT_el PHQ9_line_average, absorb(factcode) robust matrix pvalues_IHT_PHQ9 = r(p) mat colnames pvalues_IHT_PHQ9 = "Prevalence of Depression (PHQ-9>=10)" mat rownames pvalues_IHT_PHQ9 = "Health Education" matrix pvalues = pvalues_CBT_GAD7,pvalues_CBT_PHQ9\pvalues_IHT_GAD7,pvalues_IHT_PHQ9 estadd matrix pvalues = pvalues ** Tabulating the output ** esttab using table8_RI.csv, cells(b(fmt(2) star) se(fmt(2) par) pvalues(fmt(2) par([ ]))) label title(Table 8: Impact on Workers'Psychological Well-Being) nonumbers mtitles ("Prevalence of Anxiety (GAD-7>=8)" "Prevalence of Depression (PHQ-9>=10)") star(* 0.1 ** 0.05 *** 0.01) coeflabels(CBT_el "Skills Training" IHT_el "Health Education" Control_Mean "Control Mean") keep(CBT_el* IHT_el*) stats(Control_Mean N ar2, fmt(2 0 2) labels("Control Mean" "N" "Adj. R-sq")) eststo clear
Comment