--
Check out our R resources at http://d-rug.github.io/
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/davis-rug.
For more options, visit https://groups.google.com/d/optout.
--
Check out our R resources at http://d-rug.github.io/
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+...@googlegroups.com.
library(readxl)
library(tidyr)
d <- read_excel('Ratings.xls', col_types=c("text", rep("numeric", 6)))
Then reshape the data and use xtabs
to see that there is
only one observation per factor level. (You could see this from your
original data but this method works with larger data sets and more
complex interactions of factors.)
dl <-d %>%
gather(sample, rating, -ID)
xtabs(~ sample + ID, dl)
#> ID
#> sample 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 3 4 5 6 7 8 9
#> 133 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 382 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 415 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 671 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 692 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 973 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
With only one observation you can't estimate an interaction in a 2-way anova because there are no degrees of freedom to estimate the residual variance (error). To see why this is, consult the example of how to do an ANOVA by hand and note that without replication within each combination of factor levels, K=1.
What can you do instead? I'm not sure if Evan B meant to suggest that there are ways to model (which implies, to me, a way to estimate a parameter) an interaction term. I don't know if that's possible with this type of data however, you can test various null hypotheses about an interaction via one of many tests for non-additivity, some of which are provided in the r package additivityTests
. The exact test you should use depends on what you want to assume about the structure of the interaction (read the linked review).
Note that even if there is no indication of an interaction there is still another potential issue with your data and interpretation of the two-way ANOVA, which is that the outcomes are ratings and thus non-normal. This may matter or not depending on your exact question, for example if you are making a quantitative interpretation of coefficients this would matter. It doesn't matter for simply testing whether there is an effect of sample. If you want method designed for this kind of outcome variable, see the r package ordinal.