1

该调用mF@X应返回固定效果设计矩阵(对于 glmm 中的边际和条件 R^2 是必需的)。但是它不起作用。模型结构中是否列出了这样的矩阵?

我很感激任何建议。

str(mF)
Formal class 'glmerMod' [package "lme4"] with 13 slots
  ..@ resp   :Reference class 'glmResp' [package "lme4"] with 11 fields
  .. ..$ Ptr    :<externalptr> 
  .. ..$ mu     : num [1:480] 0.168 0.356 0.168 0.356 0.284 ...
  .. ..$ offset : num [1:480] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ sqrtXwt: num [1:480] 0.373 0.479 0.373 0.479 0.451 ...
  .. ..$ sqrtrwt: num [1:480] 2.68 2.09 2.68 2.09 2.22 ...
  .. ..$ weights: num [1:480] 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ wtres  : num [1:480] -0.449 -0.744 -0.449 1.344 -0.629 ...
  .. ..$ y      : num [1:480] 0 0 0 1 0 0 0 1 0 0 ...
  .. ..$ eta    : num [1:480] -1.603 -0.591 -1.603 -0.591 -0.927 ...
  .. ..$ 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:480] 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 60 72
  ..@ call   : language lme4::glmer(formula = Colour ~ Treatment + Habitat + (1 | Population) + (1 |      Container), data = Data, family = "binomial", control = structure(list( ...
  ..@ frame  :'data.frame': 480 obs. of  5 variables:
  .. ..$ Colour    : int [1:480] 0 0 0 1 0 0 0 1 0 0 ...
  .. ..$ Treatment : Factor w/ 2 levels "Cont","Exp": 1 2 1 2 1 2 1 2 1 2 ...
  .. ..$ Habitat   : Factor w/ 2 levels "A","B": 1 1 1 1 2 2 2 2 1 1 ...
  .. ..$ Population: int [1:480] 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ Container : int [1:480] 2 2 2 2 2 2 2 2 4 4 ...
  .. ..- attr(*, "terms")=Classes 'terms', 'formula' length 3 Colour ~ Treatment + Habitat + (1 + Population) + (1 + Container)
  .. .. .. ..- attr(*, "variables")= language list(Colour, Treatment, Habitat, Population, Container)
  .. .. .. ..- attr(*, "factors")= int [1:5, 1:4] 0 1 0 0 0 0 0 1 0 0 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:5] "Colour" "Treatment" "Habitat" "Population" ...
  .. .. .. .. .. ..$ : chr [1:4] "Treatment" "Habitat" "Population" "Container"
  .. .. .. ..- attr(*, "term.labels")= chr [1:4] "Treatment" "Habitat" "Population" "Container"
  .. .. .. ..- attr(*, "order")= int [1:4] 1 1 1 1
  .. .. .. ..- attr(*, "intercept")= int 1
  .. .. .. ..- attr(*, "response")= int 1
  .. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
  .. .. .. ..- attr(*, "predvars")= language list(Colour, Treatment, Habitat, Population, Container)
  .. .. .. ..- attr(*, "dataClasses")= Named chr [1:5] "numeric" "factor" "factor" "numeric" ...
  .. .. .. .. ..- attr(*, "names")= chr [1:5] "Colour" "Treatment" "Habitat" "Population" ...
  .. .. .. ..- attr(*, "predvars.fixed")= language list(Colour, Treatment, Habitat)
  .. ..- attr(*, "formula")=Class 'formula' length 3 Colour ~ Treatment + Habitat + (1 | Population) + (1 | Container)
  .. .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
  ..@ flist  :List of 2
  .. ..$ Container : Factor w/ 60 levels "2","4","6","8",..: 1 1 1 1 1 1 1 1 2 2 ...
  .. ..$ Population: Factor w/ 12 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
  .. ..- attr(*, "assign")= int [1:2] 1 2
  ..@ cnms   :List of 2
  .. ..$ Container : chr "(Intercept)"
  .. ..$ Population: chr "(Intercept)"
  ..@ lower  : num [1:2] 0 0
  ..@ theta  : num [1:2] 0.0761 1.0537
  ..@ beta   : num [1:3] -1.251 1.012 0.676
  ..@ u      : num [1:72] -0.05 0.0254 -0.05 0.1008 -0.05 ...
  ..@ devcomp:List of 2
  .. ..$ cmp : Named num [1:11] 27.3 8.5 438.1 10.6 448.7 ...
  .. .. ..- attr(*, "names")= chr [1:11] "ldL2" "ldRX2" "wrss" "ussq" ...
  .. ..$ dims: Named int [1:14] 480 480 3 477 2 72 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:72] 0 1 2 3 4 5 6 7 8 9 ...
  .. .. .. ..@ p       : int [1:73] 0 1 2 3 4 5 6 7 8 9 ...
  .. .. .. ..@ Dim     : int [1:2] 72 72
  .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. ..$ : NULL
  .. .. .. .. ..$ : NULL
  .. .. .. ..@ x       : num [1:72] 0.0761 0.0761 0.0761 0.0761 0.0761 ...
  .. .. .. ..@ factors : list()
  .. ..$ LamtUt :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ i       : int [1:960] 0 60 0 60 0 60 0 60 0 60 ...
  .. .. .. ..@ p       : int [1:481] 0 2 4 6 8 10 12 14 16 18 ...
  .. .. .. ..@ Dim     : int [1:2] 72 480
  .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. ..$ : NULL
  .. .. .. .. ..$ : NULL
  .. .. .. ..@ x       : num [1:960] 0.0284 0.3935 0.0365 0.5046 0.0284 ...
  .. .. .. ..@ factors : list()
  .. ..$ Lind   : int [1:72] 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ Ptr    :<externalptr> 
  .. ..$ RZX    : num [1:72, 1:3] 0.124 0.125 0.124 0.125 0.124 ...
  .. ..$ Ut     :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ i       : int [1:960] 0 60 0 60 0 60 0 60 0 60 ...
  .. .. .. ..@ p       : int [1:481] 0 2 4 6 8 10 12 14 16 18 ...
  .. .. .. ..@ Dim     : int [1:2] 72 480
  .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. ..$ : chr [1:72] "2" "4" "6" "8" ...
  .. .. .. .. ..$ : NULL
  .. .. .. ..@ x       : num [1:960] 0.373 0.373 0.479 0.479 0.373 ...
  .. .. .. ..@ factors : list()
  .. ..$ Utr    : num [1:72] -0.094 -0.018 -0.094 0.058 -0.094 ...
  .. ..$ V      : num [1:480, 1:3] 0.373 0.479 0.373 0.479 0.451 ...
  .. ..$ VtV    : num [1:3, 1:3] 92.7 0 0 48.3 48.3 ...
  .. ..$ Vtr    : num [1:3] 15.738 0.879 3.455
  .. ..$ X      : num [1:480, 1:3] 1 1 1 1 1 1 1 1 1 1 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : chr [1:480] "1" "2" "3" "4" ...
  .. .. .. ..$ : chr [1:3] "(Intercept)" "TreatmentExp" "HabitatB"
  .. .. ..- attr(*, "assign")= int [1:3] 0 1 2
  .. .. ..- attr(*, "contrasts")=List of 2
  .. .. .. ..$ Treatment: chr "contr.treatment"
  .. .. .. ..$ Habitat  : chr "contr.treatment"
  .. ..$ Xwts   : num [1:480] 0.373 0.479 0.373 0.479 0.451 ...
  .. ..$ Zt     :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ i       : int [1:960] 0 60 0 60 0 60 0 60 0 60 ...
  .. .. .. ..@ p       : int [1:481] 0 2 4 6 8 10 12 14 16 18 ...
  .. .. .. ..@ Dim     : int [1:2] 72 480
  .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. ..$ : chr [1:72] "2" "4" "6" "8" ...
  .. .. .. .. ..$ : NULL
  .. .. .. ..@ x       : num [1:960] 1 1 1 1 1 1 1 1 1 1 ...
  .. .. .. ..@ factors : list()
  .. ..$ beta0  : num [1:3] 0 0 0
  .. ..$ delb   : num [1:3] 0 0 0
  .. ..$ delu   : num [1:72] -0.05 0.0254 -0.05 0.1008 -0.05 ...
  .. ..$ theta  : num [1:2] 0.0761 1.0537
  .. ..$ u0     : num [1:72] 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:5] 0.02 0.02 0.0721 0.0421 0.0418
  .. .. ..$ xt     : num [1:5] 1.00e-05 1.00e-05 3.60e-05 2.11e-05 2.09e-05
  .. .. ..$ verbose: int 0
  .. ..$ derivs   :List of 2
  .. .. ..$ gradient: num [1:5] 4.64e-05 9.60e-05 -6.73e-05 -6.46e-05 -1.26e-04
  .. .. ..$ Hessian : num [1:5, 1:5] 2.644 -0.247 0.162 -1.023 -0.625 ...
  .. ..$ conv     :List of 2
  .. .. ..$ opt : num 0
  .. .. ..$ lme4: list()
  .. ..$ feval    : num 232
  .. ..$ warnings : list()
  .. ..$ val      : num [1:5] 0.0761 1.0537 -1.2511 1.0118 0.676
4

1 回答 1

5

您可以使用该函数model.matrix获得固定效应设计矩阵:

model.matrix(fit)

fit返回的对象在哪里glmer

于 2014-05-27T07:21:32.670 回答