Reputation: 71
Does anyone know how to obtain the fitted phi parameter from the model output (mgcv GAM with a beta distribution)?
Referring to the betar gam example provided:
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)
The output shows a phi estimate under "Family:Beta regression"
> bm
Family: Beta regression(0.491)
Link function: logit
Formula:
y ~ s(x0) + s(x1) + s(x2) + s(x3)
Estimated degrees of freedom:
1.73 1.63 5.62 1.00 total = 10.98
Upvotes: 4
Views: 1470
Reputation: 46888
During the fitting, the gam function calls betar() which then estimates the phi parameter called theta. I quoted the description of the function below:
Description:
Family for use with ‘gam’ or ‘bam’, 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.
Usage:
betar(theta = NULL, link = "logit",eps=.Machine$double.eps*100) Arguments: theta: the extra parameter (phi above).
Using the example you have, you just need to look under the gam object:
bm <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=betar(link="logit"),data=dat)
exp(bm$family$getTheta())
[1] 0.4913482
Upvotes: 4