Iker Vaquero Alba
2015-Jul-02 17:14 UTC
[R] no slot of name "fixef" for this object of class "lmerMod"
?? Hello everyone. ?? I am trying to re-analyse some data with an R function I last used in 2011. Everything seemed to work fine then, but now, using the same code, it gives me this error: ?? Error in R.pe(y, group1, group2, returnR = FALSE) : ? no slot of name "fixef" for this object of class "lmerMod" ?? This is the part of the function that I think is relevant for the problem: ?? # preparation ??? #n <- rowSums(y) ??? N <- length(y) ??? k <- length(unique(group1)) # clone ??? g <- length(unique(group2)) # round ??? # ??? require(lme4) ??? # functions ??? R.pe <- function(y, group1, group2, returnR=TRUE) { ??? ?mod <- lmer(y ~ 1 + (1|group1)+(1|group2),verbose=FALSE) ??? ??? VarComp? <- lme4::VarCorr(mod) ??? ??? beta0??? <- as.numeric(mod at fixef) ??? ??? var.e <- attr(VarComp, "sc")^2 # residual variance ??? ??? var.a1 <- (as.numeric(VarComp[1])) # e.g. get clone R ??? ??? var.a2 <- (as.numeric(VarComp[2])) # e.g. get round R ??? ??? ??? R.group1? <- var.a1/(var.a1+var.e) # clone level ????????????????? R.group2? <- var.a2/(var.a2+var.e) ????????????????? R.groupr? <- var.a1/(var.a1+var.e+var.a2) ??? ??? if(returnR) return(list(R.group1=R.group1,R.group2=R.group2,R.groupr=R.groupr)) ??? ??? else return(list(beta0=beta0, var.e=var.e, var.a1=var.a1, var.a2=var.a2)) ??? } ?? I would appreciate any help about this. Let me know if you need more code, the function is obviously longer. ?? Thank you very much in advance. ?? Iker __________________________________________________________________ ?? Dr. Iker Vaquero-Alba ?? Daphne du Maurier ?? Centre for Ecology and Conservation ?? College of Life and Environmental Sciences ?? University of Exeter, Cornwall Campus ?? TR10 9FE ?? Penryn ?? U.K. ?? http://biosciences.exeter.ac.uk/cec/staff/postgradresearch/ikervaquero-alba/ ?? https://eric.exeter.ac.uk/repository/handle/10036/3381 [[alternative HTML version deleted]]
Thierry Onkelinx
2015-Jul-03 10:00 UTC
[R] no slot of name "fixef" for this object of class "lmerMod"
Dear Iker, The internals of the mer model have changed. Use fixef(your.model). Best regards, ? ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey Op 2 jul. 2015 22:17 schreef "Iker Vaquero Alba" <karraspito at yahoo.es>:> Hello everyone. > I am trying to re-analyse some data with an R function I last used in > 2011. Everything seemed to work fine then, but now, using the same code, it > gives me this error: > Error in R.pe(y, group1, group2, returnR = FALSE) : > no slot of name "fixef" for this object of class "lmerMod" > This is the part of the function that I think is relevant for the > problem: > # preparation > #n <- rowSums(y) > N <- length(y) > k <- length(unique(group1)) # clone > g <- length(unique(group2)) # round > # > require(lme4) > # functions > R.pe <- function(y, group1, group2, returnR=TRUE) { > mod <- lmer(y ~ 1 + (1|group1)+(1|group2),verbose=FALSE) > VarComp <- lme4::VarCorr(mod) > beta0 <- as.numeric(mod at fixef) > var.e <- attr(VarComp, "sc")^2 # residual variance > var.a1 <- (as.numeric(VarComp[1])) # e.g. get clone R > var.a2 <- (as.numeric(VarComp[2])) # e.g. get round R > R.group1 <- var.a1/(var.a1+var.e) # clone level > R.group2 <- var.a2/(var.a2+var.e) > R.groupr <- var.a1/(var.a1+var.e+var.a2) > if(returnR) > return(list(R.group1=R.group1,R.group2=R.group2,R.groupr=R.groupr)) > else return(list(beta0=beta0, var.e=var.e, var.a1=var.a1, > var.a2=var.a2)) > } > > > I would appreciate any help about this. Let me know if you need more > code, the function is obviously longer. > Thank you very much in advance. > Iker > __________________________________________________________________ > > Dr. Iker Vaquero-Alba > Daphne du Maurier > Centre for Ecology and Conservation > College of Life and Environmental Sciences > University of Exeter, Cornwall Campus > TR10 9FE > Penryn > U.K. > > > http://biosciences.exeter.ac.uk/cec/staff/postgradresearch/ikervaquero-alba/ > > https://eric.exeter.ac.uk/repository/handle/10036/3381 > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]
Iker Vaquero Alba
2015-Jul-03 11:59 UTC
[R] no slot of name "fixef" for this object of class "lmerMod"
?? Dear Thierry, ?? Thank you very much. Do you mean I should add a line to the function with the code "fixef(my.model)", retaining everything else, even the "beta0??? <- as.numeric(mod at fixef)" line? Or should I replace something??? Also, when you say "fixef(my.model), do you mean "fixef(mod)" (as in my case "mod <- lmer(y ~ 1 + (1|group1)+(1|group2),verbose=FALSE)"? ?? Thank you very much again.?? Iker ?__________________________________________________________________ ?? Dr. Iker Vaquero-Alba ?? Daphne du Maurier ?? Centre for Ecology and Conservation ?? College of Life and Environmental Sciences ?? University of Exeter, Cornwall Campus ?? TR10 9FE ?? Penryn ?? U.K. ?? http://biosciences.exeter.ac.uk/cec/staff/postgradresearch/ikervaquero-alba/ ?? https://eric.exeter.ac.uk/repository/handle/10036/3381 De: Thierry Onkelinx <thierry.onkelinx at inbo.be> Para: Iker Vaquero Alba <karraspito at yahoo.es> CC: r-help at r-project.org Enviado: Viernes 3 de julio de 2015 11:00 Asunto: Re: [R] no slot of name "fixef" for this object of class "lmerMod" Dear Iker,The internals of the mer model have changed. Use fixef(your.model). Best regards,? ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht BelgiumTo call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John TukeyOp 2 jul. 2015 22:17 schreef "Iker Vaquero Alba" <karraspito at yahoo.es>: ?? Hello everyone. ?? I am trying to re-analyse some data with an R function I last used in 2011. Everything seemed to work fine then, but now, using the same code, it gives me this error: ?? Error in R.pe(y, group1, group2, returnR = FALSE) : ? no slot of name "fixef" for this object of class "lmerMod" ?? This is the part of the function that I think is relevant for the problem: ?? # preparation ??? #n <- rowSums(y) ??? N <- length(y) ??? k <- length(unique(group1)) # clone ??? g <- length(unique(group2)) # round ??? # ??? require(lme4) ??? # functions ??? R.pe <- function(y, group1, group2, returnR=TRUE) { ??? ?mod <- lmer(y ~ 1 + (1|group1)+(1|group2),verbose=FALSE) ??? ??? VarComp? <- lme4::VarCorr(mod) ??? ??? beta0??? <- as.numeric(mod at fixef) ??? ??? var.e <- attr(VarComp, "sc")^2 # residual variance ??? ??? var.a1 <- (as.numeric(VarComp[1])) # e.g. get clone R ??? ??? var.a2 <- (as.numeric(VarComp[2])) # e.g. get round R ??? ??? ??? R.group1? <- var.a1/(var.a1+var.e) # clone level ????????????????? R.group2? <- var.a2/(var.a2+var.e) ????????????????? R.groupr? <- var.a1/(var.a1+var.e+var.a2) ??? ??? if(returnR) return(list(R.group1=R.group1,R.group2=R.group2,R.groupr=R.groupr)) ??? ??? else return(list(beta0=beta0, var.e=var.e, var.a1=var.a1, var.a2=var.a2)) ??? } ?? I would appreciate any help about this. Let me know if you need more code, the function is obviously longer. ?? Thank you very much in advance. ?? Iker __________________________________________________________________ ?? Dr. Iker Vaquero-Alba ??? Daphne du Maurier ??? Centre for Ecology and Conservation ??? College of Life and Environmental Sciences ??? University of Exeter, Cornwall Campus ??? TR10 9FE ??? Penryn ??? U.K. ??? http://biosciences.exeter.ac.uk/cec/staff/postgradresearch/ikervaquero-alba/ ??? https://eric.exeter.ac.uk/repository/handle/10036/3381 ? ? ? ? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]