Tobit Modelling

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Tobit Modelling

Patrick Sessford


Dear R-users,

I would like to model data where the response variable consists of many minus ones and many different positive values that seem to follow an apparently separate distribution (ie. -1, -1, 0.5, -1, 3, 3.5, 1.2, -1, -1, 0.4, etc); no values of the response can be less than minus one or between minus and zero (exclusive).

I am aware of tobit regression but unaware of exactly how to implement it in R. If anyone is able to help me on this issue I'd be extremely grateful; for example, if my (continuous) explanatory variables were x1 and x2, how should I define the model?

Thank you for your time.

Pat

     
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Tobit Modelling

sayan dasgupta
Hi Patrick,

Well tobit regression is applicable when there is censoring in the data.

Tobit regression in R has been implemented in the R package survival
An easy user interface is there in the packages AER and Zelig.

On Fri, Aug 6, 2010 at 6:12 AM, Patrick Sessford <[hidden email]>wrote:

>
>
> Dear R-users,
>
> I would like to model data where the response variable consists of many
> minus ones and many different positive values that seem to follow an
> apparently separate distribution (ie. -1, -1, 0.5, -1, 3, 3.5, 1.2, -1, -1,
> 0.4, etc); no values of the response can be less than minus one or between
> minus and zero (exclusive).
>
> I am aware of tobit regression but unaware of exactly how to implement it
> in R. If anyone is able to help me on this issue I'd be extremely grateful;
> for example, if my (continuous) explanatory variables were x1 and x2, how
> should I define the model?
>
> Thank you for your time.
>
> Pat
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Tobit Modelling

Cristian Montes
In reply to this post by Patrick Sessford
Hi Patrick

Here is some code that might help you implement your tobit regression, if you donĀ“t mind
using maximum likelihood.

#first declare a likelihood function with a censored model
#assume your x2 is censored for values below -1, and using a simple
#linear model in this case.  Our censoring threshold will be z.


YOURX1 = c(1,2,3,4,6,7,8,9,10,11)
YOURX2 = c(-1,-1,-1,-1,2.2,3.1,6.4,7, 7.2,8)

loglik <- function(param, x1, x2, z)
                {
                b0    <- param[1]
                b1    <- param[2]
                sigma <- param[3]

                result <-  ifelse(x2 >z, dnorm(x2, b0 + b1 * x1, sigma, log = T),
                      pnorm((z-b0+b1*x1)/sigma, log = T))
                return(sum(result))
                }


regression <- optim( par    = c(-3,1,1),
                           fn      = loglik,
                           method  = "L-BFGS-B",
                           lower   = c(-Inf, -Inf, 1e-10),  #bound solution for b0 and b1 to be any, but sigma >0
                           x1      = YOURX1,
                           x2      = YOURX2,
                           z       = -1,
                    control = list(fnscale = -1))  #maximize likelihood
                           
                           
plot(YOURX2 ~ YOURX1)
abline(a=regression$par[1], b= regression$par[2])
abline(lm (YOURX2~YOURX1), lty= 2)


The key here is that you are analyzing the likelihood for your x2 with different probabilities.
The code above was implemented for nonlinear regression, so you can put any model you want with
minor changes and it will work identically.  

Cheers,

Cristian.

-------------------------------------
Cristian Montes
Site Productivity Division Head
Bioforest S.A.

-----Mensaje original-----
De: [hidden email] [mailto:[hidden email]] En nombre de Patrick Sessford
Enviado el: Jueves, 05 de Agosto de 2010 08:42 p.m.
Para: [hidden email]
Asunto: [R] Tobit Modelling



Dear R-users,

I would like to model data where the response variable consists of many minus ones and many different positive values that seem to follow an apparently separate distribution (ie. -1, -1, 0.5, -1, 3, 3.5, 1.2, -1, -1, 0.4, etc); no values of the response can be less than minus one or between minus and zero (exclusive).

I am aware of tobit regression but unaware of exactly how to implement it in R. If anyone is able to help me on this issue I'd be extremely grateful; for example, if my (continuous) explanatory variables were x1 and x2, how should I define the model?

Thank you for your time.

Pat

     
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.