Function used to calculate some distance metrics between the predicted survival and the observed survival. fit_metrics() is used to calculate distance metrics between empirical and fitted survival for a predictions object, preferably the object $preds returned from plot_fit_on_data().
fit_metrics.RdFunction used to calculate some distance metrics between the predicted survival and the observed survival.
fit_metrics() is used to calculate distance metrics between empirical and fitted survival for a predictions object, preferably the object $preds returned from plot_fit_on_data().
Arguments
- preds
The
$predsobject fromplot_fit_on_data()applied to the model. If not this one, should be a predictiontibblewith the columnstime,strata(if applicable),estimate,.pred_survival,n.risk(alsochain, if necessary). It's important that the quantitiesestimateand.pred_survivalare calculated for the sametimeandstrata. It's highly recommended to simply use the object$predsreturned from the functionplot_fit_on_data().- nobs
The number of observations used to fit the model. Can be ignored if
thresholdis set to 0. To easily calculate this value, use the functionnobs()applied to the model object.- threshold
Numeric value between 0 and 1. Times with
n.riskbelow threshold * nobs will be ignored. Default is 0.005 (0.5%). Important because the distance metrics may be too big if calculated in intervals without sufficient observations to be estimated.
Value
A tibble with the following columns:
strata: The stratas used to fit the model (if necessary).n_strata: The number of observations in the strata.chain: The chain of the Bayesian model (only if necessary).metric: Which metric is being calculated.value: Value for the metric.
For now, the following metrics are available and will be included:
MSE: Mean Squared Error (the less the better).MAE: Mean Absolute Error (the less the better).Hellinger Distance: Hellinger distance, sometimes called Jeffreys distance (the less the better).KS Distance: Kolmogorov-Smirnov distance (the less the better).