. program anova
args n1 m1 s1 n2 m2 s2 n3 m3 s3
scalar k=3
gen xbar=(n1*m1+n2*m2+n3*m3)/(n1+n2+n3)
gen s2w=((n1-1)*s1*s1+(n2-1)*s2*s2+(n3-1)*s3*s3)/(n1+n2+n3-k)
gen s2b=(n1*(m1-xbar)*(m1-xbar)+ n2*(m2-xbar)*(m2-xbar)+n3*(m3-xbar)*(m3-xbar))/(k-1)
gen F=s2b/s2w
display "F-value==" F
gen P= invF(k-1,N-k, .95)
display "P-value of the F-statistics is" P
end
I am trying to calculate P-value of F-statistics obtained by the formulas above. I want to give 9 arguments which will be scalar n1 m1 s1......n3 m3 s3. So if initiate my program and type >anova 1 2 3 4 5 6 7 8 9 it would display me the F-value and P value. This is my first time I am doing something like this and I cant figure out. Can someone help me? I can elaborate if my questions are not clear.
Related Posts with Writing a simple program to calculate ANOVA directly
Computing Average/Mean ROC Curve and AUC among different observersDear all, I was wondering if it would be possible to compute a mean ROC curve, with corresponding m…
Separating epiweeks with corresponding yearsGood day all I was wondering if you could please help. I have a data set with years 2020 and 2021. …
Contingent valuation methodI am using CVM to estimate mean WTP for a conservation program. WTP is elicited in both cash value a…
How toextract the results of various stata commands into matrices or mata universally and selectivelyFor stata commands(such as npresent, fsum, etc.) without a matrix in the return values(the result of…
changing numbers that surround decimalsI have 18,000 observations in a variable, which I have cleaned down to 60 left to address. They are …
Subscribe to:
Post Comments (Atom)
0 Response to Writing a simple program to calculate ANOVA directly
Post a Comment