| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: syntax for nested two-factor ANOVA
I admit remaining confused about the design and think I may have sent
you down the wrong path. It is hard to suggest over the listserv,
without much thought, and without seeing the data.
In looking at the data I see you have replication in the table cells,
e.g., you have 4 cases for brand 7 and company 1 with a 0 keep
status. This is making the repeated measures request fail (I think).
I also see that you sometimes have a company with only one brand for
sale, so there is no variance in those cases that is separate between
company and brand.
Also I now imagine the experiment as you obtaining a continuous DV
measure on each box of cereal that was sold or discarded, and that
you have more than one box measured per brand, cereal combination.
/*
use http://www.ats.ucla.edu/stat/stata/examples/kirk/spf2-4, clear
// I remembered this example and made a suggestion, not really
understanding what you were doing
anova y a / s|a b a*b /, repeated(b) // a is between subject, b is
within subject, a and b are fixed, s is random
anova y a / s|a b / a*b /, repeated(b) // here, a is fixed, b and s
are random
// both compute without issue and I think are correct when making the
second factor b random
// looking at some of the data
list in 1/9
+----------------+
| a b s y |
|----------------|
1. | 1 1 1 3 |
2. | 1 2 1 4 |
3. | 1 3 1 7 |
4. | 1 4 1 7 |
|----------------|
5. | 1 1 2 6 |
6. | 1 2 2 5 |
7. | 1 3 2 8 |
8. | 1 4 2 8 |
|----------------|
9. | 1 1 3 3 |
// you see the explicit subject factor listed above
*/
You said you had data like (and I made the comparison):
(s) (a) (b) (y)
brand company keep testresult
1 1 1 .839
1 1 0 .605
2 1 1 .798
2 1 0 .567
3 2 1 .855
3 2 0 .650
etc etc etc etc
but you really have data like:
+------------------------------------+
| y keep brand company |
|------------------------------------|
1. | -.0800775 0 7 1 |
2. | .071272 0 7 1 |
3. | .1124799 0 7 1 |
4. | .3309362 0 7 1 |
5. | .0646274 1 7 1 |
6. | .1491636 1 7 1 |
7. | .3802552 1 7 1 |
8. | .3819582 1 7 1 |
9. | .4677568 1 7 1 |
which is really like:
+------------------------------------------+
| y keep brand company box |
|------------------------------------------|
1. | -.0800775 0 7 1 1 |
2. | .071272 0 7 1 2 |
3. | .1124799 0 7 1 3 |
4. | .3309362 0 7 1 4 |
5. | .0646274 1 7 1 5 |
6. | .1491636 1 7 1 6 |
7. | .3802552 1 7 1 7 |
8. | .3819582 1 7 1 8 |
9. | .4677568 1 7 1 9 |
where we have a three factor nested design, with brand nested in
company and crossed with keep, and keep is between subjects.
Since you don't have brand separable from company for half your
companies, why not simplify and just control for brand, in which case
you have a two factor ANOVA with unequal replication with one of your
factors a random (blocking) effect. Usually you don't interact that
blocking effect, so:
anova y brand keep
gives the test to look at for keep:
. anova y brand keep
Number of obs = 89 R-squared
= 0.3444
Root MSE = .199951 Adj R-squared
= 0.2409
Source | Partial SS df MS
F Prob > F
-----------
+----------------------------------------------------
Model | 1.59643837 12 .133036531
3.33 0.0007
|
brand | .504996573 11 .045908779
1.15 0.3373
keep | .905309904 1 .905309904
22.64 0.0000
|
Residual | 3.03851904 76 .039980514
-----------
+----------------------------------------------------
Total | 4.63495741 88 .052669971
In the case for a two factor ANOVA with one random factor, you might
allow interactions (unlike the randomized block model above that
assumes no interactions).
Say A is fixed and B is random, then the test for A is MSA/MSAB, for
B is MSB/MSE, and for MSAB/MSE.
So you can try also, if you allow interactions,
quietly anova y brand keep / brand*keep /
Number of obs = 89 R-squared
= 0.3971
Root MSE = .204223 Adj R-squared
= 0.2081
Source | Partial SS df MS
F Prob > F
-----------
+----------------------------------------------------
Model | 1.84058059 21 .087646695
2.10 0.0116
|
brand | .361996382 11 .032908762
1.21 0.3921
keep | .595857339 1 .595857339
21.97 0.0011
brand*keep | .244142211 9 .027126912
-----------
+----------------------------------------------------
brand*keep | .244142211 9 .027126912
0.65 0.7500
|
Residual | 2.79437683 67 .041707117
-----------
+----------------------------------------------------
Total | 4.63495741 88 .052669971
-Dave
*
* 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/