SCM

SCM Repository

[matrix] Diff of /pkg/R/lmer.R
ViewVC logotype

Diff of /pkg/R/lmer.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 980, Tue Oct 11 14:11:44 2005 UTC revision 981, Tue Oct 11 14:12:19 2005 UTC
# Line 1105  Line 1105 
1105      cv$analyticGradient <- FALSE      cv$analyticGradient <- FALSE
1106      cv$msMaxIter <- as.integer(200)      cv$msMaxIter <- as.integer(200)
1107      if (is.null(cv$msVerbose)) cv$msVerbose <- as.integer(1)      if (is.null(cv$msVerbose)) cv$msVerbose <- as.integer(1)
1108  ## FIXME: Need to evaluate the model frame first and then fit the glm  
1109  ##  in that frame.  Otherwise missing values in the grouping factors      ## Must evaluate the model frame first and then fit the glm using
1110  ##  cause problems.      ## that frame.  Otherwise missing values in the grouping factors
1111        ## cause inconsistent numbers of observations.
1112    
1113      ## evaluate glm.fit, a generalized linear fit of fixed effects only      ## evaluate glm.fit, a generalized linear fit of fixed effects only
1114      mf <- match.call()      mf <- match.call()
1115      m <- match(c("family", "data", "subset", "weights",      m <- match(c("family", "data", "subset", "weights",
1116                   "na.action", "offset"), names(mf), 0)                   "na.action", "offset"), names(mf), 0)
1117      mf <- mf[c(1, m)]      mf <- fe <- mf[c(1, m)]
1118      frame.form <- subbars(formula) # substitute `+' for `|'      frame.form <- subbars(formula) # substitute `+' for `|'
1119      fixed.form <- nobars(formula)  # remove any terms with `|'      fixed.form <- nobars(formula)  # remove any terms with `|'
1120      if (inherits(fixed.form, "name")) # RHS is empty - use a constant      if (inherits(fixed.form, "name")) # RHS is empty - use a constant
1121          fixed.form <- substitute(foo ~ 1, list(foo = fixed.form))          fixed.form <- substitute(foo ~ 1, list(foo = fixed.form))
1122      environment(fixed.form) <- environment(frame.form) <- environment(formula)      environment(fixed.form) <- environment(frame.form) <- environment(formula)
1123      mf$formula <- fixed.form  
1124      mf$x <- mf$model <- mf$y <- TRUE      ## evaluate a model frame for fixed and random effects
1125      mf[[1]] <- as.name("glm")      mf$formula <- frame.form
1126      glm.fit <- eval(mf, parent.frame())      mf$family <- NULL
1127        mf$drop.unused.levels <- TRUE
1128        mf[[1]] <- as.name("model.frame")
1129        frm <- eval(mf, parent.frame())
1130    
1131        ## fit a glm model to the fixed formula
1132        fe$formula <- fixed.form
1133        fe$data <- frm
1134        fe$x <- fe$model <- fe$y <- TRUE
1135        fe[[1]] <- as.name("glm")
1136        glm.fit <- eval(fe, parent.frame())
1137      x <- glm.fit$x      x <- glm.fit$x
1138      y <- as.double(glm.fit$y)      y <- as.double(glm.fit$y)
1139      family <- glm.fit$family      family <- glm.fit$family
1140    
1141      ## check for a linear mixed model      ## check for a linear mixed model
1142      lmm <- family$family == "gaussian" && family$link == "identity"      lmm <- family$family == "gaussian" && family$link == "identity"
1143      if (lmm) { # linear mixed model      if (lmm) { # linear mixed model
# Line 1147  Line 1160 
1160          }          }
1161      }      }
1162    
     ## evaluate a model frame for fixed and random effects  
     mf$formula <- frame.form  
     mf$x <- mf$model <- mf$y <- mf$family <- NULL  
     mf$drop.unused.levels <- TRUE  
     mf[[1]] <- as.name("model.frame")  
     frm <- eval(mf, parent.frame())  
   
1163      ## grouping factors and model matrices for random effects      ## grouping factors and model matrices for random effects
1164      bars <- findbars(formula[[3]])      bars <- findbars(formula[[3]])
1165      random <-      random <-

Legend:
Removed from v.980  
changed lines
  Added in v.981

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge