[R] ANCOVA with defined error terms

hpdutra hpdutra at yahoo.com
Sun Aug 23 01:19:21 CEST 2009


Hi Richard, there are no empty cells. 
I transform everything into factor, except the co-variate coon. 
Here is the full analysis with dput of the data.
I'm afraid I have not enough DF for the thre-way interaction using your
model as well. 12 plots divided in 3 blocks, each plot assigned to 2 crossed
treatments (veget and fruit two levels each), which means that my n=3. Plots
were sampled monthly for 14 months. 
I also attached the raw data, which is proportions of plates with paw
prints, but I had to use Kotz transformation to improve normality.
Thank you very much 

 track<-read.table(file.choose(), h=T)
> track<-transform(track, time=factor(time), plot=factor(plot))
> attach(track)
> summary(mymodel<-(aov(mice~veget*fruit*time+(time*block)+(time*block*veget)+(time*block*fruit)+coon+Error(block/plot,
> data = track))))

Error: block
      Df Sum Sq Mean Sq
block  2 4581.5  2290.7

Error: block:plot
            Df  Sum Sq Mean Sq  F value  Pr(>F)  
veget        1 1602.91 1602.91 379.1653 0.03267 *
fruit        1   80.07   80.07  18.9411 0.14378  
coon         1  193.53  193.53  45.7791 0.09341 .
veget:fruit  1   40.26   40.26   9.5245 0.19948  
veget:block  2  355.53  177.76  42.0495 0.10840  
fruit:block  2   15.39    7.69   1.8200 0.46423  
Residuals    1    4.23    4.23                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Error: Within
                 Df Sum Sq Mean Sq F value    Pr(>F)    
time             13 8451.5   650.1  8.7462 2.384e-06 ***
coon              1 1070.7  1070.7 14.4047 0.0008364 ***
veget:time       13 1214.4    93.4  1.2568 0.3006216    
fruit:time       13  474.7    36.5  0.4912 0.9090773    
time:block       26 2943.4   113.2  1.5230 0.1482787    
veget:fruit:time 13  726.1    55.9  0.7514 0.6992585    
veget:time:block 26 2194.9    84.4  1.1357 0.3762584    
fruit:time:block 26 2672.5   102.8  1.3828 0.2103929    
Residuals        25 1858.3    74.3                      
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
Warning message:
In aov(mice ~ veget * fruit * time + (time * block) + (time * block *  :
  Error() model is singular

> dput(track)
structure(list(plot = structure(c(1L, 5L, 6L, 7L, 8L, 9L, 10L, 
11L, 12L, 2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 4L, 
1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 4L, 1L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 9L, 
10L, 11L, 12L, 2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 
4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 4L, 1L, 5L, 
6L, 7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 
9L, 10L, 11L, 12L, 2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 2L, 3L, 4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 
4L, 1L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 2L, 3L, 4L), .Label = c("p1", 
"p10", "p11", "p12", "p2", "p3", "p4", "p5", "p6", "p7", "p8", 
"p9"), class = "factor"), veget = structure(c(2L, 1L, 2L, 1L, 
1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 
1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 
2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 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 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 
    1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
    1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 
    2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Fintact", "Fremoved"
    ), class = "factor"), time = structure(c(1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 
    6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
    7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 
    10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 
    11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 
    12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 
    13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 
    14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L), .Label = c("1", 
    "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", 
    "13", "14"), class = "factor"), block = structure(c(1L, 1L, 
    1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 
    2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
    3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 
    3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 
    1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 
    2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
    3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 
    3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 
    1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 
    2L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
    3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 
    3L), .Label = c("b1", "b2", "b3"), class = "factor"), rawcoon = c(0, 
    0.063, 0.125, 0.063, 0.25, 0.125, 0, 0, 0, 0.063, 0, 0, 0.125, 
    0, 0.375, 0.375, 0.188, 0.25, 0.063, 0.063, 0, 0.188, 0.125, 
    0.188, 0.063, 0, 0, 0, 0, 0, 0, 0, 0, 0.063, 0.063, 0, 0.063, 
    0, 0.188, 0.125, 0, 0.125, 0.063, 0, 0.125, 0, 0.188, 0, 
    0, 0, 0.063, 0.063, 0, 0, 0.063, 0, 0, 0.125, 0, 0, 0, 0, 
    0, 0.125, 0.125, 0.125, 0, 0, 0, 0, 0.063, 0, 0, 0.125, 0.063, 
    0.063, 0.188, 0, 0.063, 0.125, 0, 0, 0, 0.125, 0, 0, 0, 0.063, 
    0.063, 0, 0.188, 0.125, 0, 0.063, 0.063, 0, 0, 0.125, 0, 
    0.25, 0.188, 0, 0.063, 0.563, 0.188, 0.063, 0.188, 0, 0, 
    0.063, 0, 0, 0.063, 0, 0.063, 0.063, 0, 0.125, 0.063, 0, 
    0, 0.125, 0.063, 0.125, 0.125, 0.063, 0.063, 0.125, 0.125, 
    0.063, 0, 0.125, 0.125, 0.438, 0.125, 0.25, 0.188, 0.188, 
    0.375, 0.125, 0.25, 0.313, 0.063, 0.063, 0, 0.063, 0, 0, 
    0.063, 0.063, 0, 0, 0.125, 0.063, 0.063, 0.063, 0.063, 0.063, 
    0, 0.063, 0.125, 0, 0.313, 0, 0, 0.063, 0, 0.125), coon = c(8.605276544, 
    16.64929378, 22.12023855, 16.64929378, 30.73522506, 22.12023855, 
    8.605276544, 8.605276544, 8.605276544, 16.64929378, 8.605276544, 
    8.605276544, 22.12023855, 8.605276544, 38.09196076, 38.09196076, 
    26.67179738, 30.73522506, 16.64929378, 16.64929378, 8.605276544, 
    26.67179738, 22.12023855, 26.67179738, 16.64929378, 8.605276544, 
    8.605276544, 8.605276544, 8.605276544, 8.605276544, 8.605276544, 
    8.605276544, 8.605276544, 16.64929378, 16.64929378, 8.605276544, 
    16.64929378, 8.605276544, 26.67179738, 22.12023855, 8.605276544, 
    22.12023855, 16.64929378, 8.605276544, 22.12023855, 8.605276544, 
    26.67179738, 8.605276544, 8.605276544, 8.605276544, 16.64929378, 
    16.64929378, 8.605276544, 8.605276544, 16.64929378, 8.605276544, 
    8.605276544, 22.12023855, 8.605276544, 8.605276544, 8.605276544, 
    8.605276544, 8.605276544, 22.12023855, 22.12023855, 22.12023855, 
    8.605276544, 8.605276544, 8.605276544, 8.605276544, 16.64929378, 
    8.605276544, 8.605276544, 22.12023855, 16.64929378, 16.64929378, 
    26.67179738, 8.605276544, 16.64929378, 22.12023855, 8.605276544, 
    8.605276544, 8.605276544, 22.12023855, 8.605276544, 8.605276544, 
    8.605276544, 16.64929378, 16.64929378, 8.605276544, 26.67179738, 
    22.12023855, 8.605276544, 16.64929378, 16.64929378, 8.605276544, 
    8.605276544, 22.12023855, 8.605276544, 30.73522506, 26.67179738, 
    8.605276544, 16.64929378, 48.42882421, 26.67179738, 16.64929378, 
    26.67179738, 8.605276544, 8.605276544, 16.64929378, 8.605276544, 
    8.605276544, 16.64929378, 8.605276544, 16.64929378, 16.64929378, 
    8.605276544, 22.12023855, 16.64929378, 8.605276544, 8.605276544, 
    22.12023855, 16.64929378, 22.12023855, 22.12023855, 16.64929378, 
    16.64929378, 22.12023855, 22.12023855, 16.64929378, 8.605276544, 
    22.12023855, 22.12023855, 41.57117579, 22.12023855, 30.73522506, 
    26.67179738, 26.67179738, 38.09196076, 22.12023855, 30.73522506, 
    34.50487875, 16.64929378, 16.64929378, 8.605276544, 16.64929378, 
    8.605276544, 8.605276544, 16.64929378, 16.64929378, 8.605276544, 
    8.605276544, 22.12023855, 16.64929378, 16.64929378, 16.64929378, 
    16.64929378, 16.64929378, 8.605276544, 16.64929378, 22.12023855, 
    8.605276544, 34.50487875, 8.605276544, 8.605276544, 16.64929378, 
    8.605276544, 22.12023855), mice = c(26.67179738, 45, 26.67179738, 
    41.57117579, 38.09196076, 26.67179738, 8.605276544, 8.605276544, 
    16.64929378, 8.605276544, 30.73522506, 16.64929378, 41.57117579, 
    48.42882421, 16.64929378, 38.09196076, 30.73522506, 16.64929378, 
    16.64929378, 8.605276544, 16.64929378, 26.67179738, 16.64929378, 
    22.12023855, 51.90803924, 38.09196076, 34.50487875, 48.42882421, 
    8.605276544, 16.64929378, 26.67179738, 8.605276544, 8.605276544, 
    26.67179738, 22.12023855, 34.50487875, 41.57117579, 30.73522506, 
    38.09196076, 16.64929378, 34.50487875, 30.73522506, 8.605276544, 
    8.605276544, 51.90803924, 22.12023855, 30.73522506, 8.605276544, 
    34.50487875, 41.57117579, 26.67179738, 38.09196076, 22.12023855, 
    16.64929378, 16.64929378, 22.12023855, 30.73522506, 26.67179738, 
    22.12023855, 34.50487875, 26.67179738, 34.50487875, 22.12023855, 
    55.49512125, 16.64929378, 16.64929378, 34.50487875, 16.64929378, 
    41.57117579, 26.67179738, 16.64929378, 22.12023855, 59.26477494, 
    45, 41.57117579, 51.90803924, 41.57117579, 16.64929378, 34.50487875, 
    41.57117579, 34.50487875, 30.73522506, 22.12023855, 26.67179738, 
    30.73522506, 51.90803924, 51.90803924, 51.90803924, 41.57117579, 
    22.12023855, 38.09196076, 22.12023855, 26.67179738, 34.50487875, 
    26.67179738, 22.12023855, 41.57117579, 63.32820262, 26.67179738, 
    45, 34.50487875, 16.64929378, 30.73522506, 34.50487875, 30.73522506, 
    41.57117579, 30.73522506, 38.09196076, 38.09196076, 38.09196076, 
    22.12023855, 26.67179738, 34.50487875, 26.67179738, 38.09196076, 
    34.50487875, 34.50487875, 38.09196076, 16.64929378, 22.12023855, 
    38.09196076, 30.73522506, 51.90803924, 38.09196076, 16.64929378, 
    30.73522506, 16.64929378, 30.73522506, 59.26477494, 38.09196076, 
    38.09196076, 45, 34.50487875, 38.09196076, 26.67179738, 34.50487875, 
    22.12023855, 26.67179738, 45, 22.12023855, 34.50487875, 26.67179738, 
    8.605276544, 30.73522506, 22.12023855, 30.73522506, 16.64929378, 
    22.12023855, 26.67179738, 8.605276544, 30.73522506, 16.64929378, 
    26.67179738, 16.64929378, 8.605276544, 26.67179738, 51.90803924, 
    63.32820262, 30.73522506, 59.26477494, 48.42882421, 45, 59.26477494, 
    38.09196076, 48.42882421, 51.90803924, 51.90803924, 51.90803924
    ), rawmice = c(0.188, 0.5, 0.188, 0.438, 0.375, 0.188, 0, 
    0, 0.063, 0, 0.25, 0.063, 0.438, 0.563, 0.063, 0.375, 0.25, 
    0.063, 0.063, 0, 0.063, 0.188, 0.063, 0.125, 0.625, 0.375, 
    0.313, 0.563, 0, 0.063, 0.188, 0, 0, 0.188, 0.125, 0.313, 
    0.438, 0.25, 0.375, 0.063, 0.313, 0.25, 0, 0, 0.625, 0.125, 
    0.25, 0, 0.313, 0.438, 0.188, 0.375, 0.125, 0.063, 0.063, 
    0.125, 0.25, 0.188, 0.125, 0.313, 0.188, 0.313, 0.125, 0.688, 
    0.063, 0.063, 0.313, 0.063, 0.438, 0.188, 0.063, 0.125, 0.75, 
    0.5, 0.438, 0.625, 0.438, 0.063, 0.313, 0.438, 0.313, 0.25, 
    0.125, 0.188, 0.25, 0.625, 0.625, 0.625, 0.438, 0.125, 0.375, 
    0.125, 0.188, 0.313, 0.188, 0.125, 0.438, 0.813, 0.188, 0.5, 
    0.313, 0.063, 0.25, 0.313, 0.25, 0.438, 0.25, 0.375, 0.375, 
    0.375, 0.125, 0.188, 0.313, 0.188, 0.375, 0.313, 0.313, 0.375, 
    0.063, 0.125, 0.375, 0.25, 0.625, 0.375, 0.063, 0.25, 0.063, 
    0.25, 0.75, 0.375, 0.375, 0.5, 0.313, 0.375, 0.188, 0.313, 
    0.125, 0.188, 0.5, 0.125, 0.313, 0.188, 0, 0.25, 0.125, 0.25, 
    0.063, 0.125, 0.188, 0, 0.25, 0.063, 0.188, 0.063, 0, 0.188, 
    0.625, 0.813, 0.25, 0.75, 0.563, 0.5, 0.75, 0.375, 0.563, 
    0.625, 0.625, 0.625)), .Names = c("plot", "veget", "fruit", 
"time", "block", "rawcoon", "coon", "mice", "rawmice"), row.names = c(NA, 
-168L), class = "data.frame")


Richard M. Heiberger wrote:
> 
> The three-way interactions you mention are included in the model formula
> I suggested.  If they didn't appear in the expansion, it suggests
> that you have some aliasing due to empty cells.
> 
> I can't do any more without your dataset.
> You can post your dataset with random response values.
> The exact data.frame for the predictors is needed.
> Anything that is a factor must be a factor in what you send.
> You can use dput to ensure accurate copying.
> 
> 
>  > tmp <- data.frame(a=factor(rep(letters[1:3], 2)), y=rnorm(6))
>  > tmp
>    a          y
> 1 a -0.4313252
> 2 b -0.9065241
> 3 c -0.7285257
> 4 a  0.0368019
> 5 b  0.7982373
> 6 c -2.4712612
>  > dput(tmp)
> structure(list(a = structure(c(1L, 2L, 3L, 1L, 2L, 3L), .Label = c("a",
> "b", "c"), class = "factor"), y = c(-0.431325155041393,
> -0.906524086347679,
> -0.728525691910586, 0.0368018971284965, 0.798237317168781,
> -2.47126116272324
> )), .Names = c("a", "y"), row.names = c(NA, -6L), class = "data.frame")
>  >
>  >
>  > structure(list(a = structure(c(1L, 2L, 3L, 1L, 2L, 3L), .Label = c("a",
> + "b", "c"), class = "factor"), y = c(-0.431325155041393, 
> -0.906524086347679,
> + -0.728525691910586, 0.0368018971284965, 0.798237317168781, 
> -2.47126116272324
> + )), .Names = c("a", "y"), row.names = c(NA, -6L), class = "data.frame")
>    a          y
> 1 a -0.4313252
> 2 b -0.9065241
> 3 c -0.7285257
> 4 a  0.0368019
> 5 b  0.7982373
> 6 c -2.4712612
>  >
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/ANCOVA-with-defined-error-terms-tp25055311p25097730.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list