混合设计方差分析错误:类型为'closure'的对象不可归类

时间:2018-10-04 02:29:01

标签: r anova

我正在运行2X3X3混合ANOVA设计。香港专业教育学院一直试图让学生纽曼库尔斯函数在R中工作,但我不断收到错误:类型为'closure'的对象是不可子集的。任何帮助将不胜感激!

library(ez)
library(ggplot2)
library(nlme)
library(pastecs)
library(reshape)
library(WRS)
library(GAD)
library(multcomp)
library(psych)
library(lmerTest)
CPPData <- read.table(file = "CPPdatar.csv", header=TRUE, sep = ",")
str(CPPData)
CPPData$Test<-as.factor(CPPData$Test)
CPPData$Exposure<-as.factor(CPPData$Exposure)
CPPData$Dose<-as.factor(CPPData$Dose)
CPPData$Subject<-as.factor(CPPData$Subject)
levels(CPPData$Test)<-list("Habit"=1, "Test of Conditioning"=2)
levels(CPPData$Exposure)<-list("0% HFCS CONT"=1, "50% HFCS CONT"=2, "50% HFCS INT"=3)
levels(CPPData$Dose)<-list("0 OXY"=1, "0.16 OXY"=2, "2.5 OXY"=3)
str(CPPData)
options(contrasts=c("contr.helmert", "contr.poly"))
aov1<-aov(Time~Exposure*Dose*Test+ Error(Subject/(Test)), data=CPPData)
summary(aov1)

aov2 = lme(Time~Exposure + Dose + Test, 
         random = ~1|Subject, 
         data = CPPData, 
         method = "ML")
summary(aov2)

#SNK Test
Test2<-snk.test(lm(Time~Exposure*Test*Dose, data = CPPData))
Test1<-snk.test(lm, term = Exposure*Test*Dose, among = Exposure, within = Test*Dose)
snk.test(aov2, term = "Dose:Exposure:Test", among = "Test", within = "Dose")

错误问题:

  

SNK测试

     

T est2 <-snk.test(lm(Time〜Exposure Test Dose,data = CPPData))   估算误差(对象):     设计不平衡!此功能只能处理平衡的设计。    Test1 <-snk.test(lm,术语=曝光 Test 剂量,其中=曝光,在= Test * Dose之内)   错误:“关闭”类型的对象不可子集化   > snk.test(aov2,term =“ Dose:Exposure:Test”,在=“ Test”中,在=“ Dose)   object $ model [,2:((length(object $ x)+ 1)]中的错误:     尺寸错误

Dput

  

dput(CPPData)   结构(列表(时间= c(476.98,436.94,451.79,514.68,548.38,   457.96、489.99、536.7、517.02、566.9、487.15、553.89、527.86,   580.41、310.14、508.84、364.7、456.79、616.12、598.43、447.45,   570.9、520.35、812.48、756.92、667.5、603.77、547.55、369.2,   437.6、296.96、568.74、580.91、526.19、582.92、568.23、576.74,   378.04、549.38、548.55、492.99、388.72、581.75、538.71、511.51,   895.89、851.68、685.85、741.24、738.4、662.5、485.32、746.75,   726.89、638.64、613.11、819.65、475.14、599.93、668.34、486.99,   426.26、570.74、482.48、460.13、578.08、541.37、465.63、297.13,   543.04、560.89、536.04、419.25、555.89、587.75、530.2、619.95,   778.61、602.27、403.74、792.63、815.98、599.77、784.28、543.04,   748.08、610.94、700.87、710.38、686.02、735.57、805.47、525.02,   524.86、482.65、278.28、547.21、559.23、450.95、579.91、174.17,   312.64、683.02、790.46、422.92、664、435.44、478.14、427.43,   308.31、342.84、517.02、541.54、565.73、474.81、522.02、503.34,   321.99、498.16、554.55、527.69、776.44、966.47、867.2、846.68,   554.22,750.75,435.44,769.94,561.39,544.71,404.24,464.8,   482.48、550.88、459.79、552.05、389.56、361.86、814.15、907.41,   755.92、729.9、945.11、509.34、529.86、611.78、675.84、452.79,   584.42、566.4、420.75、465.46、533.87、579.58、492.16、521.86,   565.07、594.76、280.95、563.23、537.37、409.07、439.44、547.88,   543.88、496.66、474.14、433.43、418.75、541.37、406.74、477.98,   576.58、335.5、405.74、319.49、482.15、501、409.07、610.28、667.17,   560.56、474.14、467.3、561.56、718.88、584.25、689.52、507.51,   711.04、520.19、357.52、373.04、504、360.86、470.97、489.49,   397.06、582.41、554.05、481.15、776.78、658.66、721.55、433.93,   532.03,625.79,651.48,783.78,729.06,828.5),测试=结构(c(1L,   1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,   2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,1L,1L,1L,   1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,   2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,1L,1L,1L,1L,1L,   1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,   2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,1L,1L,1L,1L,1L,   1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,1L,   1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,   2L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,2L,   2L,2L,2L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,   2L,2L,2L,2L,2L,2L,2L,1L,1L,1L,1L,1L,1L,1L,1L,1L,   1L,1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,1L,   1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,2L,2L,   2L,2L,2L),. Label = c(“习惯”,“条件测试”),类=“因素”),       曝光=结构(c(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,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,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,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,3L,3L,3L,3L,3L,       3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,       3L,3L,3L,3L,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,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),. Label = c(“ 0%HFCS CONT”,       “ 50%HFCS CONT”,“ 50%HFCS INT”),类别=“因子”),剂量=结构(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,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,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,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,       1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,2L,       2L,2L,2L,2L,2L,2L,2L,2L,2L,3L,3L,3L,3L,3L,3L,       3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,1L,1L,1L,       1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,       1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,       2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,3L,3L,3L,3L,       3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,3L,       3L),.Label = c(“ 0 OXY”,“ 0.16 OXY”,“ 2.5 OXY”),class =“ factor”),       主题=结构(c(1L,2L,3L,4L,5L,6L,7L,8L,9L,       10L,11L,12L,13L,14L,15L,1L,2L,3L,4L,5L,6L,7L,       8L,9L,10L,11L,12L,13L,14L,15L,16L,17L,18L,19L,       20L,21L,22L,23L,24L,25L,26L,27L,28L,29L,30L,16L,       17L,18L,19L,20L,21L,22L,23L,24L,25L,26L,27L,28L,       29L,30L,31L,32L,33L,34L,35L,36L,37L,38L,39L,40L,       41L,42L,43L,44L,45L,46L,31L,32L,33L,34L,35L,36L,       37L,38L,39L,40L,41L,42L,43L,44L,45L,46L,47L,48L,       49L,50L,51L,52L,53L,54L,55L,56L,47L,48L,49L,50L,       51L,52L,53L,54L,55L,56L,57L,58L,59L,60L,61L,62L,       63L,64L,65L,57L,58L,59L,60L,61L,62L,63L,64L,65L,       66L,67L,68L,69L,70L,71L,72L,73L,74L,66L,67L,68L,       69L,70L,71L,72L,73L,74L,75L,76L,77L,78L,79L,80L,       81L,82L,83L,84L,75L,76L,77L,78L,79L,80L,81L,82L,       83L,84L,85L,86L,87L,88L,89L,90L,91L,92L,93L,94L,       95L,96L,85L,86L,87L,88L,89L,90L,91L,92L,93L,94L,       95L,96L,97L,98L,99L,100L,101L,102L,103L,104L,105L,       106L,97L,98L,99L,100L,101L,102L,103L,104L,105L,       106L),.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”,“ 97”,“ 98”,       “ 99”,“ 100”,“ 101”,“ 102”,“ 103”,“ 104”,“ 105”,“ 106”),class =“ factor”)),row.names = c(NA,   -212L),类=“ data.frame”)

1 个答案:

答案 0 :(得分:0)

您要询问的错误原因可以在这里查看:

  

Test1 <-snk.test(lm,term = ExposureTestDose,....

字母“ lm”是函数的名称,您已将其提供给期望有可能被子集化的数据对象的函数。第一次调用确实为snk.test函数提供了一个lm创建的数据对象,但是由于给出了不同原因的代码而被停止。

就其他错误而言,似乎您需要一些统计建议。 snk.test似乎不是针对您正在运行的分析类型而设计的。您可以考虑在CrossValidated.com网站上寻求有关设计问题的帮助。 (这是另一个处理统计问题的StackExchange论坛。)