Hello
I am struggling to store the results of ttest in matrix using loops. I have stname (string variable ) representing state and also state (numeric). I tried using both strings and numerics but not successful. i would like to have to state name also in the output matrix. Kindly help
Below is the code:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
foreach s in "Andhra Pradesh" "Karnataka" "Rajasthan" {
foreach v of varlist $metric_imp {
ds `v'
ds `s'
di `"`: var label `v''"'
capture noisily ttest `v' if stname==`s', by (sample)
*gen stname="Andhra Pradesh"
matrix ap_metric_t= (`s' r(N_1), r(N_2), r(p), r(p_l), r(p_u), r(t))
matrix rownames ap_metric_t= `v'
*matrix colnames AP_int4 = N1 N2 pscore pscorel pscoreu t
mat2txt, matrix(ap_metric_t) sav("census_metric_t.xlx") append
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Related Posts with t test output in matrix using loops
Editing graphHi, I need to edit a graph that starts from 0 to start from 10. I know how to change the x axis ran…
How to add scatter plot to xtline and modify its colours accordinglyHi, I'm trying to add orginial data to xtline. Sometimes a unit exhibits a constant variable over se…
How to take a random sample of panel data and keep all person-year-observations for a particular IDI try to take a random sample from a huge unbalanced panel dataset. For the MWE data, I would like t…
Combining the values of different categories into ONE with a repeated IDI have a variable (foodgr) which is divided into 4 categories (1,2,3,4). I have another variable, v…
Mediation analysis (bias-corrected bootstrapping): Using panel survey data with fixed effects (sem/gsem/xtdpdml command)Hello, I am new to the Stata forum (let me know if I have not correctly followed the forum's rules)…
Subscribe to:
Post Comments (Atom)
0 Response to t test output in matrix using loops
Post a Comment