Forum: help
Monitor Forum | Start New ThreadRE: factor() in censReg [ Reply ] By: Arne Henningsen on 2016-09-12 21:43 | [forum:43499] |
Hi Amir Based on the data set that is created by the code in my previous code, I think that I could reproduce your problem and that I found a work-around: # 2-ways FE estimation tobitFE2 <- censReg( y ~ x1 + x2 + id + factor(time), data = dat ) summary( tobitFE2 ) # create lagged dependent variable dat$yLag <- NA dat$yLag[ dat$time != 1981 ] <- dat$y[ dat$time != 2015 ] subset( dat, , c( "id", "time", "y", "yLag" ) ) # FE estimation with lagged dependent variable tobitLagFE <- censReg( y ~ x1 + x2 + yLag + id, data = dat ) summary( tobitLagFE ) # two-ways FE estimation with lagged dependent variable tobitLagFE2 <- censReg( y ~ x1 + x2 + yLag + id + factor(time), data = dat ) print( tobitLagFE2 ) # something went wrong :-( tobitLagFE2 <- censReg( y ~ x1 + x2 + yLag + id + factor(time), data = dat[ dat$time != 1981, ] ) summary( tobitLagFE2 ) # this works :-) It seems that the problem occurred, because the explanatory variable 'factor(time)' creates dummy variables for all time periods except the first time period (1981) and there are NA values in the lagged variable at all observations of the first time period so that all observations of the first time period are removed and, hence, there is perfect multicollinearity between the intercept and the dummy variables for the time periods, i.e. there is no "base period" for the time dummy variables. Best wishes, Arne |
RE: factor() in censReg [ Reply ] By: Amir Neto on 2016-09-12 20:46 | [forum:43498] |
Hello Arne, Thanks for your answer. That helps a lot. Another question I have is: if I include lag variables and the factor dummies for year, the model won't run, in the idea that my std.errors are infinite. Why does that happen? Is there a way to overcome this problem? Thanks again for the help, Amir |
RE: factor() in censReg [ Reply ] By: Arne Henningsen on 2016-09-12 20:23 | [forum:43497] |
Hi Amir If you use a "factor" variable with, say, K different levels as an explanatory variable in an equation, R automatically creates K-1 dummy variables. Hence, you can estimate a fixed-effects tobit model by estimating a standard (non random-effects) tobit model with a factor variable as explanatory variable that indicates the cross-sectional unit: # load packages library( "censReg" ) library( "plm" ) # dimension of panel data set nId <- 30 nTime <- 35 # generate data set set.seed( 123 ) dat <- data.frame( id = rep( paste( "F", 1:nId, sep = "_" ), each = nTime ), time = rep( 1980 + 1:nTime, nId ) ) dat$ui <- rep( rnorm( nId ), each = nTime ) dat$x1 <- rnorm( nId * nTime ) dat$x2 <- runif( nId * nTime ) dat$ys <- -1 + dat$ui + 2 * dat$x1 + 3 * dat$x2 + rnorm( nId * nTime ) dat$y <- ifelse( dat$ys > 0, dat$ys, 0 ) # RE estimaation pDat <- pdata.frame( dat, c( "id", "time" ) ) tobitRE <- censReg( y ~ x1 + x2, data = pDat ) summary( tobitRE ) # FE estimation tobitFE <- censReg( y ~ x1 + x2 + id, data = dat ) summary( tobitFE ) I hope that the above-given explanations and this example answer your question(s). Best wishes, Arne |
factor() in censReg [ Reply ] By: Amir Neto on 2016-09-08 18:31 | [forum:43491] |
Hi all, I am a new user of R and I have been trying to implement a fixed effect in a Tobit model. After going through several papers/threads I realized this is not possible. censReg only estimates random effect from my understading My question is: when I run something like -- tob <- censReg( y~ x1 + x2 + factor(state), data = praw, methor="BHHH") -- is the factor term like a dummy variable? If not, how should I interpret it? I couldn't find such information in the censReg documentation. Thanks, Amir |