# R Programming/Tobit And Selection Models

edit this box

## Tobit (type 1 Tobit)

In this section, we look at simple tobit model where the outcome variable is observed only if it is above or below a given threshold.

• tobit() in the AER package[1]. This is a wrapper for survreg().
```N <- 1000
u <- rnorm(N)
x <- - 1 + rnorm(N)
ystar <- 1 + x + u
y <- ystar*(ystar > 0)
hist(y)

ols <- lm(y ~ x)
summary(ols)

library(AER)
tobit <- tobit(y ~ x,left=0,right=Inf,dist = "gaussian")
```

## Selection models (type 2 tobit or heckit)

In this section we look at endogenous selection process. The outcome y is observe only if d is equal to one with d a binary variable which is correlated with the error term of y.

• heckit() and selection() in sampleSelection [2]. The command is called `heckit()` in honor of James Heckman[3].
```N <- 1000
u <- rnorm(N)
v <- rnorm(N)
x <- - 1 + rnorm(N)
z <- 1 + rnorm(N)
d <- (1 + x + z + u + v> 0)
ystar <- 1 + x + u
y <- ystar*(d == 1)
hist(y)

ols <- lm(y ~ x)
summary(ols)

library(sampleSelection)
heckit.ml <- heckit(selection = d ~ x + z, outcome = y ~ x, method = "ml")
summary(heckit.ml)

heckit.2step <- heckit(selection = d ~ x + z, outcome = y ~ x, method = "2step")
summary(heckit.2step)
```

## Truncation

• truncreg package
• DTDA "An R package for analyzing truncated data" pdf.

## References

1. Christian Kleiber and Achim Zeileis (2008). Applied Econometrics with R. New York: Springer-Verlag. ISBN 978-0-387-77316-2. URL http://CRAN.R-project.org/package=AER
2. Sample Selection Models in R: Package sampleSelection http://www.jstatsoft.org/v27/i07
3. James Heckman "Sample selection bias as a specification error", Econometrica: Journal of the econometric society, 1979