calculate_model_metrics {mfp2} | R Documentation |
Function to compute model metrics to be used within mfp2
Description
Mostly used within an mfp step to compare between the different fp models of a variable.
Usage
calculate_model_metrics(obj, n_obs, df_additional = 0)
Arguments
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. |
Value
A numeric vector with the following entries:
-
df
: number of degrees of freedom of model (i.e. coefficients plusdf_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 inmfp
. 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 byfit_model()
. -
deviance_gaussian
: deviance computed bydeviance_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 asn_obs - df
. For consistency with stata we subtract the scale parameter fromdf
.
References
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.