Description Usage Arguments Details Value Author(s) References Examples

View source: R/binon.diagnostics.R

Two techniques for evaluating the adequacy of the binary glm model used in `mlds`

, based on code in Wood (2006).

1 2 3 4 | ```
binom.diagnostics(obj, nsim = 200, type = "deviance", no.warn = TRUE)
## S3 method for class 'binom.diag'
plot(x, alpha = 0.025, breaks = "Sturges", ...)
``` |

`obj` |
Object of class ‘glm’ from a fit to data with a binary response. |

`nsim` |
number of bootstrap simulations to run. |

`type` |
character indicating type of residuals (defaults to “deviance”) to use in the simulations. |

`no.warn` |
logical indicating whether to suppress warnings from |

`x` |
object of class ‘binom.diag’, typically obtained from running |

`alpha` |
confidence level for envelope of the distribution of residuals |

`breaks` |
character indicating algorithm for choosing the breaks in the histogram of runs of residuals. Defaults to “Sturges”. See |

`...` |
additional parameters specifications for the empirical cdf plot |

Wood (2006) describes two diagnostics of the adequacy of a binary glm model based on analyses of residuals (see, p. 115, Exercise 2 and his solution on pp 346-347). The first one compares the empirical cdf of the deviance residuals to a bootstrapped confidence envelope of the curve. The second examines the number of runs in the sorted residuals with those expected on the basis of independence in the residuals, again using a resampling based on the models fitted values. The plot method generates two graphs, the first being the empirical cdf and the envelope. The second is a histogram of the number of runs from the bootstrap procedure with the observed number indicated by a vertical line. Currently, this only works if the ‘glm’ method is used to perform the fit and *not* the ‘optim’ method

`binom.diagnostics`

returns a list of class
‘binom.diag’ with components

`NumRuns ` |
integer vector giving the number of runs obtained for each simulation |

`resid ` |
numeric matrix giving the sorted deviance residuals in each column from each simulation |

`Obs.resid ` |
numeric vector of the sorted observed deviance residuals |

`ObsRuns ` |
integer giving the observed number of runs in the sorted deviance residuals |

`p ` |
numeric giving the proportion of runs in the simulation less than the observed value. |

Ken Knoblauch

Wood, SN *Generalized Additive Models: An Introduction with R*, Chapman \& Hall/CRC, 2006.

1 2 3 4 5 6 7 8 9 10 11 12 | ```
## Not run:
# generate psychometric function and binary data
levs <- 10^seq(-2, 0, len = 5)
psyF <- pnorm(levs, mean = 0.2, sd = 0.2)
Ntrials <- 100
Resp <- rbinom(Ntrials * length(psyF), 1, psyF)
d.df <- data.frame(resp = Resp, levs = levs)
fit.glm <- glm(resp ~ levs, binomial, d.df)
fit.diag <- binom.diagnostics(fit.glm)
plot(fit.diag)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.