R/attrassign.R

Defines functions attrassigndefault attrassignlm

Documented in attrassigndefault attrassignlm

# These functions are
# Copyright (C) 1998-2024 T.W. Yee, University of Auckland.
# All rights reserved.








attrassignlm <- function(lmobj) {
  attrassign(model.matrix(lmobj), terms(lmobj))
}



attrassigndefault <- function(mmat, tt) {
  if (!inherits(tt, "terms"))
    stop("need terms object")
  aa <- attr(mmat, "assign")
  if (is.null(aa))
    stop("argument is not really a model matrix")
  ll <- attr(tt, "term.labels")
  if (attr(tt, "intercept") > 0)
    ll <- c("(Intercept)", ll)
  aaa <- factor(aa, labels = ll)
  split(order(aa), aaa)
}



if (!isGeneric("attrassign"))
  setGeneric("attrassign", function(object, ...)
             standardGeneric("attrassign"))

setMethod("attrassign", "lm",
         function(object, ...)
         attrassignlm(object, ...))

Try the VGAM package in your browser

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

VGAM documentation built on Sept. 18, 2024, 9:09 a.m.