Learn R Programming

sparsereg (version 1.0)

type2tobit: Type 2 Tobit model using sparse regression.

Description

Function for fitting a type 2 Tobit model. Both stages of the model are fit using sparse modeling.

Usage

type2tobit(y1, y2=NULL, X1, X2=NULL, stage2, 
group=NULL, gibbs=200, burnin=200, thin=10,
one.constraint=TRUE, id=NULL, id2=NULL, id3=NULL, 
id_2=NULL, id2_2=NULL, id3_2=NULL)

Arguments

y1, y2
Dependent variables for stage 1 (binary model) and stage 2 (truncated model).
X1, X2
Covariates for stage 1 (binary model) and stage 2 (truncated model).
stage2
An indicator variable of length y2 taking a value of 1 for observations for which the inverse mills ratio in the stage 2 model is zero.
group
Optional vector of integers characterizing which covariates are under the same LASSO constraint. For example, the vector c(1,1,2,2,2) will place the first two covariates under one LASSO constraint and the last three under another.
gibbs
Number of posterior samples to save. Between each saved sample, thin samples are drawn.
burnin
Number of burnin samples. Between each burnin sample, thin samples are drawn. These iterations will not be included in the resulting analysis.
thin
Extent of thinning of the MCMC chain. Between each posterior sample, whether burnin or saved, thin draws are made.
one.constraint
Whether to fit a single LASSO constraint.
id, id2, id3, id_2, id2_2, id3_2
Vectors the same lenght of the sample denoting clustering in the data. In a conjoint experiment with repeated observations, these correspond with respondent IDs. Up to three different sets of random effects are allowed.

Value

  • beta.modeMatrix of sparse (mode) estimates for stage 1 with columns equal to number of effects and rows for posterior samples.
  • beta.meanMatrix of mean estimates for stage 1 with columns equal to number of effects and rows for posterior samples. These estimates are not sparse, but they do predict better than the mode.
  • beta.mode.2Matrix of sparse (mode) estimates for stage 2 with columns equal to number of effects and rows for posterior samples.
  • beta.mean.2Matrix of mean estimates for stage 2 with columns equal to number of effects and rows for posterior samples. These estimates are not sparse, but they do predict better than the mode.
  • sigma.sq_2Vector of posterior estimate of error variance for stage 2.
  • XMatrix of covariates fit. Includes interaction terms, depending on scale.type.
  • modeltypeType of sparsereg model fit. In this case, twostage. Used by summary functions.

Details

Runs a type 2 tobit model with stage 1 running a probit and stage 2 entering the residual correction as a covariate. Please note that if there are any known cases that have non-zero value with probability 1, these observations must be stacked on top of the stage 1 covariates when they are given to stage 2. If there are no such obserations, then stage 1 and stage 2 should consist of the same observations in the same order.

References

Ratkovic, Marc and Tingley, Dustin. 2015. "Sparse Estimation with Uncertainty: Subgroup Analysis in Large Dimensional Design." Working paper.

Kim, In Song, Londregan, John and Ratkovic, Marc. 2015. "A Sparse Decomposition of Democracy and Trade." Working paper

See Also

sparsereg

Examples

Run this code
set.seed(1)
 n<-1000
 k<-5
 Sigma<-diag(k)
 Sigma[Sigma==0]<-0.5
 X<-mvrnorm(n,m=rep(0,k),S=Sigma)

 y1.0<- -1+X[,2]*1 + X[,3]*(-1)+rnorm(n)
 probs1<-dnorm(y1.0)
 y1<-obs.zero<-rbinom(n,1,probs1)

 y2<-exp(1+X[,1]*1 + X[,2]*(-2)+X[,4]*(-1)+rnorm(n))
 y2[obs.zero==0]<-0

 t1<-type2tobit(y1=y1,X1=X,y2=log(1+y2),X2=X,stage2=rep(0,n),
   one.constraint=TRUE)

 plot(t1, stage=1)
 plot(t1, stage=2)

Run the code above in your browser using DataLab