# [R] using betareg: problems with anova and predict

Paul Johnson pauljohn32 at gmail.com
Mon Apr 17 21:33:06 CEST 2006

```Dear R-helpers:

We have had fun using betareg to fit models with proportions as
dependent variables.

However, in the analysis of these models we found some wrinkles and
don't know where is the best place to start looking for a fix.

The problems we see (so far) are that

1. predict ignores newdata
2. anova does not work

Here is the small working example:

----------------------------
x <- c(1, 3, 1, 4, 5, 3, 5, 2, 5, 2)
y <- c(.3, .4, .4, .5, , .7, .4, .3, .4, .3, .5)
x2 <- c( 4, 2, 1, 5, 1, 2, 4, 2, 1, 3)
library(betareg)
mybreg <- betareg(y~x)
summary(mybreg)

predict(mybreg, newdata=data.frame(x=c(2,2)))

mybreg2 <- betareg(y~x+x2)
summary(mybreg)
anova(mybreg, mybreg2)

-------------------------------
Example output:

> predict(mybreg, newdata=data.frame(x=c(2,2)))
[1] 0.3903155 0.4207632 0.3903155 0.4362319 0.4518258 0.4207632 0.4518258
[8] 0.4054484 0.4518258 0.4054484
...
> anova(mybreg, mybreg2)
Error in as.double.default(lapply(objects, df.residual)) :
(list) object cannot be coerced to 'double'

I have been digging in this a little bit and notice betareg does not
return the log likelihood at the maximum likelihood estimates, but I
am able to hack the file /usr/lib/R/library/betareg/R/betareg and save
the "value" of the optim function and print that out, so at least I
can do a likelihood-ratio test by hand in place of the anova.  But I'm
stumped on why the predict ignores newdata.

I'm using R-2.1.1 on Fedora Core Linux 5 with the betareg package from CRAN.

In case you are interested in betareg, we have found this article to
be extremely readable and helpful: FERRARI, S.L.P., CRIBARI-NETO, F.
(2004). Beta regression for  modeling rates and proportions. Journal
of Applied Statistics, v. 31, n. 7, p. 799-815.

--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

```

More information about the R-help mailing list