Learn R Programming

itsadug (version 2.4.1)

dispersion: 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

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab