Function that returns the reduced chi-squared (\(\chi^2_{red}=\chi^2/df\),
where \(df\) are the degrees of freedom) value for
a non-linear regression model (nls
object). Reduced-chi squared is a
goodness-of-fit measure. Values close to 1 indicates a good fit, while
values \(>>1\) indicate poor fit and values \(<1\) indicate
over-fitting.
The function is calculated only with non-linear regression weighted on
experimental error.
References
Philip R. Bevington, D. Keith Robinson, J. Morris Blair, A. John Mallinckrodt, Susan McKay (1993). Data Reduction and Error Analysis for the Physical Sciences
See also
stats::dchisq()
for chi-squared distribution; stats::AIC()
,
stats::BIC()
, stats::sigma()
(for RMSE), AICC()
for other
goodness-of-fit
indicators. goodness_of_fit()
Examples
x <- c(1, 2, 3, 4, 5)
y <- c(1.2, 3.9, 8.6, 17.4, 26)
er <- c(0.5, 0.8, 0.5, 1.9, 1.2)
fit1 <- nls(y ~ k * x^2,
data = list(x = x, y = y),
start = list(k = 1),
weights = 1 / er^2
)
chiquad_red(fit1)
#> [1] 0.9896681
fit2 <- nls(y ~ k * x^3,
data = list(x = x, y = y),
start = list(k = 1),
weights = 1 / er^2
)
chiquad_red(fit2)
#> [1] 22.55793