prediction_margins: prediction methods

prediction_marginsR Documentation

prediction methods

Description

Methods to compute the predictions and the marginal effects for tobit1 objects

Usage

## S3 method for class 'tobit1'
prediction(
  model,
  data = find_data(model, parent.frame()),
  at = NULL,
  type = "response",
  vcov = stats::vcov(model),
  calculate_se = FALSE,
  ...
)

## S3 method for class 'tobit1'
predict(object, newdata = NULL, what = c("expvalue", "prob", "linpred"), ...)

Arguments

model, object

a model fitted using tobit1

data, at, type, vcov, calculate_se

see prediction::prediction

...

further arguments, especially, a what argument can be provided and will be passed to predict

newdata

a new data frame for which the predict method should compute the predictions

what

for the predict method, the kind of predictions, can be the probabilities (prob), the linear predictor (linpred) and the expected value of the response (expvalue)

Details

tobit1 exports the prediction::prediction and margins::margins functions. prediction use the predict method to compute the predictions in a "tidy way", it returns the data frame provided for the predictions augmented by the predictions. margins compute the average marginal effect of every covariate. It uses the numerical derivatives of the predictions using the prediction function.

Value

prediction returns a data frame which is a data frame containging the values of the covariates used for the predictions augmented by the predicted values. margins return an object of class c('margins', 'data.frame') which is data frame containg the the marginal effects.

Examples

data("feesadm", package = "tobit1")
z <- tobit1(fees ~ expense + I(expense ^ 2) + region, feesadm)
head(predict(z))
# same with what = "expvalue", the default
head(predict(z, what = "expvalue"))
# compute the linear predictor and the probability
head(predict(z, what = "linpred"))
head(predict(z, what = "prob"))
# the prediction method returns a data frame
prediction(z, what = "prob")
# use a smaller data set
fees2 <- feesadm[5:25, ]
predict(z, newdata = fees2, what = "prob")
prediction(z, data = fees2, what = "prob")
margins(z, data = fees2, what = "prob")
summary(margins(z, data = fees2, what = "prob"))

tobit1 documentation built on March 18, 2022, 7:31 p.m.