goodnessOfFit {gllvm} | R Documentation |
Goodness of fit measures for a gllvm
Description
Several goodness-of-fit measure are currently available and can be calculated for a gllvm model fit and predicted values.
Usage
goodnessOfFit(
y = NULL,
pred = NULL,
object = NULL,
measure = c("cor", "RMSE", "MAE", "MARNE"),
species = FALSE
)
Arguments
y |
a response matrix |
pred |
predicted values for response matrix y |
object |
an object of class 'gllvm'. |
measure |
a goodness-of-fit measure to be calculated. Options are |
species |
logical, if |
Details
goodnessOfFit is used for evaluating the goodness-of-fit of a model or predictions. Available goodness-of-fit measures are correlation, RMSE, MARNE, and R2 measures. Definitions are below.
Denote an observed response j (species) at sample i, i=1,...,n
, as y_{ij}
, and predicted value as \hat y_{ij}
.
RMSE(\boldsymbol{y_{j}}, \boldsymbol{\hat y_{j}}) = \sqrt{\frac{1}{n}\Sigma_{i=1}^{n} {(y_{ij} - \hat y_{ij})^2}}
MAE(\boldsymbol{y_{j}}, \boldsymbol{\hat y_{j}}) = \frac{1}{n}\Sigma_{i=1}^{n} |y_{ij} - \hat y_{ij}|
MARNE(\boldsymbol{y_{j}}, \boldsymbol{\hat y_{j}}) = \frac{1}{n}\Sigma_{i=1}^{n} \frac{|y_{ij} - \hat y_{ij}|}{max(\boldsymbol{y_{j}}) - min(\boldsymbol{y_{j}})}
Tjur's R2(\boldsymbol{y_{j}}, \boldsymbol{\hat y_{j}}) = \frac{1}{n_1}\Sigma \hat y_{ij}\boldsymbol{1}_{y=1}(y_{ij}) - \frac{1}{n_0}\Sigma \hat y_{ij}\boldsymbol{1}_{y=0}(y_{ij})
Author(s)
Jenni Niku <jenni.m.e.niku@jyu.fi>
See Also
Examples
## Not run:
# Fit gllvm model with Poisson family
data(microbialdata)
X <- microbialdata$Xenv
y <- microbialdata$Y[, order(colMeans(microbialdata$Y > 0),
decreasing = TRUE)[21:40]]
fit <- gllvm(y, X, formula = ~ pH + Phosp, family = poisson())
# Calculate metrics
goodnessOfFit(object = fit, measure = c("cor", "RMSE"))
## End(Not run)