I wonder whether any of you know of an efficient way to calculate the approximate degrees of freedom of a gamm() fit. Calculating the smoother/projection matrix S: y -> \hat y and then its trace by sum(eigen(S))$values is what I've been doing so far- but I was hoping there might be a more efficient way than doing the spectral decomposition of an NxN-matrix. The degrees of freedom associated with the linear and smooth parts can be read from the gam-part of the fitted gamm()-model, but not the degrees of freedom associated with the random effects. For lmer()-models, there is hatTrace() but I know of nothing of the sort for lme()-Objects. Maybe somebody has some code or ideas to share? --
On Wed, 1 Nov 2006, Fabian Scheipl wrote:> > Calculating the smoother/projection matrix S: y -> \hat y and then its > trace by sum(eigen(S))$values is what I've been doing so far- but I was > hoping there might be a more efficient way than doing the spectral > decomposition of an NxN-matrix. >Well, there are more efficient ways to compute the trace of a matrix than spectral decomposition. The trace is just the sum of the diagonal elements: sum(diag(S)) -thomas
Reasonably Related Threads
- mgcv, testing gamm vs lme, which degrees of freedom?
- Help : generating correlation matrix with a particular structure
- QR decomposition question
- mgcv::gamm error when combining random smooths and correlation/autoregressive term
- Poisson and negbin gamm in mgcv - overdispersion and theta