predict.htobit: Predictions and Residuals for htobit Objects

Description Usage Arguments Details See Also Examples

View source: R/htobit.R

Description

Methods for computing predictions, fitted values, and residuals from fitted htobit objects.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'htobit'
predict(object, newdata = NULL,
  type = c("response", "location", "scale", "parameter", "probability", "quantile"),
  na.action = na.pass, at = 0.5, ...)
## S3 method for class 'htobit'
fitted(object, type = c("location", "scale"), ...)
## S3 method for class 'htobit'
residuals(object, type = c("standardized", "pearson", "response"), ...)

Arguments

object

an object of class "htobit".

newdata

optionally, a data frame in which to look for variables with which to predict. If omitted, the original observations are used.

type

character indicating type of predictions/residuals: fitted means of latent response ("response" or equivalently "location"), latent standard deviation ("scale"), or both ("parameter"). The cumulative distribution function or quantile function of the corresponding fitted parametric distributions can be evaluated with "probability" or "quantile", respectively.

na.action

function determining what should be done with missing values in newdata. The default is to predict NA.

at

numeric vector indicating the level(s) at which quantiles or probabilities should be predicted (only if type = "quantile" or "probability").

...

currently not used.

Details

Currently, "location" and "scale" only provide the parameters of the latent Gaussian variable in the censored regression. Additionally, the mean and standard deviation of the manifest observed response variable would be of interest. However, this is currently not implemented yet.

Therefore, the standardized/Pearson residuals are not entirely correct. These would really need to be defined in terms of the manifest rather than the latent parameters.

In addition to the methods above, a set of standard extractor functions for "htobit" objects is available, see htobit for an overview.

See Also

htobit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## heteroscedastic tobit model for budget share of alcohol
data("AlcoholTobacco", package = "htobit2017")
AlcoholTobacco$persons <- with(AlcoholTobacco, adults + oldkids + youngkids)
ma <- htobit(alcohol ~ age + log(expenditure) + persons | age + log(expenditure) + persons,
  data = AlcoholTobacco)

## by default predict() and fitted() return the fitted latent means on the observed sample
head(fitted(ma))
head(predict(ma))

## new data with fixed age and persons (at median) and varying expenditure (over observed range)
nd <- data.frame(age = 2, persons = 2, expenditure = exp(12:15))

## latent Gaussian location and scale (or both)
predict(ma, newdata = nd, type = "location")
predict(ma, newdata = nd, type = "scale")
predict(ma, newdata = nd, type = "parameter")

## median
predict(ma, newdata = nd, type = "quantile", at = 0.5)

## probability of zero boundary
predict(ma, newdata = nd, type = "probability", at = 0)

htobit2017 documentation built on May 2, 2019, 6:04 p.m.