Description Usage Arguments Details Value References Examples
get contrast of categorical variables in a model
1 2 |
model |
a model, either |
data |
dataframe, to provide new data to evaluate the model. If NULL (default), then we use the default data in the model. |
PRINT |
a boolean, whether to print messages. Default is TRUE. |
return_method |
a boolean, whether to return the method of contrast, rather than the contrast itself. Default is FALSE. |
delete.minus.var |
a boolean. whether to delete x2 in y ~ x1 - x2. Default is TRUE. |
When R put categorical vars in the linear model, R will transform them into set of 'contrast' using certain contrast encoding schedule. See example code and the reference link below for details.
contrasts of the categorical vars in the model, or the contrast method if return_method
is TRUE.
http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | get_contrast(lm(price ~ carat + I(carat^2) + cut:carat +
color,ggplot2::diamonds))
get_contrast(lm(price ~ carat + I(carat^2) + cut:carat +
color,ggplot2::diamonds),return_method = TRUE)
# dirty formulas: all categorical vars are with minus sign
# no categorical vars, thus no contast
get_contrast(lm(price ~ carat + I(carat^2) ,ggplot2::diamonds))
model_dirty = lm(price ~ carat + I(carat^2) - cut:carat - color,
ggplot2::diamonds)
get_contrast(model = model_dirty )
diamond_lm3 = lm(price~ I(cut) + depth,ggplot2::diamonds) # a GLM
get_contrast(model = diamond_lm3 )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.