kCoef: Nicely Formatted Model Coefficient Output

Description Usage Arguments Details Value Note Examples

View source: R/misc.R

Description

A customized coefficient function that assigns better row names to the coefficient matrix returned by coef() for a model fit. Also includes some arguments for parsing of variable names.

Usage

1
2
kCoef(fit, remove_underscore = TRUE, remove_dollar = TRUE,
  swap_periods = TRUE)

Arguments

fit

the model fit we wish to generate coefficients from.

remove_underscore

remove underscores (and all elements after) in a variable?

remove_dollar

remove all elements before and including a $ in a variable name?

swap_periods

swap periods with spaces?

Details

NOTE:

Models with interaction effects are currently not handled.

Value

a matrix of coefficients with nicely formatted names.

Note

The names given assume default contrasts in your model fit; ie, the default is contr.treatment, where each level of a factor is compared to a reference.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## How the remove_underscore and remove_dollar arguments act:
## An example:
##                     kDat$variable_other_stuff
## remove_underscore:  +++++++++++++------------
## remove_dollar:      -----++++++++++++++++++++

x <- rnorm(100); y <- x * runif(100)
z <- as.factor( rep( c("apple", "banana", "cherry", "date"), each=25 ) )
myFit <- lm( y ~ x + z )

## compare the output of these two: which do you prefer?
coef( summary( myFit ) )
kCoef( myFit )

Kmisc documentation built on May 29, 2017, 1:43 p.m.

Related to kCoef in Kmisc...