View source: R/model_metrics.R
calculate_model_metrics | R Documentation |
mfp2
Mostly used within an mfp step to compare between the different fp models of a variable.
calculate_model_metrics(obj, n_obs, df_additional = 0)
obj |
a list returned by |
n_obs |
a numeric value indicating the number of observations for the
data used to fit |
df_additional |
a numeric value indicating the number of additional degrees of freedom to be accounted for in the computations of AIC and BIC. These may be necessary when a model uses FP terms, as these add another degree of freedom per estimated power. |
A numeric vector with the following entries:
df
: number of degrees of freedom of model (i.e. coefficients plus
df_additional
).
deviance_rs
: "deviance", i.e. minus twice the log likelihood.
This is not the usual definition of deviance used by R, which is defined as
twice the difference between the log likelihoods of the saturated model
(one parameter per observation) and the null (or reduced) model.
It is, however, the definition used in Royston and Sauerbrei (2008) and in
mfp
. For selection of fps this does not really play a role, as the common
factor would be cancelled anyway when comparing models based on deviances.
sse
: sum of squared residuals as returned by fit_model()
.
deviance_gaussian
: deviance computed by deviance_gaussian()
,
applicable to Gaussian models and used for F-test computations.
aic
: Akaike information criterion, defined as
-2logL + 2(df + df_additional)
.
bic
: Bayesian information criterion, defined as
-2logL + log(n_obs)(df + df_additional)
.
df_resid
: residual degrees of freedom, defined as n_obs - df
.
For consistency with stata we subtract the scale parameter from df
.
Royston, P. and Sauerbrei, W., 2008. Multivariable Model - Building:
A Pragmatic Approach to Regression Anaylsis based on Fractional Polynomials
for Modelling Continuous Variables. John Wiley & Sons.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.