Learn R Programming

linear.tools (version 1.3.0)

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

Description

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

Usage

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.

Value

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

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.

Examples

Run this code

# 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')

Run the code above in your browser using DataLab