Learn R Programming

VGAM (version 1.0-2)

tobit: The Tobit Distribution

Description

Density, distribution function, quantile function and random generation for the Tobit model.

Usage

dtobit(x, mean = 0, sd = 1, Lower = 0, Upper = Inf, log = FALSE) ptobit(q, mean = 0, sd = 1, Lower = 0, Upper = Inf, lower.tail = TRUE, log.p = FALSE) qtobit(p, mean = 0, sd = 1, Lower = 0, Upper = Inf, lower.tail = TRUE, log.p = FALSE) rtobit(n, mean = 0, sd = 1, Lower = 0, Upper = Inf)

Arguments

x, q
vector of quantiles.
p
vector of probabilities.
n
number of observations. If length(n) > 1 then the length is taken to be the number required.

Lower, Upper
vector of lower and upper thresholds.

mean, sd, lower.tail, log, log.p
see rnorm.

Lower
Numeric. It is the value $L$ described below. Any value of the linear model $x_i^T beta$ that is less than this lowerbound is assigned this value. Hence this should be the smallest possible value in the response variable. May be a vector (see below for more information).

Upper
Numeric. It is the value $U$ described below. Any value of the linear model $x_i^T beta$ that is greater than this upperbound is assigned this value. Hence this should be the largest possible value in the response variable. May be a vector (see below for more information).

lmu, lsd
Parameter link functions for the mean and standard deviation parameters. See Links for more choices. The standard deviation is a positive quantity, therefore a log link is its default.

imu, isd, byrow.arg
See CommonVGAMffArguments for information.

type.fitted
Type of fitted value returned. The first choice is default and is the ordinary uncensored or unbounded linear model. If "censored" then the fitted values in the interval $[L, U]$. If "mean.obs" then the mean of the observations is returned; this is a doubly truncated normal distribution augmented by point masses at the truncation points (see dtobit). See CommonVGAMffArguments for more information.

imethod
Initialization method. Either 1 or 2 or 3, this specifies some methods for obtaining initial values for the parameters. See CommonVGAMffArguments for information.

zero
A vector, e.g., containing the value 1 or 2. If so, the mean or standard deviation respectively are modelled as an intercept-only. Setting zero = NULL means both linear/additive predictors are modelled as functions of the explanatory variables. See CommonVGAMffArguments for more information.

Value

dtobit gives the density, ptobit gives the distribution function, qtobit gives the quantile function, and rtobit generates random deviates.

Warning

If values of the response and Lower and/or Upper are not integers then there is the danger that the value is wrongly interpreted as uncensored. For example, if the first 10 values of the response were runif(10) and Lower was assigned these value then testing y[1:10] == Lower[1:10] is numerically fraught. Currently, if any y < Lower or y > Upper then a warning is issued.

Details

See tobit, the VGAM family function for estimating the parameters, for details. Note that the density at Lower and Upper is the the area to the left and right of those points. Thus there are two spikes (but less in value); see the example below. Consequently, dtobit(Lower) + dtobit(Upper) + the area in between equals unity.

See Also

tobit, rnorm.

Examples

Run this code
mu <- 0.5; x <- seq(-2, 4, by = 0.01)
Lower <- -1; Upper <- 2.0

integrate(dtobit, lower = Lower, upper = Upper,
          mean = mu, Lower = Lower, Upper = Upper)$value +
dtobit(Lower, mean = mu, Lower = Lower, Upper = Upper) +
dtobit(Upper, mean = mu, Lower = Lower, Upper = Upper)  # Adds to unity

## Not run:  
# plot(x, ptobit(x, m = mu, Lower = Lower, Upper = Upper),
#      type = "l", ylim = 0:1, las = 1, col = "orange",
#      ylab = paste("ptobit(m = ", mu, ", sd = 1, Lower =", Lower,
#                   ", Upper =", Upper, ")"),
#      main = "Orange is cumulative distribution function; blue is density",
#      sub = "Purple lines are the 10,20,...,90 percentiles")
# abline(h = 0)
# lines(x, dtobit(x, m = mu, Lower = Lower, Upper = Upper), col = "blue")
# 
# probs <- seq(0.1, 0.9, by = 0.1)
# Q <- qtobit(probs, m = mu, Lower = Lower, Upper = Upper)
# lines(Q, ptobit(Q, m = mu, Lower = Lower, Upper = Upper),
#       col = "purple", lty = "dashed", type = "h")
# lines(Q, dtobit(Q, m = mu, Lower = Lower, Upper = Upper),
#       col = "darkgreen", lty = "dashed", type = "h")
# abline(h = probs, col = "purple", lty = "dashed")
# max(abs(ptobit(Q, m = mu, Lower = Lower, Upper = Upper) - probs))  # Should be 0
# 
# endpts <- c(Lower, Upper)  # Endpoints have a spike (not quite, actually)
# lines(endpts, dtobit(endpts, m = mu, Lower = Lower, Upper = Upper),
#       col = "blue", lwd = 3, type = "h")
# ## End(Not run)

Run the code above in your browser using DataLab