简体   繁体   中英

mgcv GAM with betar

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 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM