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
How do I identify a variable within a date intervalHI, Would someone be able to help me with a code for how to identify a viable within a date interva…
Difference-in-difference with three time periodsHi statalist, I’m running a difference in difference model with time fixed effects. My sample inclu…
Interpretation regression results moderation with factor variableHi all! I hope you can help me out with the interpretation of my regression results as the internet…
effect size for one group wich is own control groupHi omnes, I am searching a stata function for calculatting size effect. There is esize wich use Hed…
replace with multiple if statementHello everyone, I am trying to replace values of the variable "NomenCode" based on multiple if state…
Subscribe to:
Post Comments (Atom)
0 Response to t test output in matrix using loops
Post a Comment