Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: ANOVA model (my mistake)


From   David Airey <[email protected]>
To   [email protected]
Subject   st: re: ANOVA model (my mistake)
Date   Mon, 30 Sep 2002 15:05:21 -0500

My version of Stata disagrees with what you say about numbering schemes. Here is data and the same test repeated twice with different numbering schemes for the subsamples, and code used to generate the data can results. Note the different results.

drop _all
set obs 150
*only difference in next line
egen neuron = seq(), from(1) to(3) block(1)
egen subject = seq(), from(1) to(10) block(15)
egen treatment = seq(), from(1) to(5) block(3)
gen a = invnorm(uniform()) in 1/10
gen a_effect = a[subject]
drop a
gen c_effect = invnorm(uniform())
gen error = invnorm(uniform())
gen measure = a_effect + c_effect + error

* correct RMA model nesting neuron in subject
anova measure subject / neuron|subject treatment / treatment*subject /, repeated(treatment)
test treatment / treatment*subject

neuron subject treatm~t measure
1. 1 1 1 1.232982
2. 2 1 1 1.166421
3. 3 1 1 1.674022
4. 1 1 2 1.690412
5. 2 1 2 1.079583
6. 3 1 2 1.983932
7. 1 1 3 -1.573235
8. 2 1 3 2.714028
9. 3 1 3 3.24
10. 1 1 4 1.470877
11. 2 1 4 4.342456
12. 3 1 4 .1263056
13. 1 1 5 3.049922
14. 2 1 5 2.537046
15. 3 1 5 -.7629604
16. 1 2 1 -1.013575
17. 2 2 1 .6785818
18. 3 2 1 -1.619054
19. 1 2 2 1.396539
20. 2 2 2 .9016123
21. 3 2 2 -2.113595
22. 1 2 3 2.285021
23. 2 2 3 .9567382
24. 3 2 3 2.037529
25. 1 2 4 .5208883
etc.
Number of obs = 150 R-squared = 0.6542
Root MSE = 1.46849 Adj R-squared = 0.3560

Source | Partial SS df MS F Prob > F
------------------+----------------------------------------------------
Model | 326.402584 69 4.73047224 2.19 0.0004
|
subject | 211.95834 9 23.5509266 8.84 0.0000
neuron|subject | 53.2741741 20 2.66370871
------------------+----------------------------------------------------
treatment | 2.60790639 4 .651976599 0.40 0.8068
treatment*subject | 58.5621641 36 1.62672678
------------------+----------------------------------------------------
treatment*subject | 58.5621641 36 1.62672678 0.75 0.8249
|
Residual | 172.515961 80 2.15644951
------------------+----------------------------------------------------
Total | 498.918545 149 3.34844661


drop _all
set obs 150
egen neuron = seq(), from(1) to(150) block(1)
egen subject = seq(), from(1) to(10) block(15)
egen treatment = seq(), from(1) to(5) block(3)
gen a = invnorm(uniform()) in 1/10
gen a_effect = a[subject]
drop a
gen c_effect = invnorm(uniform())
gen error = invnorm(uniform())
gen measure = a_effect + c_effect + error

* correct RMA model nesting neuron in subject
anova measure subject / neuron|subject treatment / treatment*subject /, repeated(treatment)
test treatment / treatment*subject

neuron subject treatm~t measure
1. 1 1 1 3.588527
2. 2 1 1 2.431523
3. 3 1 1 1.267083
4. 4 1 2 2.137298
5. 5 1 2 1.644081
6. 6 1 2 4.000641
7. 7 1 3 2.452223
8. 8 1 3 2.811015
9. 9 1 3 2.97793
10. 10 1 4 1.751251
11. 11 1 4 3.431399
12. 12 1 4 .4201414
13. 13 1 5 1.742686
14. 14 1 5 .4739965
15. 15 1 5 1.596641
16. 16 2 1 -.9146303
17. 17 2 1 -.5972514
18. 18 2 1 -1.519495
19. 19 2 2 -.6959237
20. 20 2 2 -.3078359
21. 21 2 2 -.5360426
22. 22 2 3 .9754638
23. 23 2 3 -.007028
24. 24 2 3 -.2681147
25. 25 2 4 1.523469
etc.

Number of obs = 150 R-squared = 1.0000
Root MSE = 0.00 Adj R-squared =

Source | Partial SS df MS F Prob > F
------------------+----------------------------------------------------
Model | 495.194439 149 3.32345261
|
subject | 234.868301 9 26.0964779 13.89 0.0000
neuron|subject | 255.445948 136 1.87827903
------------------+----------------------------------------------------
treatment | 11.6365863 4 2.90914656
treatment*subject | 0.00 0
------------------+----------------------------------------------------
treatment*subject | 0.00 0
|
Residual | 0.00 0
------------------+----------------------------------------------------
Total | 495.194439 149 3.32345261

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index