Learn R Programming

chemdeg (version 0.1.2)

chiquad_red: Reduced chi-squared

Description

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.

Usage

chiquad_red(fit)

Value

Returns the reduced chi-squared value

Arguments

fit

nls object with weighted fit

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

Run this code
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)

fit2 <- nls(y ~ k * x^3,
  data = list(x = x, y = y),
  start = list(k = 1),
  weights = 1 / er^2
)
chiquad_red(fit2)

Run the code above in your browser using DataLab