ame: Average marginal effects for ML algorithms

Description Usage Arguments Details Value Author(s) See Also Examples

Description

ame estimates average marginal effects (AME) for models fitted using different machine learning (ML) algorithms. AMEs can be estimated for continuous and binary independent variables / features on continuous dependent variables / response.

Usage

1
2
ame(data.name, meth = "dt", func, var.name, fromtoby = NULL,
  plotTree = FALSE, plotPV = FALSE)

Arguments

data.name

a data frame containing the variables in the model.

meth

ML algorithm to be used; currently "lm", "dt", "dtt", "rf", and "rftt" are implemented. For more information see 'Details'.

func

an object of class "formula" specifying the model to be fitted. For example: y ~ x + z

var.name

name of independent variable / feature AME is to be estimated for.

fromtoby

range predicted values are to be esitmated for. Only necessary for continuous independent variables / features. Usually given as seq(from, to, by) Where from and to are the interval boundaries and by is the step width.

plotTree

plot the resulting decision tree (only for meth = "dt").

plotPV

plot predicted values (only for continuous independent variables / features).

Details

The data frame data.name is used to train a ML model using one of five algorithms:

method = "lm"

an ordinary linear model (yes, this is also considered a ML algorithm ;)

method = "dt"

an ordinary regression tree implemented via the rpart function.

method = "dtt"

two tree algorithm

method = "rf"

a random forest

method = "rftt"

random forest two tree

The formula func is used to specify the dependent variable / response and the independent variables / features that will be used for learning the model.

Value

ame returns a list of two (for binary independent variables / features) or three objects (for continuous independent variables / features):

  1. AME estimate

  2. predicted values (continuous only)

  3. model information

Author(s)

Jonas Beste (jonas.beste@iab.de) and Arne Bethmann (bethmann@uni-mannheim.de).

See Also

ame.boot

Examples

1
2
3
4
5
6
7
8
## Estimate AMEs for Species on Petal.Length in iris data
set.seed(1)

## Using a linear model
ame(iris, "lm", Petal.Length ~ Petal.Width + Species, "Species")[1:2]

## Using a decision tree
ame(iris, "dt", Petal.Length ~ Petal.Width + Species, "Species")[1:2]

umasds/mlame documentation built on May 3, 2019, 2:24 p.m.