R/cmulti.R

Defines functions cmulti

Documented in cmulti

cmulti <-
function(formula, data, type=c("rem", "mix", "dis", "fmix"),
inits=NULL, method="Nelder-Mead", ...)
{
    if (missing(data))
        data <- environment(formula)
    rv <- dFormula(formula, data, drop=FALSE)
    if (is.null(rv$D))
        stop("sampling design matrix not provided in LHS")
    if (!is.null(rv$Q) || !is.null(rv$Z))
        stop("RHS must have 1 part only")
    rv <- rv[!(names(rv) %in% c("Z", "Q"))]
    NAM <- colnames(rv$X)
    if (ncol(rv$X) < 2)
        rv$X <- NULL
    or <- cmulti.fit(rv$Y, rv$D, rv$X, type=type,
        inits=unname(inits), method=method, ...)
    rv <- c(rv, or)
    rv$call <- match.call()
    rv$type <- type
    rv$nobs <- sum(rowSums(rv$Y, na.rm=TRUE) > 0)
    rv$df.residual <- rv$nobs - length(rv$coefficients)
    names(rv$coefficients) <- switch(type,
        "dis" = paste("log.tau", NAM, sep="_"),
        "mix" = c("log.phi", paste("logit.c", NAM, sep="_")),
        "rem" = paste("log.phi", NAM, sep="_"),
        "fmix" = c(paste("log.phi", NAM, sep="_"), "logit.c"))
    class(rv) <- c("cmulti")
    rv
}

Try the detect package in your browser

Any scripts or data that you put into this service are public.

detect documentation built on March 31, 2023, 10:02 p.m.