Dear all, I get an error using betrag on this data set :http://dl.dropbox.com/u/1866110/dump.csv. I run it like this regression f2.1=betareg(Y~X1+X2,data=dump) summary(f2.1) I get : Call: betareg(formula = Y ~ X1 + X2, data = dump) Standardized weighted residuals 2: Error in quantile.default(x$residuals) : missing values and NaN's not allowed if 'na.rm' is FALSE In addition: Warning message: In sqrt(v * (1 - hatvalues(object))) : NaNs produced Does anybody know how to fix this? Oyvind -- View this message in context: http://r.789695.n4.nabble.com/Error-using-betareg-tp3621955p3621955.html Sent from the R help mailing list archive at Nabble.com.
On Fri, 24 Jun 2011, oyvfos wrote:> Dear all, > > I get an error using betrag on this data set > :http://dl.dropbox.com/u/1866110/dump.csv. > I run it like this > regression f2.1=betareg(Y~X1+X2,data=dump) > summary(f2.1) > > I get : > > Call: > betareg(formula = Y ~ X1 + X2, data = dump) > > Standardized weighted residuals 2: > Error in quantile.default(x$residuals) : > missing values and NaN's not allowed if 'na.rm' is FALSE > In addition: Warning message: > In sqrt(v * (1 - hatvalues(object))) : NaNs produced > > Does anybody know how to fix this?I cannot replicate this. I get no error but the results below for R 2.13.0 and betareg 2.3.0. R> d <- read.table("http://dl.dropbox.com/u/1866110/dump.csv") R> m <- betareg(Y ~ X1 + X2, data = d) R> summary(m) Call: betareg(formula = Y ~ X1 + X2, data = d) Standardized weighted residuals 2: Min 1Q Median 3Q Max -1.2621 -0.5828 -0.1272 0.3490 3.5940 Coefficients (mean model with logit link): Estimate Std. Error z value Pr(>|z|) (Intercept) -0.6830481 0.2697329 -2.532 0.0113 * X1Y -0.4199696 0.2657974 -1.580 0.1141 X2 -0.0003639 0.0001561 -2.331 0.0198 * Phi coefficients (precision model with identity link): Estimate Std. Error z value Pr(>|z|) (phi) 0.97087 0.04256 22.81 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Log-likelihood: 1820 on 4 Df Pseudo R-squared: 0.01671 Number of iterations in BFGS optimization: 17 Your results suggest that something goes wrong in the computation of residuals. So you may try to use summary(m, type = "deviance") or summary(m, type = "pearson"). If these work, then you should look at residuals(m, type = "sweighted2") which is the default type of residuals. As these involve computations of quadratic (n x n) complexity, they may be numerically less stable compared to deviance or pearson residuals which just require computations of linear complexity. hth, Z> Oyvind > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Error-using-betareg-tp3621955p3621955.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org 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. >
The replication of the error did not "suceed" because I forgot to tell that X2 is a factor. Sorry about that. For instance: d[,3]=as.factor(d[,3]) This piece is just a small sample of a larger error for which I encouneter this error many times. Thanks -- View this message in context: http://r.789695.n4.nabble.com/Error-using-betareg-tp3621955p3622300.html Sent from the R help mailing list archive at Nabble.com.
On Fri, 24 Jun 2011, oyvfos wrote:> The replication of the error did not "suceed" because I forgot to tell that > X2 is a factor. Sorry about that. For instance: > d[,3]=as.factor(d[,3]) > This piece is just a small sample of a larger error for which I encouneter > this error many times.You try to estimate coefficients for levels with very few observations. In particular for one level, the number of occurrences is only _one_. This creates problems if you want to compute measures of reliability (which are required in beta regression residuals). If you want to get the usual coefficient table with partial Wald tests, you can still do so via coeftest(m), as illustrated in the vignette. The results will, of course, not be very meaningful for those coefficients estimated from just one observation... However, if you want to have a model that is interpretable as a whole, then include only levels whose coefficients can be estimated meaningfully. In your demo case, you need to exclude at least the level "700". Best, Z> Thanks > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Error-using-betareg-tp3621955p3622300.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org 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. >