scaleB: Standardize coefficients

Description Usage Arguments Details Value Author(s) Examples

View source: R/scaleB.R

Description

Generic function for obtaining scaled coefficients

Usage

1
scaleB(object, scale.response = F)

Arguments

object

an object resulting from glm, lm, or lda

scale.response

should the response variable be scaled as well? (Usually not for glm or lda).

Details

Given an object of class lm, glm, or lda, this function will first standardize the variables, then run the model again. The resulting coefficients will be standardized betas.

Value

an object of the same class as the one outputted

Author(s)

Dustin Fife

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
		#### create random data with different means and variances
d = data.frame(matrix(rnorm(5*50, c(10,5,14,100, 33), c(3,5,4,3,5)), nrow=50, byrow=TRUE))
names(d) = LETTERS[1:5]
g = lm(C~B + A + D + E, data=d)
scaleB(g, TRUE)
##### make a logistic
d$A = as.factor(as.numeric(cut(d$A, 2, labels=c(1,0))	))
object = glm(A~B + C + D + E, data=d, family=binomial)
scaleB(object)
##### LDA
object = lda(A~B + C + D + E, data=d, family=binomial)
scaleB(object)

fifer documentation built on May 30, 2017, 7:40 a.m.

Related to scaleB in fifer...