Generalized Additive Model – Extracting the Degrees of Freedom of T Distribution in a GAM

generalized-additive-modelmgcv

I would have a rather easy question regarding the output when fitting a GAM using the mgvz package and assuming t distributed data.

Sample code is taken from https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/scat.html

library(mgcv)
## Simulate some t data...
set.seed(3);n<-400
dat <- gamSim(1,n=n)
dat$y <- dat$f + rt(n,df=4)*2

b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=scat(link="identity"),data=dat)

summary(b) yields the output “Family: Scaled t(5.376,2.088)”.

My question is whether I am right assuming that:

• 5.376 = degrees of freedom of the t distribution (nu)

• 2.088 = sigma

Best Answer

To get the actual values directly, {mgcv} has this hidden functionality of an extractor function buried in the family object of the fitted model. If the model has some additional parameters like the scaled t or negative binomial (nb()) families, there will be a function getTheta in the family.

These are not typically well documented in the {mgcv} help, unfortunately. Usually what is returned by getTheta() will be on the scales used for actual model fitting. To get them back on a more useful scale (like the $\nu$ and $\sigma$ parameters displayed in the output from summary()) getTheta() typically has a trans argument:

f <- family(b)
args(f$getTheta)
f$getTheta()
f$getTheta(trans = TRUE)

which produces:

> f <- family(b)
> args(f$getTheta)
function (trans = FALSE) 
NULL
> f$getTheta()
[1] 0.8653386 0.7362529
> f$getTheta(trans = TRUE)
[1] 5.375810 2.088097
Related Question