我试图预测混合效果模型(逻辑回归)的固定效果。我的模特是:
MOD.MIX.1 <- glmer(PATCH_TYPE~PC1+PC2+PC3+JUL.DAY+(1|Study_area)+
(1|ID),family=binomial,data=FOR.MODEL)
我试图以这种方式预测模型:
newdata <- with(MOD.MIX.1, expand.grid(PC1=unique(PC1),
PC2=mean(FOR.MODEL$PC2),
PC3=mean(FOR.MODEL$PC3),
JUL.DAY=mean(FOR.MODEL$JUL.DAY)))
PREDICTPC1<-predict(MOD.MIX.1, newdata)
这是我得到的错误:
Error: couldn't evaluate grouping factor Study_area within model frame:
try adding grouping factor to data frame explicitly if possible
这是什么意思,我该如何处理?
数据:
structure(list(Study_area = structure(c(1L, 1L, 1L, 1L), .Label = c("GLQ",
"MEN", "STB", "STN", "STO"), class = "factor"), PATCH_CODE = structure(c(2L,
2L, 2L, 91L), .Label = c("A", "A1", "A2", "A3", "A4", "A5", "A6",
"A7", "A8", "A9", "AA1", "AA2", "AA3", "AB1", "AB2", "AB3", "AC1",
"AC2", "AC3", "AD1", "AD2", "AD3", "AE1", "AE2", "AF1", "AF2",
"AG1", "AG2", "AG3", "AH1", "AH2", "AH3", "AI1", "AI2", "AI3",
"AJ1", "AJ2", "AK1", "AK2", "AK3", "AL1", "AL2", "AL3", "AM1",
"AM2", "AM3", "AN1", "AN2", "AO1", "AO2", "AO3", "AP1", "AP2",
"AP3", "AP4", "AQ1", "AQ2", "AQ3", "AR1", "AR2", "AR3", "AS1",
"AS2", "AS3", "AS4", "AT1", "AT2", "AT3", "AT4", "AU1", "AU2",
"AU3", "AU4", "AV1", "AV2", "AV3", "AV4", "AW1", "AW2", "AW3",
"AX1", "AX2", "AX3", "AY1", "AY2", "AY3", "AZ1", "AZ2", "AZ3",
"B", "B1", "B2", "B3", "B4", "BA1", "BA2", "BA3", "BB", "BB1",
"BB2", "BB3", "BC1", "BC2", "BC3", "BD1", "BD2", "BD3", "BE1",
"BE2", "BE3", "BF1", "BF2", "BF3", "BG1", "BG2", "BG3", "BH1",
"BH2", "BH3", "BI1", "BI2", "BI3", "BJ1", "BJ2", "BJ3", "BK1",
"BK2", "BK3", "BL1", "BL2", "BL3", "BM1", "BM2", "BN1", "BN2",
"BN3", "BO1", "BO2", "BO3", "BO4", "BP1", "BP2", "BP3", "BQ1",
"BQ2", "BQ3", "BR1", "BR2", "BR3", "BS1", "BS2", "BT1", "BT2",
"BT3", "BU1", "BU2", "BU3", "BV1", "BV2", "BV3", "BW1", "BX1",
"BX2", "BY1", "BY2", "BY3", "BZ1", "BZ2", "BZ3", "BZ4", "C",
"C1", "C2", "C3", "C4", "C5", "C6", "CA1", "CA2", "CA3", "CB1",
"CB2", "CC", "CC1", "CC2", "CD1", "CE1", "CE2", "CF1", "CF2",
"CG1", "CG2", "CH1", "CH2", "CI1", "CI2", "CJ1", "CJ2", "CK1",
"CK2", "CL1", "CL2", "CM1", "CM2", "CN1", "CN2", "CO1", "CO2",
"CO3", "D", "D1", "D2", "D3", "D4", "D5", "D6", "E", "E1", "E2",
"E3", "E4", "F1", "F2", "F3", "F4", "F5", "G1", "G2", "G3", "G4",
"G5", "G6", "G7", "G8", "H1", "H2", "H3", "H4", "HH", "I1", "I2",
"I3", "I4", "J1", "J2", "J3", "J4", "J5", "J6", "J7", "J8", "J9",
"K1", "K2", "K3", "K4", "K5", "L1", "L2", "L3", "M1", "M2", "M3",
"M4", "M5", "M6", "N1", "N2", "N3", "O1", "O2", "O3", "O4", "O5",
"O6", "P1", "P2", "P3", "P4", "Q1", "Q2", "Q3", "Q4", "Q5", "R1",
"R2", "R3", "S1", "S2", "S3", "S4", "S5", "S6", "T1", "T2", "T3",
"T4", "U1", "U2", "U3", "U4", "U5", "U6", "V1", "V2", "V3", "W1",
"W2", "W3", "X1", "X2", "X3", "Y1", "Y2", "Y3", "Y4", "Z1", "Z2",
"Z3"), class = "factor"), PATCH_NAME = structure(c(1L, 1L, 1L,
35L), .Label = c("A", "AA", "AA ", "AB", "AB ", "AC", "AC ",
"AD", "AD ", "AE", "AE ", "AF", "AF ", "AG", "AG ", "AH", "AI",
"AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT",
"AU", "AV", "AW", "AX", "AY", "AZ", "B", "BA", "BB", "BC", "BD",
"BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BO",
"BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ",
"C", "CA", "CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", "CJ",
"CK", "CL", "CM", "CN", "CO", "D", "E", "F", "F ", "G", "G ",
"H", "H ", "I", "I ", "J", "J ", "K", "K ", "L", "L ", "M", "M ",
"N", "N ", "O", "O ", "P", "P ", "Q", "Q ", "R", "R ", "S", "S ",
"T", "T ", "U ", "V", "V ", "W", "W ", "X", "X ", "Y", "Y ",
"Z", "Z "), class = "factor"), REPLICATE = structure(c(1L, 1L,
1L, 1L), .Label = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
"B", "C", "H"), class = "factor"), REP_MES = c(19L, 19L, 19L,
133L), Observer = structure(c(4L, 4L, 4L, 4L), .Label = c("CM",
"JA", "JB", "JC", "SH", "SP", "TP"), class = "factor"), HAB_TYPE = structure(c(2L,
2L, 2L, 2L), .Label = c("Grazed", "Ungrazed"), class = "factor"),
PATCH_TYPE = c(1, 0, 0, 1), Male_visits__all_ = c(3L, 0L,
0L, 1L), Male_visits__successful_ = c(3L, 0L, 0L, 1L), Male_visits__for_young_ = c(0L,
0L, 0L, 0L), Female_visits__all_ = c(1L, 0L, 0L, 0L), Female_visits__successful_ = c(1L,
0L, 0L, 0L), Female_visits__for_young_ = c(0L, 0L, 0L, 0L
), Juv__Visits__all_ = c(0L, 0L, 0L, 0L), Juv__Visits__succ__ = c(0L,
0L, 0L, 0L), HERB_0 = c(0L, 0L, 40L, 10L), HERB_20 = c(0L,
0L, 10L, 0L), HERB_50 = c(0L, 0L, 0L, 0L), GRASS_0 = c(10L,
100L, 60L, 30L), GRASS_20 = c(0L, 20L, 0L, 0L), GRASS_50 = c(0L,
0L, 0L, 0L), RUSH_0 = c(0L, 0L, 0L, 0L), RUSH_20 = c(0L,
0L, 0L, 0L), RUSH_50 = c(0L, 0L, 0L, 0L), ERIC_0 = c(0L,
0L, 0L, 0L), ERIC_20 = c(0L, 0L, 0L, 0L), ERIC_50 = c(0L,
0L, 0L, 0L), BRACK_0 = c(0L, 0L, 0L, 0L), BRACK_20 = c(0L,
0L, 0L, 0L), BRACK_50 = c(0L, 0L, 0L, 0L), MOSS = c(0L, 0L,
0L, 0L), BARE = c(90L, 0L, 0L, 0L), WATER = c(0L, 0L, 0L,
0L), O_HUNG = structure(c(3L, 3L, 3L, 3L), .Label = c("BRA",
"GOR", "N", "RUS", "S"), class = "factor"), DISCREET = structure(c(5L,
17L, 17L, 5L), .Label = c("1", "10", "15", "1.5", "2", "20",
"25", "3", "4", "40", "5", "50", "6", "7", "8", "9", "NO"
), class = "factor"), Notes = structure(c(21L, NA, NA, 21L
), .Label = c("By burn", "Clear-felled conifer", "Concrete reservoir overflow",
"Female feeding 4 rf juvs, male sing", "Foraging figure includes flycatchin",
"Gorse", "Grassy area surrounded by juniper", "Male, female and 4 juvs, male singi",
"Male singing most of time, female f", "Patch of rushes",
"pr around nest (female removing fae", "Pr foraging, didn't appear to be pr",
"Pr provisioning at least 2 fledged", "Pr with 4 rf juvs",
"Pr with at least 1 rf young, male s", "Road", "Road edge",
"rows added as James Bray said the reference patches were the same in extensive bracken",
"Shorter grass under tree", "Shorter veg. surrounded by taller",
"Track", "Willow"), class = "factor"), Site = structure(c(NA_integer_,
NA_integer_, NA_integer_, NA_integer_), .Label = c("A", "B",
"C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T"), class = "factor"), Site_visit = c(NA_integer_,
NA_integer_, NA_integer_, NA_integer_), DAY = c(17L, 17L,
17L, 17L), DEAD = c(0L, 0L, 0L, 0L), StartHour = c(6L, NA,
NA, 6L), StartMinute = c(0L, NA, NA, 0L), EndHour = c(6L,
NA, NA, 6L), EndMinute = c(30L, NA, NA, 30L), DURATION = c(30L,
NA, NA, 30L), EASTING = c(297736L, NA, NA, 297991L), NORTHING = c(703033L,
NA, NA, 702934L), ELEV = c(NA_integer_, NA_integer_, NA_integer_,
NA_integer_), MONTH = c(6L, 6L, 6L, 6L), ORIENTATION = structure(c(NA_integer_,
NA_integer_, NA_integer_, NA_integer_), .Label = c("C", "N",
"S"), class = "factor"), PERCH = structure(c(NA_integer_,
NA_integer_, NA_integer_, NA_integer_), .Label = c("B", "F",
"G", "R", "T"), class = "factor"), TERR = structure(c(NA_integer_,
NA_integer_, NA_integer_, NA_integer_), .Label = "M", class = "factor"),
VISIT_NO = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_
), JUL.DAY = c(17, 17, 17, 17), ID = c("GLQ_JC_19", "GLQ_JC_19",
"GLQ_JC_19", "GLQ_JC_133"), PC1 = c(0.0435645668204425, 0.72948034145072,
0.803061560901585, 0.259840578885553), PC2 = c(-0.593400745369881,
0.848541838597916, -1.19902967772894, -0.58625628136995),
PC3 = c(-0.729043630624223, -0.534297045616433, 0.655933470491286,
-0.518820312795394)), .Names = c("Study_area", "PATCH_CODE",
"PATCH_NAME", "REPLICATE", "REP_MES", "Observer", "HAB_TYPE",
"PATCH_TYPE", "Male_visits__all_", "Male_visits__successful_",
"Male_visits__for_young_", "Female_visits__all_", "Female_visits__successful_",
"Female_visits__for_young_", "Juv__Visits__all_", "Juv__Visits__succ__",
"HERB_0", "HERB_20", "HERB_50", "GRASS_0", "GRASS_20", "GRASS_50",
"RUSH_0", "RUSH_20", "RUSH_50", "ERIC_0", "ERIC_20", "ERIC_50",
"BRACK_0", "BRACK_20", "BRACK_50", "MOSS", "BARE", "WATER", "O_HUNG",
"DISCREET", "Notes", "Site", "Site_visit", "DAY", "DEAD", "StartHour",
"StartMinute", "EndHour", "EndMinute", "DURATION", "EASTING",
"NORTHING", "ELEV", "MONTH", "ORIENTATION", "PERCH", "TERR",
"VISIT_NO", "JUL.DAY", "ID", "PC1", "PC2", "PC3"), row.names = c(NA,
4L), class = "data.frame")
模型结构
str(MOD.MIX.1)
Formal class 'glmerMod' [package "lme4"] with 13 slots
..@ resp :Reference class 'glmResp' [package "lme4"] with 11 fields
.. ..$ Ptr :<externalptr>
.. ..$ mu : num [1:1208] 0.316 0.341 0.31 0.325 0.222 ...
.. ..$ offset : num [1:1208] -0.42 -0.308 -0.45 -0.38 -0.903 ...
.. ..$ sqrtXwt: num [1:1208] 0.465 0.474 0.462 0.468 0.416 ...
.. ..$ sqrtrwt: num [1:1208] 2.15 2.11 2.16 2.14 2.41 ...
.. ..$ weights: num [1:1208] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ wtres : num [1:1208] 1.47 -0.719 -0.67 1.441 -0.534 ...
.. ..$ y : num [1:1208] 1 0 0 1 0 0 1 0 0 1 ...
.. ..$ eta : num [1:1208] -0.771 -0.659 -0.801 -0.731 -1.254 ...
.. ..$ family :List of 11
.. .. ..$ family : chr "binomial"
.. .. ..$ link : chr "logit"
.. .. ..$ linkfun :function (mu)
.. .. ..$ linkinv :function (eta)
.. .. ..$ variance :function (mu)
.. .. ..$ dev.resids:function (y, mu, wt)
.. .. ..$ aic :function (y, n, mu, wt, dev)
.. .. ..$ mu.eta :function (eta)
.. .. ..$ validmu :function (mu)
.. .. ..$ valideta :function (eta)
.. .. ..$ simulate :function (object, nsim)
.. .. ..- attr(*, "class")= chr "family"
.. ..$ n : num [1:1208] 1 1 1 1 1 1 1 1 1 1 ...
.. ..and 41 methods, of which 29 are possibly relevant:
.. .. aic, allInfo, allInfo#lmResp, copy#envRefClass, devResid, fam,
.. .. initialize, initialize#lmResp, initializePtr, Laplace, link, muEta,
.. .. ptr, ptr#lmResp, resDev, setOffset, setResp, setTheta, setWeights,
.. .. sqrtWrkWt, theta, updateMu, updateMu#lmResp, updateWts, variance,
.. .. wrkResids, wrkResp, wrss, wtWrkResp
..@ Gp : int [1:3] 0 220 222
..@ call : language glmer(formula = PATCH_TYPE ~ PC1 + PC2 + PC3 + JUL.DAY + (1 | Study_area) + (1 | ID), data = FOR.MODEL, family = binomial)
..@ frame :'data.frame': 1208 obs. of 7 variables:
.. ..$ PATCH_TYPE: num [1:1208] 1 0 0 1 0 0 1 0 0 1 ...
.. ..$ PC1 : num [1:1208] 0.0436 0.7295 0.8031 0.2598 1.1722 ...
.. ..$ PC2 : num [1:1208] -0.593 0.849 -1.199 -0.586 -1.66 ...
.. ..$ PC3 : num [1:1208] -0.729 -0.534 0.656 -0.519 2.483 ...
.. ..$ JUL.DAY : num [1:1208] 17 17 17 17 17 17 17 17 17 20 ...
.. ..$ Study_area: Factor w/ 2 levels "GLQ","MEN": 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ ID : chr [1:1208] "GLQ_JC_19" "GLQ_JC_19" "GLQ_JC_19" "GLQ_JC_133" ...
.. ..- attr(*, "terms")=Classes 'terms', 'formula' length 3 PATCH_TYPE ~ PC1 + PC2 + PC3 + JUL.DAY + (1 + Study_area) + (1 + ID)
.. .. .. ..- attr(*, "variables")= language list(PATCH_TYPE, PC1, PC2, PC3, JUL.DAY, Study_area, ID)
.. .. .. ..- attr(*, "factors")= int [1:7, 1:6] 0 1 0 0 0 0 0 0 0 1 ...
.. .. .. .. ..- attr(*, "dimnames")=List of 2
.. .. .. .. .. ..$ : chr [1:7] "PATCH_TYPE" "PC1" "PC2" "PC3" ...
.. .. .. .. .. ..$ : chr [1:6] "PC1" "PC2" "PC3" "JUL.DAY" ...
.. .. .. ..- attr(*, "term.labels")= chr [1:6] "PC1" "PC2" "PC3" "JUL.DAY" ...
.. .. .. ..- attr(*, "order")= int [1:6] 1 1 1 1 1 1
.. .. .. ..- attr(*, "intercept")= int 1
.. .. .. ..- attr(*, "response")= int 1
.. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
.. .. .. ..- attr(*, "predvars")= language list(PATCH_TYPE, PC1, PC2, PC3, JUL.DAY, Study_area, ID)
.. .. .. ..- attr(*, "dataClasses")= Named chr [1:7] "numeric" "numeric" "numeric" "numeric" ...
.. .. .. .. ..- attr(*, "names")= chr [1:7] "PATCH_TYPE" "PC1" "PC2" "PC3" ...
.. .. .. ..- attr(*, "predvars.fixed")= language list(PATCH_TYPE, PC1, PC2, PC3, JUL.DAY)
.. ..- attr(*, "formula")=Class 'formula' length 3 PATCH_TYPE ~ PC1 + PC2 + PC3 + JUL.DAY + (1 | Study_area) + (1 | ID)
.. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
..@ flist :List of 2
.. ..$ ID : Factor w/ 220 levels "GLQ_JB_58","GLQ_JB_59",..: 19 19 19 4 4 4 5 5 5 6 ...
.. ..$ Study_area: Factor w/ 2 levels "GLQ","MEN": 1 1 1 1 1 1 1 1 1 1 ...
.. ..- attr(*, "assign")= int [1:2] 1 2
..@ cnms :List of 2
.. ..$ ID : chr "(Intercept)"
.. ..$ Study_area: chr "(Intercept)"
..@ lower : num [1:2] 0 0
..@ theta : num [1:2] 0 0.365
..@ beta : num [1:5] -0.88409 0.57692 -0.14263 -0.40055 0.00369
..@ u : num [1:222] 0 0 0 0 0 0 0 0 0 0 ...
..@ devcomp:List of 2
.. ..$ cmp : Named num [1:11] 5.53 29.32 1241.23 1.86 1243.09 ...
.. .. ..- attr(*, "names")= chr [1:11] "ldL2" "ldRX2" "wrss" "ussq" ...
.. ..$ dims: Named int [1:14] 1208 1208 5 1203 2 222 1 1 0 2 ...
.. .. ..- attr(*, "names")= chr [1:14] "N" "n" "p" "nmp" ...
..@ pp :Reference class 'merPredD' [package "lme4"] with 18 fields
.. ..$ Lambdat:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..@ i : int [1:222] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. ..@ p : int [1:223] 0 1 2 3 4 5 6 7 8 9 ...
.. .. .. ..@ Dim : int [1:2] 222 222
.. .. .. ..@ Dimnames:List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : NULL
.. .. .. ..@ x : num [1:222] 0 0 0 0 0 0 0 0 0 0 ...
.. .. .. ..@ factors : list()
.. ..$ LamtUt :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..@ i : int [1:2416] 18 220 18 220 18 220 3 220 3 220 ...
.. .. .. ..@ p : int [1:1209] 0 2 4 6 8 10 12 14 16 18 ...
.. .. .. ..@ Dim : int [1:2] 222 1208
.. .. .. ..@ Dimnames:List of 2
.. .. .. .. ..$ : NULL
.. .. .. .. ..$ : NULL
.. .. .. ..@ x : num [1:2416] 0 0.17 0 0.173 0 ...
.. .. .. ..@ factors : list()
.. ..$ Lind : int [1:222] 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ Ptr :<externalptr>
.. ..$ RZX : num [1:222, 1:5] 0 0 0 0 0 0 0 0 0 0 ...
.. ..$ Ut :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..@ i : int [1:2416] 18 220 18 220 18 220 3 220 3 220 ...
.. .. .. ..@ p : int [1:1209] 0 2 4 6 8 10 12 14 16 18 ...
.. .. .. ..@ Dim : int [1:2] 222 1208
.. .. .. ..@ Dimnames:List of 2
.. .. .. .. ..$ : chr [1:222] "GLQ_JB_58" "GLQ_JB_59" "GLQ_JB_60" "GLQ_JC_133" ...
.. .. .. .. ..$ : NULL
.. .. .. ..@ x : num [1:2416] 0.465 0.465 0.474 0.474 0.462 ...
.. .. .. ..@ factors : list()
.. ..$ Utr : num [1:222] 0 0 0 0 0 0 0 0 0 0 ...
.. ..$ V : num [1:1208, 1:5] 0.465 0.474 0.462 0.468 0.416 ...
.. ..$ VtV : num [1:5, 1:5] 241 0 0 0 0 ...
.. ..$ Vtr : num [1:5] 33.49 -15.03 34.71 8.54 512.19
.. ..$ X : num [1:1208, 1:5] 1 1 1 1 1 1 1 1 1 1 ...
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:1208] "1" "2" "3" "4" ...
.. .. .. ..$ : chr [1:5] "(Intercept)" "PC1" "PC2" "PC3" ...
.. .. ..- attr(*, "assign")= int [1:5] 0 1 2 3 4
.. ..$ Xwts : num [1:1208] 0.465 0.474 0.462 0.468 0.416 ...
.. ..$ Zt :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
.. .. .. ..@ i : int [1:2416] 18 220 18 220 18 220 3 220 3 220 ...
.. .. .. ..@ p : int [1:1209] 0 2 4 6 8 10 12 14 16 18 ...
.. .. .. ..@ Dim : int [1:2] 222 1208
.. .. .. ..@ Dimnames:List of 2
.. .. .. .. ..$ : chr [1:222] "GLQ_JB_58" "GLQ_JB_59" "GLQ_JB_60" "GLQ_JC_133" ...
.. .. .. .. ..$ : NULL
.. .. .. ..@ x : num [1:2416] 1 1 1 1 1 1 1 1 1 1 ...
.. .. .. ..@ factors : list()
.. ..$ beta0 : num [1:5] 0 0 0 0 0
.. ..$ delb : num [1:5] 0 0 0 0 0
.. ..$ delu : num [1:222] 0 0 0 0 0 0 0 0 0 0 ...
.. ..$ theta : num [1:2] 0 0.365
.. ..$ u0 : num [1:222] 0 0 0 0 0 0 0 0 0 0 ...
.. ..and 42 methods, of which 30 are possibly relevant:
.. .. b, beta, CcNumer, copy#envRefClass, initialize, initializePtr,
.. .. installPars, L, ldL2, ldRX2, linPred, P, ptr, RX, RXdiag, RXi,
.. .. setBeta0, setDelb, setDelu, setTheta, solve, solveU, sqrL, u, unsc,
.. .. updateDecomp, updateL, updateLamtUt, updateRes, updateXwts
..@ optinfo:List of 7
.. ..$ optimizer: chr "Nelder_Mead"
.. ..$ control :List of 3
.. .. ..$ xst : num [1:7] 0.02 0.02 0.0641 0.0122 0.0101 ...
.. .. ..$ xt : num [1:7] 1.00e-05 1.00e-05 3.21e-05 6.10e-06 5.05e-06 ...
.. .. ..$ verbose: int 0
.. ..$ derivs :List of 2
.. .. ..$ gradient: num [1:7] 1.35e-03 -1.64e-04 -5.18e-05 -6.99e-04 8.31e-04 ...
.. .. ..$ Hessian : num [1:7, 1:7] 2.70e+02 5.34e-05 3.05e-05 -1.95e-03 -2.29e-05 ...
.. ..$ conv :List of 2
.. .. ..$ opt : num 0
.. .. ..$ lme4: list()
.. ..$ feval : num 321
.. ..$ warnings : list()
.. ..$ val : num [1:7] 0 0.365 -0.884 0.577 -0.143 ...
>
答案 0 :(得分:2)
如果你想预测仅使用固定效果(即不包括随机效果),那么你需要包括&#34; re.form = NA&#34;在预测的代码行中:
PREDICTPC1&lt; -predict(MOD.MIX.1,newdata,re.form = NA)
默认值包括预测中的随机效果,在这种情况下,您需要一个列,指定&#34; newdata&#34;中的随机效果。数据框架,正如罗宾逊先生上面指出的那样。
请参阅http://www.inside-r.org/packages/cran/lme4/docs/predict.merMod
上的文档