df_typical: Find typical levels of explanatory variables in a...

Description Usage Arguments Details Value Examples

View source: R/df_typical.R

Description

This function tries to choose sensible values of the explanatory variables from the data used to build a model or any other specified data. (or from data specified with the data = argument.)

Usage

1
df_typical(data = NULL, nlevels = 3, at = list(), model = NULL, ...)

Arguments

data

optional data frame from which to extract levels for explanatory variables

nlevels

how many levels to construct for input variables. For quantitative variables, this is a suggestion. Set to Inf to get all levels for categorical variables and 100 levels for quantitative variables.

at

named list giving specific values at which to hold the variables. Use this to override the automatic generation of levels for any or all explanatory variables.

model

the model to display graphically

...

a more concise mechanism to passing desired values for variables

Details

For categorical variables, the most populated levels are used. For quantitative variables, a sequence of pretty() values is generated.

For categorical variables, will return the nlevels most popular levels, unless the levels are specified explicitly in an argument.

Value

A dataframe containing all combinations of the selected values for the explanatory variables. If there are p explanatory variables, there will be about nlevels^p cases.

Examples

1
2
3
4
5
6
7
## Not run: 
df_typical(mosaicData::Galton, nlevels = 2, father = 70, mother = 68, nkids = 3)
df_typical(mosaicData::Galton, nlevels = 2)
mod1 <- lm(wage ~ age * sex + sector, data = mosaicData::CPS85)
df_typical(model = mod1, nlevels = 3)

## End(Not run)

mosaicModel documentation built on Sept. 22, 2017, 5:05 p.m.