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

View source: R/margEff.polywog.r

Computes average and observationwise marginal effects from a fitted
`polywog`

model.

1 2 |

`object` |
a fitted model of class |

`xvar` |
a character string containing the name of a raw input variable
(from |

`drop` |
logical: whether to convert one-column matrices in the output to vectors. |

`...` |
other arguments, currently ignored. |

For input variables that are binary, logical, or factors,
`margEff.polywog`

computes a first difference with comparison to a
reference category. All other variables are treated as continuous:
the function computes the partial derivative of the fitted value with
respect to the selected variable.

If `xvar`

is specified, a numeric object containing
the marginal effect of the chosen variable at each observation in
`object$model`

. For factor variables, if there are more than two
levels or `drop = FALSE`

, the returned object is a matrix; otherwise it
is a vector.

If `xvar`

is `NULL`

, a list of such results for each raw input
variable in the model is returned.

In either case, the returned object is of class `"margEff.polywog"`

.

Brenton Kenkel and Curtis S. Signorino

To plot the density of the observationwise marginal effects, see
`plot.margEff.polywog`

. For a table of average marginal effects
and order statistics, `summary.margEff.polywog`

.

To compute fitted values, see `predict.polywog`

and
`predVals`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
## Using occupational prestige data
data(Prestige, package = "carData")
Prestige <- transform(Prestige, income = income / 1000)
## Fit a polywog model
## (note: using low convergence threshold to shorten computation time of the
## example, *not* recommended in practice!)
set.seed(22)
fit1 <- polywog(prestige ~ education + income | type,
data = Prestige,
degree = 2,
thresh = 1e-4)
## Compute marginal effects for all variables
me1 <- margEff(fit1)
summary(me1) # type was included linearly, hence constant effects
## Plotting density of the results
plot(me1)
## Can do the same when just examining a single variable
me2 <- margEff(fit1, xvar = "income")
summary(me2)
plot(me2)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.