get_model_pair: get a list of model vars with their corresponding coeff vars...

Description Usage Arguments Details Value Examples

View source: R/linear.tools.R

Description

get a list of model vars with their corresponding coeff vars or raw vars.

Usage

1
get_model_pair(model, data = NULL, pair_with = c("coeff", "raw"))

Arguments

model

a lm or glm output

data

NULL (default) or data.frame, a new dataset to evaluate the categorical variables. If NULL, then use the data used in model itself.

pair_with

either 'raw' (default) or 'coeff', to decide the elements of list are raw vars or coeff vars. See get_x for the meaning of model var, coeff var and raw var.

Details

get a list of model vars with their corresponding coeff vars or raw vars. See get_x for the meaning of model var, coeff var and raw var.

Value

a list with names as model vars and elements as their corresponding coeff/raw vars

Examples

1
2
3
4
5
6
7
8
# return coeff
get_model_pair(model = price~  I(carat^2) + cut  + carat*table, data = ggplot2::diamonds)
# return raw vars
get_model_pair(price~  I(carat^2) + cut  + carat*table, data= ggplot2::diamonds, pair_with = 'raw')

# correctly deal with irregular formulas
model_dirty = lm(price~  I(carat^   2) + cut  - carat:table - cut ,ggplot2::diamonds)
get_model_pair(model_dirty,pair_with = 'raw')

linear.tools documentation built on May 2, 2019, 3:17 a.m.