R code demonstrating how to fit a logistic regression model, with a random intercept term, and how to use resampling-based hypothesis testing for inference..E092-001-S1

Ecological Archives

File list (downloads)

Description

David I. Warton & Francis K. C. Hui

School of Mathematics and Statistics

The University of New South Wales

NSW 2052 Australia

David.Warton@unsw.edu.au

glmmeg.R: R code demonstrating how to fit a logistic regression model, with a random intercept term, to randomly generated overdispersed binomial data.

boot.glmm.R: R code for estimating

P-values by applying the bootstrap to a GLMM likelihood ratio statistic.

glmm.R is some example R code which show how to fit a logistic regression model (with or without a random effects term) and use diagnostic plots to check the fit. The code is run on some randomly generated data, which are generated in such a way that overdispersion is evident. This code could be directly applied for your own analyses if you read into R a data.frame called ādatasetā, which has columns labelled āsuccessā and āfailureā (for number of binomial successes and failures), āspeciesā (a label for the different rows in the dataset), and where we want to test for the effect of some predictor variable called ālocationā. In other cases, just change the labels and formula as appropriate.

boot.glmm.R extends glmm.R by using bootstrapping to calculate P-values in a way that provides better control of Type I error in small samples. It accepts data in the same form as that generated in glmm.R.

ESA Publications | Ecological Archives | Permissions | Citation | Contacts