dummy.coef
Extract Original Coefficients from a Linear Model

Description

Extracts coefficients in terms of the original dummy variable coding of factors for linear models.

Usage

dummy.coef(object, ...)
## S3 method for class 'lm':
dummy.coef(object, use.na = FALSE, ...)
## S3 method for class 'aovlist':
dummy.coef(object, use.na = FALSE, ...)

## S3 method for class 'dummy_coef': print(x, ..., title) ## S3 method for class 'dummy_coef_list': print(x, ...)

Arguments

object a lm or aovlist object.
use.na a logical value that specifies if 0-valued coefficients should be replaced with NAs.
... other arguments passed in to or returned from functions or methods.
x a dummy_coef or dummy_coef_list object.
title a character string that represents the title. If you do not set a value, the default title is "Full coefficients are".

Details

The coefficients returned by coefficients(object) for factor terms in an lm object are coefficients for the contrast variables derived for those factors. By default, these are helmert contrasts for unordered factors and polynomial for ordered. For a main effect term, there are typically K - 1 coefficients for a K level factor.
dummy.coef returns K coefficients for a K level factor, and these coefficients will satisfy the constraints implied by the choice of contrasts. For example, if you use the default or the "contr.sum" contrast functions to code a K-level factor, K coefficients are returned by dummy.coef for this term, and if there was an intercept in the model, they will sum to 0. Similarly K . L coefficients are returned for an interaction term between a K level and a L level factor, with the appropriate constraints honored. Coefficients for numeric variables and matrices are returned as well, but these are the same as those in the object, unless they are crossed with factor terms.
Value
dummy.coef returns an object of class "dummy_coef" for dummy.coef.lm or "dummy_coef_list" for dummy.coef.aovlist along with a list of coefficient vectors that contain an element for each term in the model.
print.* returns the input argument x invisibly.
See Also
C, coef, contrasts, lm.object, Methods, model.matrix, print.default
Examples
data(catalyst, package = "Sdatasets")
myfit <- lm(Yield ~ Temp + Cat + Temp:Cat, data = catalyst) 
dummy.coef(myfit)  

myfit.aovlist <- aov(Yield ~ Error(Temp) + Cat + Temp:Cat, data = catalyst) dummy.coef(myfit.aovlist) dummy.coef(myfit.aovlist, use.na = TRUE)

Package stats version 6.0.0-69
Package Index