effect_size: Calculate effect sizes in a model

Description Usage Arguments Details Examples

View source: R/effect_size.R

Description

Like a derivative or finite-difference

Usage

1
2
effect_size(model, formula, step = NULL, bootstrap = FALSE, to = step,
  data = NULL, at = NULL, ...)

Arguments

model

the model from which the effect size is to be calculated

formula

a formula whose right-hand side is the variable with respect to which the effect size is to be calculated.

step

the numerical stepsize for the change var, or a comparison category for a categorical change var. This will be either a character string or a number, depending on the type of variable specified in the formula.

bootstrap

If TRUE, calculate a standard error using bootstrapping. Alternatively, you can specify the number of bootstrap replications (default:100).

to

a synonym for step. (In English, "to" is more appropriate for a categorical input, "step" for a quantitative. But you can use either.)

data

Specifies exactly the cases at which you want to calculate the effect size. Unlike ... or at, no new combinations will be created.

at

similar to ... but expects a list or dataframe of the values you want to set. Like ..., all combinations of the values specified will be used as inputs.

...

additional arguments for evaluation levels of explanatory variables or to be passed to predict(). For instance, for a glm, perhaps you want type = "response".

Details

When you want to force or restrict the effect size calculation to specific values for explanatory variables, list those variables and levels as a vector in ... For example, educ = c(10, 12, 16) will cause the effect size to be calculated at each of those three levels of education. Any variables whose levels are not specified in ... will have values selected automatically.

Examples

1
2
3
4
5
6
mod1 <- lm(wage ~ age * sex * educ + sector, data = mosaicData::CPS85)
effect_size(mod1, ~ sex)
effect_size(mod1, ~ sector)
effect_size(mod1, ~ age, sex = "M", educ = c(10, 12, 16), age = c(30, 40))
effect_size(mod1, ~ age, sex = "F", age = 34, step = 1)
effect_size(mod1, ~ sex, age = 35, sex = "M", to = "F" )

Example output

Loading required package: ggplot2
     change sex to:sex age educ sector
1 -1.875015   M      F  35   12   prof
     change sector to:sector age sex educ
1 -2.232965   prof  clerical  35   M   12
      slope age   to:age sex educ sector
1 0.1181573  30 41.72657   M   10   prof
2 0.1181573  40 51.72657   M   10   prof
3 0.1381628  30 41.72657   M   12   prof
4 0.1381628  40 51.72657   M   12   prof
5 0.1781739  30 41.72657   M   16   prof
6 0.1781739  40 51.72657   M   16   prof
     slope age to:age sex educ sector
1 0.054897  34     35   F   12   prof
     change sex to:sex age educ sector
1 -1.875015   M      F  35   12   prof

statisticalModeling documentation built on May 29, 2017, 11:56 p.m.