### Eclipse Workspace Patch 1.0 #P pedigreemm Index: R/pedigree.R =================================================================== --- R/pedigree.R (revision 127) +++ R/pedigree.R (working copy) @@ -163,7 +163,8 @@ { mc <- match.call() lmerc <- mc # create a call to lmer - lmerc[[1]] <- as.name("lmer") + l... = list(...) + if (!is.null(l...$family)) lmerc[[1]] <- as.name("glmer") else lmerc[[1]] <- as.name("lmer") lmerc$pedigree <- NULL if (!length(pedigree)) # call lmer instead @@ -172,24 +173,25 @@ stopifnot(is.list(pedigree), # check the pedigree argument length(names(pedigree)) == length(pedigree), all(sapply(pedigree, is, class2 = "pedigree"))) - + lmerc$doFit <- FALSE # call lmer without pedigree and with doFit = FALSE - lmf <- eval(lmerc, parent.frame()) + lmf <- eval(lmerc, parent.frame()) - relfac <- pedigree # copy the pedigree list for relfactor pnms <- names(pedigree) - stopifnot(all(pnms %in% names(lmf$FL$fl))) - asgn <- attr(lmf$FL$fl, "assign") + stopifnot(all(pnms %in% names(lmf$reTrms$flist))) + asgn <- attr(lmf$reTrms$flist, "assign") for (i in seq_along(pedigree)) { - tn <- which(match(pnms[i], names(lmf$FL$fl)) == asgn) + tn <- which(match(pnms[i], names(lmf$reTrms$flist)) == asgn) if (length(tn) > 1) stop("a pedigree factor must be associated with only one r.e. term") - Zt <- lmf$FL$trms[[tn]]$Zt - relfac[[i]] <- relfactor(pedigree[[i]], rownames(Zt)) - lmf$FL$trms[[tn]]$Zt <- lmf$FL$trms[[tn]]$A <- relfac[[i]] %*% Zt + Zt <- lmf$rho$pp$Zt + Zt <- Zt[rownames(Zt) %in% levels(lmf$reTrms$flist[[tn]]), ] + relfac[[i]] <- relfactor(pedigree[[i]], rownames(Zt)) + #lmf$FL$trms[[tn]]$Zt <- lmf$FL$trms[[tn]]$A <- relfac[[i]] %*% Zt + lmf$rho$pp$Zt <- relfac[[i]] %*% Zt } - ans <- do.call(if (!is.null(lmf$glmFit)) lme4:::glmer_finalize else lme4:::lmer_finalize, lmf) + ans <- do.call(if (is(lmf$rho$resp, "lmerResp")) lme4:::lmer_finalize else lme4:::glmer_finalize, lmf) ans <- new("pedigreemm", relfac = relfac, ans) ans@call <- match.call() ans @@ -203,7 +205,8 @@ { mc <- match.call() lmerc <- mc # create a call to lmer - lmerc[[1]] <- as.name("lmer") + l... = list(...) + if (!is.null(l...$family)) lmerc[[1]] <- as.name("glmer") else lmerc[[1]] <- as.name("lmer") lmerc$pre <- NULL if (!length(pre)) # call lmer instead @@ -212,22 +215,23 @@ stopifnot(is.list(pre), # check the pre argument length(names(pre)) == length(pre), all(sapply(pre, is, class2 = "Matrix"))) - - lmerc$doFit <- FALSE # call lmer without pre and with doFit = FALSE - lmf <- eval(lmerc, parent.frame()) - + lmerc$doFit <- FALSE # call lmer without pedigree and with doFit = FALSE + lmf <- eval(lmerc, parent.frame()) + pnms <- names(pre) - stopifnot(all(pnms %in% names(lmf$FL$fl))) - asgn <- attr(lmf$FL$fl, "assign") + stopifnot(all(pnms %in% names(lmf$reTrms$flist))) + asgn <- attr(lmf$reTrms$flist, "assign") for (i in seq_along(pre)) { - tn <- which(match(pnms[i], names(lmf$FL$fl)) == asgn) + tn <- which(match(pnms[i], names(lmf$reTrms$flist)) == asgn) if (length(tn) > 1) stop("a pre factor must be associated with only one r.e. term") - Zt <- lmf$FL$trms[[tn]]$Zt - lmf$FL$trms[[tn]]$Zt <- lmf$FL$trms[[tn]]$A <- pre[[i]] %*% Zt - } - do.call(if (!is.null(lmf$glmFit)) lme4:::glmer_finalize else lme4:::lmer_finalize, lmf) + Zt <- lmf$rho$pp$Zt + Zt <- Zt[rownames(Zt) %in% levels(lmf$reTrms$flist[[tn]]), ] + #lmf$FL$trms[[tn]]$Zt <- lmf$FL$trms[[tn]]$A <- pre[[i]] %*% Zt + lmf$rho$pp$Zt <- pre[[i]] %*% Zt + } + do.call(if (is(lmf$rho$resp, "lmerResp")) lme4:::lmer_finalize else lme4:::glmer_finalize, lmf) } setMethod("ranef", signature(object = "pedigreemm"),