Learn R Programming

spaMM (version 4.7.0)

gof: Goodness of fit test

Description

Performs a test of goodness of fit (by default: see the testfn argument for possible alternatives). The only method implemented so far is based on randomized quantile residuals (Dunn & Smyth, 1996).

Usage

gof(object, method = "RQR", plot.=FALSE, testfn=stats::shapiro.test, ...)

Value

Returns a list made up of the return value of a call to the function provided by the testfn argument, with added element RQR, itself a list including the randomized residuals. The default testfn, shapiro.test (except for datasets of more than 5000 fitted response values), returns “a list with class "htest"” which is therefore the class of the default result.

Arguments

object

A fit object inheriting from class "HLfit", as returned by spaMM's main fitting functions.

method

Character string; a method of test of goodness of fit.

plot.

Boolean: whether to produce a plot (effectively plot(object, res_type="RQR", which="mean") for RQRs as function of predicted values).

testfn

A function with the following interface: it takes the vector of values whose normality is assessed as first argument; and it returns a list (to which the RQR element will be added, see Value). There is no particular constraint on the contents of the returned list. For example, qqnorm is a possible testfn although it does not return a test.

...

Further arguments passed to testfn.

References

Dunn, K. P., and Smyth, G. K. (1996). Randomized quantile residuals. Journal of Computational and Graphical Statistics 5, 1-10.

Examples

Run this code
data("Orthodont", package = "nlme")
sp1 <- fitme(distance ~ age * Sex + (1 | Subject), data = Orthodont)
gof(sp1) #  classic toy example, but poor fit.                
gof(sp1, testfn=ks.test, y="pnorm")                

Run the code above in your browser using DataLab