Folks, Based on http://www.biostat.wustl.edu/archives/html/s-news/1999-06/msg00125.html I thought I should experiment with using survreg() to estimate tobit models. I start by simulating a data frame with 100 observations from a tobit model> x1 <- runif(100) > x2 <- runif(100)*3 > ystar <- 2 + 3*x1 - 4*x2 + rnorm(100)*2 > y <- ystar > censored <- ystar <= 0 > y[censored] <- 0 > D <- data.frame(y, x1, x2) > head(D)y x1 x2 1 0.0000000 0.86848630 2.6275703 2 0.0000000 0.88675832 1.7199261 3 2.7559349 0.38341782 0.6247869 4 0.0000000 0.02679007 2.4617981 5 2.2634588 0.96974450 0.4345950 6 0.6563741 0.92623096 2.4983289> # Estimate it > library(survival) > tfit <- survreg(Surv(y, y>0, type='left') ~ x1 + x2,data=D, dist='gaussian', link='identity') It says: Error in survreg.control(...) : unused argument(s) (link ...) Execution halted My competence on library(survival) is zero. Is it still the case that it's possible to be clever and estimate the tobit model using library(survival)? I also saw the two-equation setup in the micEcon library. I haven't yet understood when I would use that and when I would use a straight estimation of a censored regression by MLE. Can someone shed light on that? My situation is: Foreign investment on the Indian stock market. Lots of firms have zero foreign investment. But many do have foreign investment. I thought this is a natural tobit situation. -- Ajay Shah http://www.mayin.org/ajayshah ajayshah at mayin.org http://ajayshahblog.blogspot.com <*(:-? - wizard who doesn't know the answer.
If you look at ?survreg, you might notice that there is no link argument, but that reference is made to survreg.old that does contain a link argument. Thus, help(survreg,package=survival)> x1 <- runif(100) > x2 <- runif(100)*3 > ystar <- 2 + 3*x1 - 4*x2 + rnorm(100)*2 > y <- ystar > censored <- ystar <= 0 > y[censored] <- 0 > D <- data.frame(y, x1, x2) > head(D)y x1 x2 1 0.000000 0.8381902 2.3445745 2 2.834993 0.6603959 0.4572142 3 2.322114 0.6683632 0.2619112 4 0.000000 0.3762860 1.8897217 5 1.977283 0.9713827 0.8079159 6 0.536224 0.8266868 1.1839211> library(survival)Loading required package: splines> tfit <- survreg(Surv(y, y>0, type='left') ~ x1 + x2,+ data=D, dist='gaussian', link='identity') Error in survreg.control(...) : unused argument(s) (link ...) +> tfit <- survreg.old(Surv(y, y>0, type='left') ~ x1 + x2,+ data=D, dist='gaussian', link='identity')> tfitCall: survreg(formula = formula, data = data, dist = dist, scale = scale) Coefficients: (Intercept) x1 x2 1.594501 2.825190 -2.985390 Scale= 1.493047 Loglik(model)= -66.1 Loglik(intercept only)= -109.7 Chisq= 87.28 on 2 degrees of freedom, p= 0 n= 100>-- Ken Knoblauch Inserm U371 Cerveau et Vision Dept. of Cognitive Neuroscience 18 avenue du Doyen L??pine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.lyon.inserm.fr/371/
On Thu, 19 Jan 2006 14:05:58 +0530 Ajay Narottam Shah wrote:> Folks, > > Based on > http://www.biostat.wustl.edu/archives/html/s-news/1999-06/msg00125.html > > I thought I should experiment with using survreg() to estimate tobit > models.I've been working on a convenience interface to survreg() that makes it particularly easy to fit tobit models re-using the survreg() infrastructure. The package containing the code will hopefully be release soon - anyone who wants a devel snapshot, please contact me off-list. Ajay, I'll send you the code in a separate mail. Best, Z> I start by simulating a data frame with 100 observations from a tobit > model > > > x1 <- runif(100) > > x2 <- runif(100)*3 > > ystar <- 2 + 3*x1 - 4*x2 + rnorm(100)*2 > > y <- ystar > > censored <- ystar <= 0 > > y[censored] <- 0 > > D <- data.frame(y, x1, x2) > > head(D) > y x1 x2 > 1 0.0000000 0.86848630 2.6275703 > 2 0.0000000 0.88675832 1.7199261 > 3 2.7559349 0.38341782 0.6247869 > 4 0.0000000 0.02679007 2.4617981 > 5 2.2634588 0.96974450 0.4345950 > 6 0.6563741 0.92623096 2.4983289 > > > # Estimate it > > library(survival) > > tfit <- survreg(Surv(y, y>0, type='left') ~ x1 + x2, > data=D, dist='gaussian', link='identity') > > It says: > > Error in survreg.control(...) : unused argument(s) (link ...) > Execution halted > > My competence on library(survival) is zero. Is it still the case that > it's possible to be clever and estimate the tobit model using > library(survival)? > > I also saw the two-equation setup in the micEcon library. I haven't > yet understood when I would use that and when I would use a straight > estimation of a censored regression by MLE. Can someone shed light on > that? My situation is: Foreign investment on the Indian stock > market. Lots of firms have zero foreign investment. But many do have > foreign investment. I thought this is a natural tobit situation. > > -- > Ajay Shah > http://www.mayin.org/ajayshah > ajayshah at mayin.org > http://ajayshahblog.blogspot.com <*(:-? - wizard who doesn't know the > answer. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >