Skip to content

[package-car:Anova] extracting residuals from Anova for Type II/III Repeated Measures ?

7 messages · Tal Galili, Peter Dalgaard, John Fox

#
Dear Tal,

I suppose that the "between" residuals would be obtained, for your example,
by residuals(mod.ok). I'm not sure what the "within" residuals are. You
could apply the transformation for each within-subject effect to the matrix
of residuals to get residuals for that effect -- is that what you had in
mind? A list of transformations is in the element $P of the Anova.mlm
object.

Regards,
 John

------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox
On
residuals
http://www.R-project.org/posting-guide.html
1 day later
#
Dear Tal,

I didn't have time to look at all this yesterday.

Since aov() doesn't do what I typically want to do, I guess I've not paid
much attention to it recently. I can see, however, that you appear to have
specified the error strata incorrectly, since (given your desire to compare
to Anova) the within-block factors are nested within blocks. Something like
should be closer to what you want, and in fact produces all of the sums of
squares, but doesn't put all of the error terms together with the
corresponding terms; thus, you get, e.g., the test for N but not for P and
K, even though the SSs and error SSs for the latter are in the table. By
permuting N, P, and K, you can get the other F tests. I suspect that this
has to do with the sequential approach taken by aov() but someone else more
familiar with how it works will have to fill in the details. I wonder,
though, whether you've read the sections in Statistical Models in S and MASS
referenced in the help file for aov.
Error: block
          Df  Sum Sq Mean Sq F value Pr(>F)
Residuals  5 153.147  30.629               

Error: P
  Df Sum Sq Mean Sq
P  1 16.803  16.803

Error: K
  Df Sum Sq Mean Sq
K  1 190.40  190.40

Error: block:N
          Df Sum Sq Mean Sq F value   Pr(>F)   
N          1 378.56  378.56  38.614 0.001577 **
Residuals  5  49.02    9.80                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Error: block:P
          Df  Sum Sq Mean Sq F value Pr(>F)
Residuals  5 19.1317  3.8263               

Error: block:K
          Df  Sum Sq Mean Sq F value Pr(>F)
Residuals  5 24.4933  4.8987               

Error: P:K
    Df  Sum Sq Mean Sq
P:K  1 0.96333 0.96333

Error: block:N:P
          Df Sum Sq Mean Sq F value  Pr(>F)  
N:P        1 42.563  42.563  8.6888 0.03197 *
Residuals  5 24.493   4.899                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Error: block:N:K
          Df Sum Sq Mean Sq F value  Pr(>F)   
N:K        1 66.270  66.270  17.320 0.00881 **
Residuals  5 19.132   3.826                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Error: block:P:K
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  5 49.018   9.804               

Error: block:N:P:K
          Df  Sum Sq Mean Sq F value Pr(>F)
N:P:K      1  74.003  74.003  2.4161 0.1808
Residuals  5 153.147  30.629               


John
Type
output,
when
for
where
yielded
combination
You
had
Anova.mlm
for
type
F
4.6323
2.5558
2.8555
20.8651
4.8997
0.2078
0.6366
17.0067
0.0929
0.4094
0.6204
1.1525
0.3256
0.6900
0.7359
#
John Fox wrote:
Does it not help if you use Error(block/(N*P*K))? I suspect you're being 
bitten by operator precedence, of the same making as the fact that 1/2*2 
is 1, not 0.25.

	-pd
#
Hello John, thanks for your reply and correction.
I apologies for my crude mistake in applying the aov (now I have
learned better). I hope to get a hold of "Statistical Models in S",
but I don't predict it could easily happen in the near future.

Also, I would be very happy if you could supply me with some more
directions as to how to obtain the "within" residuals (such as
reported from the aov summary), since I am not sure how to proceed
with that.

With regards,
Tal
On Sat, Feb 21, 2009 at 12:41 AM, John Fox <jfox at mcmaster.ca> wrote:
--
----------------------------------------------


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
www.talgalili.com
www.biostatistics.co.il
#
Dear Peter,

Yes, you're absolutely right -- of course (though I didn't notice it!), the
precedence of / and * in a formula is like division and multiplication in an
arithmetic expression. With this correction, the SSs and error SSs are
properly matched by aov(), producing the same F-tests as Anova().

Thank you,
 John
Type
paid
have
compare
like
of
and
this
more