fMaker: Create formulas from strings to be used in linear models

Description Usage Arguments Value See Also Examples

Description

This function takes a string and a linear model and either adds the predictor to the model, or removes it.

Usage

1
fMaker(pred, fitCurrent, add = T)

Arguments

pred

the predictor to be added or removed from the current model

fitCurrent

the current model to be updated

add

by default adds the predictor to to the model. add=F removes the predictor from the model

Value

the updated model of type "lm"

See Also

pStepwise

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#Using the leafshape data set from the DAAG package

#Adding a predictor to a linear model
data(leafshape)
attach(leafshape)
currentModel <- lm(bladelen~bladewid + latitude, data = leafshape)
newModel <- fMaker("petiole", currentModel)
newModel$call
#lm(formula = bladelen ~ bladewid + latitude + petiole, data = leafshape)

#Removing a predictor from a linear model
currentModel <- lm(bladelen~bladewid + latitude, data = leafshape)
newModel <- fMaker("latitude", currentModel, add = FALSE)
newModel$call
#lm(formula = bladelen ~ bladewid, data = leafshape)

c-langille/pStepwise documentation built on May 13, 2019, 9:55 a.m.