fitchisq: The chi-square goodness-of-fit

Description Usage Arguments Details Value Author(s) References Examples

Description

Calculates χ^2, reduced χ_{ν}^2 and the χ^2 fit probability for objects of class pcrfit, lm, glm, nls or any other object with a call component that includes formula and data. The function checks for replicated data (i.e. multiple same predictor values). If replicates are not given, the function needs error values, otherwise NA's are returned.

Usage

1
fitchisq(object, error = NULL)

Arguments

object

a single model of class 'pcrfit', a 'replist' or any fitted model of the above.

error

in case of a model without replicates, a single error for all response values or a vector of errors for each response value.

Details

The variance of a fit s^2 is also characterized by the statistic χ^2 defined as followed:

χ^2 \equiv ∑_{i=1}^n \frac{(y_i - f(x_i))^2}{σ_i^2}

The relationship between s^2 and χ^2 can be seen most easily by comparison with the reduced χ^2:

χ_ν^2 = \frac{χ^2}{ν} = \frac{s^2}{\langle σ_i^2 \rangle}

whereas ν = degrees of freedom (N - p), and \langle σ_i^2 \rangle is the weighted average of the individual variances. If the fitting function is a good approximation to the parent function, the value of the reduced chi-square should be approximately unity, χ_ν^2 = 1. If the fitting function is not appropriate for describing the data, the deviations will be larger and the estimated variance will be too large, yielding a value greater than 1. A value less than 1 can be a consequence of the fact that there exists an uncertainty in the determination of s^2, and the observed values of χ_ν^2 will fluctuate from experiment to experiment. To assign significance to the χ^2 value, we can use the integral probability

P_χ(χ^2;ν) = \int_{χ^2}^∞ P_χ(x^2, ν)dx^2

which describes the probability that a random set of n data points sampled from the parent distribution would yield a value of χ^2 equal to or greater than the calculated one. This is calculated by 1 - pchisq(χ^2, ν).

Value

A list with the following items:

chi2

the χ^2 value.

chi2.red

the reduced χ_ν^2.

p.value

the fit probability as described above.

Author(s)

Andrej-Nikolai Spiess

References

Data Reduction and Error Analysis for the Physical Sciences.
Bevington PR & Robinson DK.
McGraw-Hill, New York (2003).

Applied Regression Analysis.
Draper NR & Smith H.
Wiley, New York, 1998.

Examples

1
2
3
4
5
6
7
8
## Using replicates by making a 'replist'.
ml1 <- modlist(reps, fluo = 2:5)
rl1 <- replist(ml1, group = c(1, 1, 1, 1))
fitchisq(rl1[[1]])

## Using single model with added error.
m1 <- pcrfit(reps, 1, 2, l5)
fitchisq(m1, 0.1)

qpcR documentation built on May 2, 2019, 5:17 a.m.

Related to fitchisq in qpcR...