{"action":"created","issue":{"url":"https://api.github.com/repos/lme4/lme4/issues/369","repository_url":"https://api.github.com/repos/lme4/lme4","labels_url":"https://api.github.com/repos/lme4/lme4/issues/369/labels{/name}","comments_url":"https://api.github.com/repos/lme4/lme4/issues/369/comments","events_url":"https://api.github.com/repos/lme4/lme4/issues/369/events","html_url":"https://github.com/lme4/lme4/issues/369","id":140281679,"number":369,"title":"glmer error when using with lapply()","user":{"login":"atyre2","id":2787883,"avatar_url":"https://avatars.githubusercontent.com/u/2787883?v=3","gravatar_id":"","url":"https://api.github.com/users/atyre2","html_url":"https://github.com/atyre2","followers_url":"https://api.github.com/users/atyre2/followers","following_url":"https://api.github.com/users/atyre2/following{/other_user}","gists_url":"https://api.github.com/users/atyre2/gists{/gist_id}","starred_url":"https://api.github.com/users/atyre2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atyre2/subscriptions","organizations_url":"https://api.github.com/users/atyre2/orgs","repos_url":"https://api.github.com/users/atyre2/repos","events_url":"https://api.github.com/users/atyre2/events{/privacy}","received_events_url":"https://api.github.com/users/atyre2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-11T20:21:01Z","updated_at":"2016-03-11T21:18:03Z","closed_at":null,"body":"The error arises when running glmer inside lapply().\r\n\r\n    library(lme4)\r\n\r\n    ## Loading required package: Matrix\r\n\r\n    cbpp$obs <- 1:nrow(cbpp)\r\n    (gm2 <- glmer(cbind(incidence, size - incidence) ~ period +\r\n        (1 | herd) +  (1|obs),\r\n                  family = binomial, data = cbpp))\r\n\r\n    ## Generalized linear mixed model fit by maximum likelihood (Laplace\r\n    ##   Approximation) [glmerMod]\r\n    ##  Family: binomial  ( logit )\r\n    ## Formula: cbind(incidence, size - incidence) ~ period + (1 | herd) + (1 |  \r\n    ##     obs)\r\n    ##    Data: cbpp\r\n    ##      AIC      BIC   logLik deviance df.resid \r\n    ## 186.6383 198.7904 -87.3192 174.6383       50 \r\n    ## Random effects:\r\n    ##  Groups Name        Std.Dev.\r\n    ##  obs    (Intercept) 0.8911  \r\n    ##  herd   (Intercept) 0.1840  \r\n    ## Number of obs: 56, groups:  obs, 56; herd, 15\r\n    ## Fixed Effects:\r\n    ## (Intercept)      period2      period3      period4  \r\n    ##      -1.500       -1.226       -1.329       -1.866\r\n\r\n    listOfFormulas <- list(\r\n      cbind(incidence, size - incidence) ~ 1 +\r\n        (1 | herd) +  (1|obs),\r\n      cbind(incidence, size - incidence) ~ period +\r\n        (1 | herd) +  (1|obs)\r\n    )\r\n    lapply(listOfFormulas,glmer,family=binomial,data=cbpp)\r\n\r\n    ## Error: 'data' not found, and some variables missing from formula environment\r\n\r\n    sessionInfo()\r\n\r\n    ## R version 3.2.3 (2015-12-10)\r\n    ## Platform: x86_64-w64-mingw32/x64 (64-bit)\r\n    ## Running under: Windows 7 x64 (build 7601) Service Pack 1\r\n    ## \r\n    ## locale:\r\n    ## [1] LC_COLLATE=English_United States.1252 \r\n    ## [2] LC_CTYPE=English_United States.1252   \r\n    ## [3] LC_MONETARY=English_United States.1252\r\n    ## [4] LC_NUMERIC=C                          \r\n    ## [5] LC_TIME=English_United States.1252    \r\n    ## \r\n    ## attached base packages:\r\n    ## [1] stats     graphics  grDevices utils     datasets  methods   base     \r\n    ## \r\n    ## other attached packages:\r\n    ## [1] lme4_1.1-11  Matrix_1.2-3\r\n    ## \r\n    ## loaded via a namespace (and not attached):\r\n    ##  [1] Rcpp_0.12.2     lattice_0.20-33 digest_0.6.8    MASS_7.3-45    \r\n    ##  [5] grid_3.2.3      nlme_3.1-125    formatR_1.2.1   magrittr_1.5   \r\n    ##  [9] evaluate_0.8    stringi_1.0-1   minqa_1.2.4     nloptr_1.0.4   \r\n    ## [13] rmarkdown_0.9.2 splines_3.2.3   tools_3.2.3     stringr_1.0.0  \r\n    ## [17] yaml_2.1.13     htmltools_0.3   knitr_1.11\r\n\r\nThe error did not occur when using `lme4_1.1-10`. Creating an anonymous\r\nfunction works.\r\n\r\n    lapply(listOfFormulas,\r\n           function(mm) glmer(mm, ,family=binomial,data=cbpp))\r\n\r\n    ## [[1]]\r\n    ## Generalized linear mixed model fit by maximum likelihood (Laplace\r\n    ##   Approximation) [glmerMod]\r\n    ##  Family: binomial  ( logit )\r\n    ## Formula: cbind(incidence, size - incidence) ~ 1 + (1 | herd) + (1 | obs)\r\n    ##    Data: cbpp\r\n    ##      AIC      BIC   logLik deviance df.resid \r\n    ## 194.4654 200.5414 -94.2327 188.4654       53 \r\n    ## Random effects:\r\n    ##  Groups Name        Std.Dev. \r\n    ##  obs    (Intercept) 1.160e+00\r\n    ##  herd   (Intercept) 2.905e-05\r\n    ## Number of obs: 56, groups:  obs, 56; herd, 15\r\n    ## Fixed Effects:\r\n    ## (Intercept)  \r\n    ##      -2.526  \r\n    ## \r\n    ## [[2]]\r\n    ## Generalized linear mixed model fit by maximum likelihood (Laplace\r\n    ##   Approximation) [glmerMod]\r\n    ##  Family: binomial  ( logit )\r\n    ## Formula: cbind(incidence, size - incidence) ~ period + (1 | herd) + (1 |  \r\n    ##     obs)\r\n    ##    Data: cbpp\r\n    ##      AIC      BIC   logLik deviance df.resid \r\n    ## 186.6383 198.7904 -87.3192 174.6383       50 \r\n    ## Random effects:\r\n    ##  Groups Name        Std.Dev.\r\n    ##  obs    (Intercept) 0.8911  \r\n    ##  herd   (Intercept) 0.1840  \r\n    ## Number of obs: 56, groups:  obs, 56; herd, 15\r\n    ## Fixed Effects:\r\n    ## (Intercept)      period2      period3      period4  \r\n    ##      -1.500       -1.226       -1.329       -1.866\r\n"},"comment":{"url":"https://api.github.com/repos/lme4/lme4/issues/comments/195558114","html_url":"https://github.com/lme4/lme4/issues/369#issuecomment-195558114","issue_url":"https://api.github.com/repos/lme4/lme4/issues/369","id":195558114,"user":{"login":"bbolker","id":78918,"avatar_url":"https://avatars.githubusercontent.com/u/78918?v=3","gravatar_id":"","url":"https://api.github.com/users/bbolker","html_url":"https://github.com/bbolker","followers_url":"https://api.github.com/users/bbolker/followers","following_url":"https://api.github.com/users/bbolker/following{/other_user}","gists_url":"https://api.github.com/users/bbolker/gists{/gist_id}","starred_url":"https://api.github.com/users/bbolker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbolker/subscriptions","organizations_url":"https://api.github.com/users/bbolker/orgs","repos_url":"https://api.github.com/users/bbolker/repos","events_url":"https://api.github.com/users/bbolker/events{/privacy}","received_events_url":"https://api.github.com/users/bbolker/received_events","type":"User","site_admin":false},"created_at":"2016-03-11T21:18:03Z","updated_at":"2016-03-11T21:18:03Z","body":"Sigh.  I have tracked this down to fcde0d14a4503957a6fc0f3bee4166332ae9b119\r\n\r\n```\r\ncommit fcde0d14a4503957a6fc0f3bee4166332ae9b119\r\nAuthor: bbolker <bbolker@gmail.com>\r\nDate:   Sat Nov 14 19:06:42 2015 -0500\r\n\r\n    better missing-data error; lots of glmer.nb updating fixes\r\n```\r\n\r\nwhich was my attempt to do a better job detecting when data couldn't be found.  I will see if I can figure out what's going wrong here, as it's obviously a false positive\r\n"}}