[Rd] summary of lme4.0 model in package

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Apr 3 12:09:16 CEST 2014


Dear all,

My package has Depends: lme4.0 in the DESCRIPTION. I need to extract the fixed effect of a model and their standard errors. I use coef(summary(model)) inside a function to do that. Model is the output of a call to glmer() from the lme4.0 package.

coef(summary(model)) throws an error: $ operator is invalid for atomic vectors

I have tracked it down to a problem with summary(model) because str(summary(model)) gives this

Classes 'summaryDefault', 'table'  Named chr [1:3] "1" "mer" "S4"
  ..- attr(*, "names")= chr [1:3] "Length" "Class" "Mode"

But it should return

Formal class 'summary.mer' [package "lme4.0"] with 42 slots
  ..@ methTitle: chr "Generalized linear mixed model fit by the Laplace approximation"
  ..@ logLik   :Class 'logLik' : -2265 (df=12)
--- output snipped ---

What puzzles me is that the function gives the error when called from the package, but works fine when I source the code of the function manually.

#this fails
MyPackage:MyFunction(model)
#this works
source("MyPackage/R/MyFunction.R")
MyFunction(model)

Any idea on what is going wrong and how to fix this?

sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Dutch_Belgium.1252  LC_CTYPE=Dutch_Belgium.1252    LC_MONETARY=Dutch_Belgium.1252
[4] LC_NUMERIC=C                   LC_TIME=Dutch_Belgium.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] sendmailR_1.1-2   base64enc_0.1-1   ABV_0.2-21        lme4.0_0.999999-4 lattice_0.20-28   Matrix_1.1-3

loaded via a namespace (and not attached):
 [1] AFLP_0.4.0-66       colorspace_1.2-4    dichromat_2.0-0     digest_0.6.4        Epi_1.1.63
 [6] fortunes_1.5-2      ggplot2_0.9.3.1.99  grid_3.0.2          gridExtra_0.9.1     gtable_0.1.2
[11] labeling_0.2        lme4_1.1-5          lubridate_1.3.3     MASS_7.3-30         memoise_0.1
[16] mgcv_1.7-28         minqa_1.2.3         multcomp_1.3-2      munsell_0.4.2       mvtnorm_0.9-9997
[21] nlme_3.1-115        permute_0.8-3       plyr_1.8.1          proto_0.3-10        RColorBrewer_1.0-5
[26] Rcpp_0.11.1         RcppEigen_0.3.2.1.1 reshape_0.8.4       reshape2_1.2.2      RODBC_1.3-10
[31] sandwich_2.3-0      scales_0.2.3        seqinr_3.0-9        signal_0.7-3        splines_3.0.2
[36] stats4_3.0.2        stringr_0.6.2       survival_2.37-7     TH.data_1.0-3       tools_3.0.2
[41] vegan_2.1-41        watervogels_0.5-51  xtable_1.7-3        zoo_1.7-11


Best regards,

Thierry


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
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx at inbo.be
www.inbo.be

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


* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.



More information about the R-devel mailing list