Skip to content

Commit

Permalink
cleaning up and retesting issue #50
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Jun 28, 2013
1 parent f7dadc1 commit 6bf771a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 74 deletions.
21 changes: 11 additions & 10 deletions R/lmer.R
Expand Up @@ -116,10 +116,13 @@ lmer <- function(formula, data=NULL, REML = TRUE,
mc$control <- control ## update for back-compatibility kluge
if (!is.null(list(...)[["family"]])) {
warning("calling lmer with 'family' is deprecated; please use glmer() instead")
mc[[1]] <- as.name("glmer")
mc[[1]] <- quote(lme4::glmer)
return(eval(mc,parent.frame(1L)))
}
mc[[1]] <- as.name("lFormula")

## https://github.com/lme4/lme4/issues/50
## parse data and formula
mc[[1]] <- quote(lme4::lFormula)
lmod <- eval(mc, parent.frame(1L)) ## parse data and formula
mcout$formula <- lmod$formula
lmod$formula <- NULL
Expand Down Expand Up @@ -240,17 +243,15 @@ glmer <- function(formula, data=NULL, family = gaussian,
## redirect to lmer (with warning)
warning("calling glmer() with family=gaussian (identity link) as a shortcut to lmer() is deprecated;",
" please call lmer() directly")
mc[[1]] <- as.name("lmer")
mc[[1]] <- quote(lme4::lmer)
mc["family"] <- NULL # to avoid an infinite loop
return(eval(mc, parent.frame()))
}
mc[[1]] <- as.name("glFormula")
#m <- match(c("formula", "data", "family", "sparseX", "subset", "weights",
# "na.action", "offset", "contrasts", "mustart", "etastart"),
# names(mc), 0)
#mc <- mc[c(1, m)]

glmod <- eval(mc, parent.frame(1L)) # parse the formula and data

## see https://github.com/lme4/lme4/issues/50
## parse the formula and data
mc[[1]] <- quote(lme4::glFormula)
glmod <- eval(mc, parent.frame(1L))
mcout$formula <- attr(glmod, "formula")
#glmod$formula <- NULL # not necessary now that formula is returned from glFormula as an attribute

Expand Down
12 changes: 6 additions & 6 deletions R/modular.R
Expand Up @@ -92,7 +92,7 @@ lFormula <- function(formula, data=NULL, REML = TRUE,
do.call("checkArgs",c(list("lmer"),l...))
if (!is.null(list(...)[["family"]])) {
## lmer(...,family=...); warning issued within checkArgs
mc[[1]] <- as.name("glFormula")
mc[[1]] <- quote(lme4::glFormula)
if (missing(control)) mc[["control"]] <- glmerControl()
return(eval(mc, parent.frame()))
}
Expand Down Expand Up @@ -129,7 +129,7 @@ lFormula <- function(formula, data=NULL, REML = TRUE,
cstr <- "check.numobs.vs.rankZ"
if (doCheck(cc <- control[[cstr]]) && ## not NULL or "ignore"
!(grepl("Small",cc) && prod(dim(reTrms$Zt))>1e6) ## not "*Small" and large Z mat
&& (nrow(fr) <= (rankZ <- rankMatrix(reTrms$Zt))))
&& (nrow(fr) <= (rankZ <- Matrix::rankMatrix(reTrms$Zt))))
{
wstr <- "number of observations <= rank(Z) ; variance-covariance matrix is likely to be unidentifiable"
switch(cc,warningSmall=,warning=warning(wstr),stopSmall=,stop=stop(wstr),
Expand All @@ -144,7 +144,7 @@ lFormula <- function(formula, data=NULL, REML = TRUE,
attr(attr(fr,"terms"),"predvars.fixed") <- attr(attr(fixedfr,"terms"),"predvars")
X <- model.matrix(fixedform, fr, contrasts)#, sparse = FALSE, row.names = FALSE) ## sparseX not yet
p <- ncol(X)
if ((rankX <- rankMatrix(X)) < p)
if ((rankX <- Matrix::rankMatrix(X)) < p)
stop(gettextf("rank of X = %d < ncol(X) = %d", rankX, p))
return(list(fr = fr, X = X, reTrms = reTrms, REML = REML, formula = formula))
}
Expand Down Expand Up @@ -261,7 +261,7 @@ glFormula <- function(formula, data=NULL, family = gaussian,
family <- get(family, mode = "function", envir = parent.frame(2))
if( is.function(family)) family <- family()
if (isTRUE(all.equal(family, gaussian()))) {
mc[[1]] <- as.name("lFormula")
mc[[1]] <- quote(lme4::lFormula)
mc["family"] <- NULL # to avoid an infinite loop
return(eval(mc, parent.frame()))
}
Expand Down Expand Up @@ -299,7 +299,7 @@ glFormula <- function(formula, data=NULL, family = gaussian,
## useSc is not defined yet/not defined properly?
if (doCheck(cc <- control[[cstr]]) && ## not NULL or "ignore"
!(grepl(cc,"Small") && prod(dim(reTrms$Zt))>1e6) ## not "*Small" and large Z mat
&& (nrow(fr) < (rankZ <- rankMatrix(reTrms$Zt)))) ## test
&& (nrow(fr) < (rankZ <- Matrix::rankMatrix(reTrms$Zt)))) ## test
{
wstr <- "number of observations<rank(Z); variance-covariance matrix will be unidentifiable"
switch(cc,warningSmall=,warning=warning(wstr),stopSmall=,stop=stop(wstr),
Expand All @@ -315,7 +315,7 @@ glFormula <- function(formula, data=NULL, family = gaussian,
X <- model.matrix(form, fr, contrasts)#, sparse = FALSE, row.names = FALSE) ## sparseX not yet
p <- ncol(X)

if ((rankX <- rankMatrix(X)) < p)
if ((rankX <- Matrix::rankMatrix(X)) < p)
stop(gettextf("rank of X = %d < ncol(X) = %d", rankX, p))

out <- list(fr = fr, X = X, reTrms = reTrms, family = family)
Expand Down
110 changes: 55 additions & 55 deletions misc/pkgtests/lme4_compat_report.html
Expand Up @@ -22,7 +22,7 @@ <h1 > lme4: downstream package report</h1>

<p class='character'>lme4 version: 0.99999911.5</p>

<p class='character'>Test date: Thu Jun 27 23:10:54 2013</p>
<p class='character'>Test date: Fri Jun 28 14:28:04 2013</p>

<h2 > Notes</h2>

Expand All @@ -48,9 +48,9 @@ <h2 > Notes</h2>
<td class=cellinside> 0</td></tr>

<tr><td class=firstcolumn>error_examples</td>
<td class=cellinside>11</td>
<td class=cellinside>10</td>
<td class=cellinside> 0</td>
<td class=cellinside> 5</td></tr>
<td class=cellinside> 4</td></tr>

<tr><td class=firstcolumn>error_install</td>
<td class=cellinside> 6</td>
Expand All @@ -63,9 +63,9 @@ <h2 > Notes</h2>
<td class=cellinside> 1</td></tr>

<tr><td class=firstcolumn>OK</td>
<td class=cellinside>15</td>
<td class=cellinside>16</td>
<td class=cellinside> 4</td>
<td class=cellinside>33</td></tr>
<td class=cellinside>34</td></tr>

</tbody>
</table>
Expand Down Expand Up @@ -150,30 +150,6 @@ <h2 > Notes</h2>
<td class=cellinside>proximal: set control=lmerControl(check.numlev.gtr.1='ignore') in federer.diag
</td></tr>

<tr>
<td class=firstcolumn>5
</td>
<td class=cellinside>aod
</td>
<td class=cellinside><font style="color:green">Suggests</font>
</td>
<td class=cellinside>CRAN
</td>
<td class=cellinside>1.3
</td>
<td class=cellinside>Renaud Lancelot &lt;renaud.lancelot@cirad.fr&gt
</td>
<td class=cellinside><font style="color:red">error_examples</font>
</td>
<td class=cellinside>Error in eval(expr, envir, enclos) : could not find function "glFormula"<br>Calls: iccbin -> <Anonymous> -> eval -> eval<br>Execution halted
</td>
<td class=cellinside>BMB
</td>
<td class=cellinside> TRUE
</td>
<td class=cellinside>fails because it only Suggests: lme4 then calls lme4::glmer -- see https://github.com/lme4/lme4/issues/50. Deprecated by authors in favour of aods3??
</td></tr>

<tr>
<td class=firstcolumn>7
</td>
Expand Down Expand Up @@ -366,30 +342,6 @@ <h2 > Notes</h2>
<td class=cellinside>
</td></tr>

<tr>
<td class=firstcolumn>51
</td>
<td class=cellinside>mlmRev
</td>
<td class=cellinside><font style="color:blue">Depends</font>
</td>
<td class=cellinside>Rforge
</td>
<td class=cellinside>1.0-3
</td>
<td class=cellinside>&lt;lme4-authors@R-forge.wu-wien.ac.at&gt
</td>
<td class=cellinside><font style="color:red">error_examples</font>
</td>
<td class=cellinside> Cholmod error 'out of memory' at file ../Core/cholmod_memory.c, line 147<br>Calls: lmer ... svd -> as.matrix -> as.matrix.Matrix -> as -> asMethod<br>Execution halted
</td>
<td class=cellinside>SW
</td>
<td class=cellinside>FALSE
</td>
<td class=cellinside>very slow/memory-hungry; will skip. Should see whether this is equally bad in lme4.0, or is lme4 1.0 greedier/slower???
</td></tr>

<tr>
<td class=firstcolumn>58
</td>
Expand Down Expand Up @@ -847,6 +799,30 @@ <h2 > Notes</h2>
<td class=cellinside>
</td></tr>

<tr>
<td class=firstcolumn>5
</td>
<td class=cellinside>aod
</td>
<td class=cellinside><font style="color:green">Suggests</font>
</td>
<td class=cellinside>CRAN
</td>
<td class=cellinside>1.3
</td>
<td class=cellinside>Renaud Lancelot &lt;renaud.lancelot@cirad.fr&gt
</td>
<td class=cellinside><font style="color:blue">OK</font>
</td>
<td class=cellinside>
</td>
<td class=cellinside>BMB
</td>
<td class=cellinside> TRUE
</td>
<td class=cellinside>
</td></tr>

<tr>
<td class=firstcolumn>6
</td>
Expand Down Expand Up @@ -1109,7 +1085,7 @@ <h2 > Notes</h2>
</td>
<td class=cellinside> TRUE
</td>
<td class=cellinside>fails because it only Imports: lme4 then calls lme4::glmer -- see https://github.com/lme4/lme4/issues/50. Passes with hacked local version that sets Depends: instead of Imports:.
<td class=cellinside>
</td></tr>

<tr>
Expand Down Expand Up @@ -1568,6 +1544,30 @@ <h2 > Notes</h2>
<td class=cellinside>
</td></tr>

<tr>
<td class=firstcolumn>51
</td>
<td class=cellinside>mlmRev
</td>
<td class=cellinside><font style="color:blue">Depends</font>
</td>
<td class=cellinside>Rforge
</td>
<td class=cellinside>1.0-3
</td>
<td class=cellinside>&lt;lme4-authors@R-forge.wu-wien.ac.at&gt
</td>
<td class=cellinside><font style="color:blue">OK</font>
</td>
<td class=cellinside>
</td>
<td class=cellinside>SW
</td>
<td class=cellinside>FALSE
</td>
<td class=cellinside>very slow/memory-hungry; will skip. Should see whether this is equally bad in lme4.0, or is lme4 1.0 greedier/slower???
</td></tr>

<tr>
<td class=firstcolumn>52
</td>
Expand Down Expand Up @@ -2031,7 +2031,7 @@ <h2 > Notes</h2>

<hr size=1>
<font size=-1>
Generated on: <i>Thu Jun 27 23:10:54 2013</i> - <b>R2HTML</b>
Generated on: <i>Fri Jun 28 14:28:04 2013</i> - <b>R2HTML</b>
<hr size=1>
</body>
</html>
4 changes: 2 additions & 2 deletions misc/pkgtests/lme4_notes.csv
@@ -1,14 +1,14 @@
pkgname,lme4_contact,contacted,notes
agridat,BMB,TRUE,"proximal: set control=lmerControl(check.numlev.gtr.1='ignore') in federer.diag"
AICcmodavg,BMB,TRUE,
aod,BMB,TRUE,"fails because it only Suggests: lme4 then calls lme4::glmer -- see https://github.com/lme4/lme4/issues/50. Deprecated by authors in favour of aods3??"
aod,BMB,TRUE
arm,SW,NA,"proximal problem is nonexistence of display.merMod, but we know sim() will need lots of modification"
boss,BMB,TRUE,"fairly simple fixes"
BradleyTerry2,BMB,TRUE,
car,BMB,TRUE,
clusterPower,BMB,TRUE,"fairly simple fixes"
cplm,BMB,TRUE,NA
EquiNorm,BMB,TRUE,"fails because it only Imports: lme4 then calls lme4::glmer -- see https://github.com/lme4/lme4/issues/50. Passes with hacked local version that sets Depends: instead of Imports:."
EquiNorm,BMB,TRUE
gamm4,MM,FALSE,NA
GRRGI,MM,FALSE,NA
influence.ME,MM,FALSE,NA
Expand Down
4 changes: 3 additions & 1 deletion misc/pkgtests/pkgdepfuns.R
Expand Up @@ -327,7 +327,9 @@ doPkgDeptests <- function(pkg="lme4",
if (length(pkgdepMiss)>0)
install.packages(pkgdepMiss,lib=libdir, type="source")
if (!is.null(pkg_tarball)) {
tb0time <- max(file.info(pkg_tarball)$mtime)
tb0times <- file.info(pkg_tarball)$mtime
pkg_tarball <- pkg_tarball[which.max(tb0times)]
tb0time <- max(tb0times)
pkg_inst <- file.exists(file.path(libdir,pkg))
pkgtime <- if (!pkg_inst) -Inf else {
file.info(file.path(libdir,pkg))$mtime
Expand Down
2 changes: 2 additions & 0 deletions tests/glmerWarn.R
Expand Up @@ -5,6 +5,8 @@ m3 <- suppressWarnings(glmer(Reaction ~ Days + (Days|Subject), sleepstudy))
m4 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
m5 <- suppressWarnings(glmer(Reaction ~ Days + (Days|Subject), sleepstudy, family=gaussian))
expect_equal(fixef(m3),fixef(m5))
## hack call -- comes out unimportantly different
m4@call[[1]] <- quote(lme4::lmer)
expect_equal(m3,m4)
expect_equal(m3,m5)

Expand Down

0 comments on commit 6bf771a

Please sign in to comment.