library("gamlss2")
data("HarzTraffic", package = "gamlss2")
## estimate negative binomial count models
m1 <- gamlss2(
bikes ~ s(yday, bs = "cc"),
data = HarzTraffic,
family = NBI
)
m2 <- gamlss2(
bikes ~ s(yday, bs = "cc") | .,
data = HarzTraffic,
family = NBI
)
## compare models
Rsq(m1)
Rsq(m1, type = "both")
Rsq(m1, m2)
GAIC(m1, m2)
AIC(m1, m2)
BIC(m1, m2)
## plot estimated effects
plot(m2)GAIC and Generalised (Pseudo) R-squared for GAMLSS Models
Description
Functions to compute the GAIC and the generalized R-squared of Nagelkerke (1991) for GAMLSS models.
Usage
## information criteria
GAIC(object, ...,
k = 2, corrected = FALSE)
## r-squared
Rsq(object, ...,
type = c("Cox Snell", "Cragg Uhler", "both", "simple"),
newdata = NULL)
Arguments
object
|
A fitted model object. |
…
|
Optionally more fitted model objects. |
k
|
Numeric, the penalty to be used. The default k = 2 corresponds to the classical AIC.
|
corrected
|
Logical, whether the corrected AIC should be used? Note that it applies only when k = 2.
|
type
|
Which definition of R-squared should be used? Possible values are “Cox Snell”, “Cragg Uhler”, “both”, and “simple”. The option “simple” computes an R-squared based on the median; in this case newdata may also be supplied.
|
newdata
|
For type = “simple”, the R-squared can also be evaluated on newdata.
|
Details
The Rsq() function uses the following definition of R-squared:
\(R^2=1- \left(\frac{L(0)}{L(\hat{\theta})}\right)^{2/n}\)
where \(L(0)\) is the null model (only a constant is fitted to all parameters) and \(L(\hat{\theta})\) is the fitted model under consideration. This definition is sometimes referred to as the Cox and Snell R-squared. The Nagelkerke or Cragg and Uhler definition divides the above by
\(1 - L(0)^{2/n}\)
Value
Numeric vector or data frame, depending on the number of fitted model objects.
References
Nagelkerke NJD (1991). “A Note on a General Definition of the Coefficient of Determination.” Biometrika, 78(3), 691–692. doi:10.1093/biomet/78.3.691
See Also
gamlss2