Repeated Measures ANOVA in R: ezANOVA Error One or more Cells missing Data

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

Originally we were thinking a one-way ANOVA, but it seems like I need to do a Two-way because I have two independent variables. The session (the time that the minnow trap samples were taken) and TRAP (the individual trap (four per hole to be averaged) for each alligator hole in each macrocosm. CPUE would be the dependent variable, and then the ID column.

SESSION TRAP    CPUE    ID One     M1E1    3   1 One     M1E2    0   2 One     M1E3    0   3 One     M1E4    2   4 One     M1W1    0   5 One     M1W2    0   6 One     M1W3    0   7 One     M1W4    0   8 One     M2E1    0   9 One     M2E2    0   10 One     M2E3    0   11 One     M2E4    0   12 One     M2W1    0   13 One     M2W2    1   14 One     M2W3    1   15 One M2W4    0   16 One M3E1    5   17 One M3E2    2   18 One M3E3    0   19 One M3E4    3   20 One M3W1    0   21 One M3W2    0   22 One M3W3    0   23 One M3W4    2   24 One M4E1    0   25 One M4E2    1   26 One M4E3    0   27 One M4E4    0   28 One M4W1    0   29 One M4W2    0   30 One M4W3    0   31 One M4W4    8   32 Two M4E1    23  33 Two M4E2    5   34 Two M4E3    0   35 Two     M4E4    10  36 Two     M4W1    23  37 Two     M4W2    7   38 Two     M4W3    1   39 Two     M4W4    7   40 Two     M3E1    6   41 Two     M3E2    3   42 Two     M3E3    5   43 Two     M3E4    10  44 Two     M3W1    8   45 Two     M3W2    0   46 Two     M3W3    1   47 Two     M3W4    5   48 Two     M2E1    12  49 Two     M2E2    15  50 Two     M2E3    3   51 Two     M2E4    10  52 Two     M2W1    5   53 Two     M2W2    11  54 Two     M2W3    6   55 Two     M2W4    4   56 Two     M1E1    13  57 Two     M1E2    19  58 Two     M1E3    3   59 Two     M1E4    30  60 Two     M1W1    16  61 Two     M1W2    2   62 Two     M1W3    4   63 Two     M1W4    27  64 Three   M4E1    0   65 Three   M4E2    26  66 Three   M4E3    3   67 Three   M4E4    13  68 Three   M4W1    9   69 Three   M4W2    0   70 Three   M4W3    4   71 Three   M4W4    2   72 Three   M3E1    29  73 Three   M3E2    0   74 Three   M3E3    0   75 Three   M3E4    11  76 Three   M3W1    27  77 Three   M3W2    5   78 Three   M3W3    8   79 Three   M3W4    3   80 Three   M2E1    5   81 Three   M2E2    11  82 Three   M2E3    62  83 Three   M2E4    31  84 Three   M2W1    11  85 Three   M2W2    1   86 Three   M2W3    0   87 Three   M2W4    9   88 Three   M1E1    48  89 Three   M1E2    78  90 Three   M1E3    14  91 Three   M1E4    7   92 Three   M1W1    3   93 Three   M1W2    63  94 Three   M1W3    43  95 Three   M1W4    31  96  

I am using this command:

> output = ezANOVA(data = CSV.Repeated.Measures.ANOVA.Minnow._2cm.R.Data.Sheet, dv= CPUE, wid = ID, within = .(SESSION, TRAP), detailed = TRUE, type = 3) 

I Get this error message:

Error in ezANOVA_main(data = data, dv = dv, wid = wid, within = within, : One or more cells is missing data. Try using ezDesign() to check your data.

I don't know what the exDesign() is trying to tell me either.

回答1:

I will try to give a solution to your problem with ezANOVA. Of course, it would be necessary to know all the details of your experiment for a complete and correct answer to your question.

If I am not wrong, you wrote that minnow traps are the sample units of the experiment and repeated measures are made on these units (under different experimental conditions). Hence the IDs of the sample units are not those stored in the column ID; a new id variable needs to be generated.
Here is the dataset:

df <- structure(list(SESSION = structure(c(1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L,  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,  3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L,  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("One", "Three",  "Two"), class = "factor"), TRAP = structure(c(1L, 2L, 3L, 4L,  1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,  1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,  1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,  1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,  1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,  1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c("1",  "2", "3", "4"), class = "factor"), CPUE = c(3L, 0L, 0L, 2L, 0L,  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 5L, 2L, 0L, 3L, 0L,  0L, 0L, 2L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 8L, 23L, 5L, 0L, 10L,  23L, 7L, 1L, 7L, 6L, 3L, 5L, 10L, 8L, 0L, 1L, 5L, 12L, 15L, 3L,  10L, 5L, 11L, 6L, 4L, 13L, 19L, 3L, 30L, 16L, 2L, 4L, 27L, 0L,  26L, 3L, 13L, 9L, 0L, 4L, 2L, 29L, 0L, 0L, 11L, 27L, 5L, 8L,  3L, 5L, 11L, 62L, 31L, 11L, 1L, 0L, 9L, 48L, 78L, 14L, 7L, 3L,  63L, 43L, 31L), ID = structure(1:96, .Label = c("1", "2", "3",  "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",  "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",  "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37",  "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48",  "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",  "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70",  "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81",  "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92",  "93", "94", "95", "96"), class = "factor"), MACROCOSM = structure(c(1L,  1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,  3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,  4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L,  2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 4L,  4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L,  2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("1",  "2", "3", "4"), class = "factor"), HOLE = structure(c(1L, 1L,  1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,  1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,  1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,  1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,  1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,  1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("E",  "W"), class = "factor")), .Names = c("SESSION", "TRAP", "CPUE",  "ID", "MACROCOSM", "HOLE"), row.names = c(NA, -96L), class = "data.frame") 

and here is the code that (hopefully) should show you the way for finding a solution to your problem:

df$MACROCOSM <- factor(substr(df$TRAP, 2, 2)) df$HOLE <- factor(substr(df$TRAP, 3, 3)) df$TRAP <- factor(substr(df$TRAP, 4, 4))  library(ez) ezOut <- ezANOVA(data = df,      dv=CPUE, wid = .(TRAP), within = .(SESSION,HOLE,MACROCOSM),      detailed = TRUE, type = 1) print(ezOut)  ############# $ANOVA                   Effect DFn DFd       SSn        SSd          F           p p<.05        ges 1                SESSION   2   6 4372.5625  753.35417 17.4123780 0.003174556     * 0.30542230 2                   HOLE   1   3  276.7604   56.11458 14.7961760 0.031011624     * 0.02707856 3              MACROCOSM   3   9 2030.5313 1466.76042  4.1530939 0.041961697     * 0.16957246 4           SESSION:HOLE   2   6  216.2708   60.47917 10.7278677 0.010436491     * 0.02128617 5      SESSION:MACROCOSM   6  18 2327.6875 3995.39583  1.7477774 0.167180534       0.18968127 6         HOLE:MACROCOSM   3   9  198.6146 1070.34375  0.5566845 0.656642963       0.01958241 7 SESSION:HOLE:MACROCOSM   6  18  461.4792 2541.43750  0.5447458 0.767574519       0.04435012 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!