plotRunsProfile: Calculate runs test and plot profile plot. The output is a...

View source: R/plotRunsProfile.R

plotRunsProfileR Documentation

Calculate runs test and plot profile plot. The output is a plot of runs profiles (with p-value to indicate level of correlation)

Description

Calculate runs test and plot profile plot. The output is a plot of runs profiles (with p-value to indicate level of correlation)

Usage

plotRunsProfile(model, varlist, label = "", save = FALSE)

Arguments

model

Fitted model object (glm or gam)

varlist

Vector of covariate names (continous covariates only)

label

Label printed at the end of the plot name to identify it when save=TRUE.

save

(default=FALSE). Logical stating whether plot should be saved into working directory.

Value

Runs profile plots are returned for residuals ordered by each covariate in varlist, predicted value and index of observations (temporally).

The black line is the line of sequences of positive or negative residuals. The vertical lines are the change between a sequence of positive to negative residuals (or vice versa).

The p-values are from a runsTest and indicate whether there is correlation in the residuals (p<0.05) or independence (p>0.05). The test statistic determines the type of correlation (positive/negative) and the result printed at the bottom of the figure.

Note: if the covariate is discrete in nature (like the example below), there will be a lot of overplotting of runs. Some jittering occurs at each discrete value (for covariates with <= 25 unique values).

Examples

# load data
data(ns.data.re)

model<-gamMRSea(birds ~ observationhour + as.factor(floodebb) + as.factor(impact), 
            family='quasipoisson', data=ns.data.re)

plotRunsProfile(model, varlist=c('observationhour'))


lindesaysh/MRSea documentation built on May 11, 2024, 11:30 p.m.