Hello all, I have a problem estimating Random Effects model using censReg function. small part of code: UpC <- censReg(Power ~ Windspeed, left = -Inf, right 2000,data=PData_In,method="BHHH",nGHQ = 4) Error in maxNRCompute(fn = logLikAttr, fnOrig = fn, gradOrig = grad, hessOrig = hess, : NA in the initial gradient ...then I tried to set starting values myself and here is the error what I got: UpC <- censReg(Power ~ Windspeed, left = -Inf, right 2000,data=PData_In,method="BHHH",nGHQ = 4,start=c(-691,189,5)) Error in names(start) <- c(colnames(xMat), "logSigmaMu", "logSigmaNu") : 'names' attribute [4] must be the same length as the vector [3] How can I solve any of these errors? Thanks in advance! Best, Igors -- View this message in context: http://r.789695.n4.nabble.com/function-censReg-in-panel-data-setting-tp3792227p3792227.html Sent from the R help mailing list archive at Nabble.com.
Dear Igors On 5 September 2011 23:58, Igors <igors.lahanciks at gmail.com> wrote:> I have a problem estimating Random Effects model using censReg function. > > small part of code: > > UpC <- censReg(Power ~ Windspeed, left = -Inf, right > 2000,data=PData_In,method="BHHH",nGHQ = 4) > > Error in maxNRCompute(fn = logLikAttr, fnOrig = fn, gradOrig = grad, > hessOrig = hess, ?: > ?NA in the initial gradient > > > ...then I tried to set starting values myself and here is the error what I > got: > > UpC <- censReg(Power ~ Windspeed, left = -Inf, right > 2000,data=PData_In,method="BHHH",nGHQ = 4,start=c(-691,189,5)) > > Error in names(start) <- c(colnames(xMat), "logSigmaMu", "logSigmaNu") : > ?'names' attribute [4] must be the same length as the vector [3] > > > How can I solve any of these errors?You chose a suitable solution for the first problem (NA in initial gradient). Unfortunately, the documentation of "censReg" is not very clear regarding starting values of panel tobit models. Please note that you have to specify 4 starting values: intercept, slope parameter, variance of the individual effects ("mu"), and variance of the general error term ("nu"). http://cran.r-project.org/web/packages/censReg/vignettes/censReg.pdf Best wishes from Copenhagen, Arne -- Arne Henningsen http://www.arne-henningsen.name
Does censReg expect from panel data to be balanced? Because in my case it is unbalanced. Could this be a reason for errors? Best, Igors -- View this message in context: http://r.789695.n4.nabble.com/function-censReg-in-panel-data-setting-tp3792227p3798113.html Sent from the R help mailing list archive at Nabble.com.
On 8 September 2011 09:56, Igors <igors.lahanciks at gmail.com> wrote:> Does censReg expect from panel data to be balanced?No. censReg() can estimate models with unbalanced panel data. The estimation in the code that you sent me indeed does not work but if I remove the user-specified starting values (argument "start"), it works fine. R> summary(UpC) Call: censReg(formula = Power ~ Windspeed, left = -Inf, right = 2000, data = PData_In, nGHQ = 4, method = "BHHH", iterlim = 200) Observations: Total Left-censored Uncensored Right-censored 874 0 847 27 Coefficients: Estimate Std. error t value Pr(> t) (Intercept) -462.26676 19.89517 -23.23 <2e-16 *** Windspeed 188.38796 1.72492 109.22 <2e-16 *** logSigmaMu 4.54053 0.03352 135.45 <2e-16 *** logSigmaNu 5.08733 0.02706 188.00 <2e-16 *** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 BHHH maximisation, 131 iterations Return code 2: successive function values within tolerance limit Log-likelihood: -5538.124 on 4 Df /Arne -- Arne Henningsen http://www.arne-henningsen.name