dispersion: Calculate the dispersion of the residuals

View source: R/inspect.R

dispersionR Documentation

Calculate the dispersion of the residuals

Description

Calculate the dispersion of the residuals

Usage

dispersion(model)

Arguments

model

A fitted regression model (using gam, or bam).

Value

Numeric value: dispersion of the residuals.

See Also

Other Functions for model inspection: fvisgam(), gamtabs(), inspect_random(), plot_data(), plot_parametric(), plot_smooth(), plot_topo(), pvisgam()

Examples

trial <- function(f=.95){
    x <- rep(1-f,101)
    x[round(runif(1,1,50)):length(x)] <- f
    return(rbinom(101,1,x))
}
set.seed(123)
dat <- data.frame(Time=rep( seq(0,1,length=101),100),
    y = unlist(replicate(100, trial(f=1), simplify=FALSE)),
    stringsAsFactors=FALSE)
# under dispersion:
gam1 <- gam(y ~ s(Time), data=dat, family=binomial)
summary(gam1)
dispersion(gam1)
# but not here:
gam2 <- gam(y ~ 1, data=dat, family=binomial)
summary(gam2)
dispersion(gam2)
# and not here:
dat <- data.frame(Time=rep( seq(0,1,length=101),100),
    y = unlist(replicate(100, trial(f=.75), simplify=FALSE)),
    stringsAsFactors=FALSE)
gam3 <- gam(y ~ s(Time), data=dat, family=binomial)
summary(gam3)
dispersion(gam3)


itsadug documentation built on June 17, 2022, 5:05 p.m.