betar {mgcv} | R Documentation |
Family for use with gam
, implementing regression for beta distributed data on (0,1).
A linear predictor controls the mean, mu of the beta distribution, while the variance is then
mu(1-mu)/(1+phi), with parameter phi being estimated during
fitting, alongside the smoothing parameters.
betar(theta = NULL, link = "logit")
theta |
the extra parameter (phi above). |
link |
The link function: one of |
These models are useful for proportions data which can not be modelled as binomial. Note the assumption that data are in (0,1), despite the fact that for some parameter values 0 and 1 are perfectly legitimate observations. The restriction is needed to keep the log likelihood bounded for all parameter values. Any data exactly at 0 or 1 are reset to be just above 0 or just below 1.
An object of class extended.family
.
Natalya Pya (nyp20@bath.ac.uk) and Simon Wood (s.wood@r-project.org)
library(mgcv) ## Simulate some beta data... set.seed(3);n<-400 dat <- gamSim(1,n=n) mu <- binomial()$linkinv(dat$f/4-2) phi <- .5 a <- mu*phi;b <- phi - a; dat$y <- rbeta(n,a,b) bm <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=betar(link="logit"),data=dat) bm plot(bm,pages=1)