| pa_nlm | R Documentation |
Evaluate observed and predicted continuous responses using the R-squared and L-squared measures of Li and Wang (2019). Predictions may come from a linear or nonlinear model; the original fitted model is not required.
pa_nlm(y, y.predict)
pam.nlm(y, y.predict)
y |
A finite numeric vector of observed continuous responses. |
y.predict |
A finite numeric vector of predictions, paired with
|
An ordinary least-squares regression of y on
y.predict, with an intercept, gives the corrected predictions
\hat y_c. The measures are
R^2 = \frac{\sum_i (\hat y_{c,i} - \bar y)^2}
{\sum_i (y_i - \bar y)^2}
and
L^2 = \frac{\sum_i (y_i - \hat y_{c,i})^2}
{\sum_i (y_i - y.predict_i)^2}.
R-squared describes explained response variation after affine correction;
L-squared compares the corrected and original prediction errors. These
are the original PAmeasures definitions, not 1 - L^2.
Constant predictions use the intercept-only correction mean(y).
A constant observed response makes R-squared undefined. Predictions
exactly equal to the observations make L-squared undefined because its
denominator is zero. Undefined measures are NA_real_, with a
warning; any other defined measure is retained. Inputs whose squared
deviations overflow or whose nonzero deviations underflow to zero are
rejected with an error and should be rescaled to common units.
pam.nlm() is the retained PAmeasures 0.1.0 compatibility entry
point. It uses the same calculation, then rounds and formats each result
to four decimal places as in the historical package. Its ordinary,
defined results retain the historical field names and character format;
input validation and undefined-result handling follow pa_nlm().
No deprecation warning is issued for this supported compatibility entry.
A list with R.squared and L.squared.
pa_nlm() returns unrounded numeric scalars.
pam.nlm() returns the historical formatted character scalars.
Li, G. and Wang, X. (2019). Prediction Accuracy Measures for a Nonlinear Model and for Right-Censored Time-to-Event Data. Journal of the American Statistical Association, 114, 1815–1825. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2018.1515079")}.
y <- c(1, 2, 4, 5)
prediction <- c(1, 2, 3, 4)
pa_nlm(y, prediction)
pam.nlm(y, prediction)
data(moore)
fit <- stats::lm(log2(count) ~ time, data = moore)
pa_nlm(moore$count, 2^stats::predict(fit))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.