"myags"<- function(formula, id, weights = NULL, cor.met = NULL, family, alpfun = NULL, scalefun = LZ.scalefun, wcorigen = identni, tol = 0.0001, contrasts = NULL, corstr = c("independence", "exchangeable", "ar1", "unstructured"), maxiter = 25) { ## myags same as yags, except ## replace yags.pmat.fit with ## myags.pmat.fit prog.error <- NULL call <- match.call() m <- match.call(expand = F) m$contrasts <- m$tol <- m$wcorigen <- m$scalefun <- m$alpfun <- m$ family <- m$cor.met <- m$id <- m$corstr <- m$maxiter <- NULL m[[1]] <- as.name("model.frame") m <- eval(m, sys.parent()) Terms <- attr(m, "terms") y <- as.matrix(model.extract(m, response)) # 1.5.1.1 B : add weight-processing specifically for binomial matrices # as in glm() if(is.null(weights)) weights <- rep(1, nrow(y)) else if(length(weights) != nrow(y)) stop("lengths of y and weights incompatible") if(ncol(y) == 2) { n <- apply(y, 1, sum) y <- y[, 1, drop = F]/n weights <- n/weights } else weights <- 1/weights x <- model.matrix(Terms, m, contrasts) Y <- load.clustered.outcome(y, id) X <- load.clustered.design(x, id) if(is.null(alpfun) & length(corstr) > 1) { warning("no alpfun provided and corstr has several elements; corstr[1] used" ) corstr <- corstr[1] } if(!is.null(alpfun) & length(corstr) == 1) warning("both alpfun and corstr provided; corstr will be ignored" ) else if(corstr[1] == "exchangeable" & is.null(alpfun)) { alpfun <- LZ.exchalp wcorigen <- excoriput } else if(corstr[1] == "ar1" & is.null(alpfun)) { if(is.null(cor.met)) stop("must supply times (cor.met) with ar1") alpfun <- prop.ar1alp wcorigen <- ar1.coriput } else if(corstr[1] == "unstructured" & is.null(alpfun)) { if(is.null(cor.met)) stop("must supply times (cor.met) with unstructured") alpfun <- prop.unstruc.alp wcorigen <- unstr.coriput } else if(corstr[1] == "independence" & is.null(alpfun)) { alpfun <- function(a, b, c, d, p) NULL wcorigen <- identni } ans <- myags.pmat.fit(X, Y, id, weights, cor.met, family, alpfun, scalefun, wcorigen, tol, maxiter, prog.error) ans$call <- call class(ans) <- c("yags", "glm", "lm") ans }