Del 2 - Beginner's Guide to
Beginner's Guide to GLM and GLMM with R
A Frequentist and Bayesian Perspective for Ecologists
Häftad, 2013
679 kr
Slutsåld
This book presents Generalized Linear Models (GLM) and Generalized Linear Mixed Models (GLMM) based on both frequency-based and Bayesian concepts. Using ecological data from real-world studies, the text introduces the reader to the basics of GLM and mixed effects models, with demonstrations of binomial, gamma, Poisson, negative binomial regression, and beta and beta-binomial GLMs and GLMMs. The book uses the functions glm, lmer, glmer, glmmADMB, and also JAGS from within R. JAGS results are compared with frequentist results. R code to construct, fit, interpret, and comparatively evaluate models is provided at every stage. Otherwise challenging procedures are presented in a clear and comprehensible manner with each step of the modelling process explained in detail, and all code is provided so that it can be reproduced by the reader.
Produktinformation
- Utgivningsdatum2013-05-01
- Mått156 x 233 x undefined mm
- Vikt500 g
- SerieBeginner's Guide to
- FörlagHighland Statistics Ltd
- EAN9780957174139
Tillhör följande kategorier
- 1 INTRODUCTION TO GENERALIZED LINEAR MODELS1 1.1 LINEAR REGRESSION APPLIED ON FISHERIES DATA1 1.2 POISSON GLM7 1.2.1 Poisson distribution for count data7 1.2.2 Predictor function8 1.2.3 Linking the mean and the predictor function9 1.2.4 Maximum likelihood to estimate the parameters9 1.2.5 Application of Poisson GLM on the fisheries data11 1.2.6 Overdispersion19 1.2.7 Adding covariates23 1.2.8 Using the offset24 1.3 NEGATIVE BINOMIAL GLM26 1.3.1 Negative binomial distribution for count data26 1.3.2 Example of Negative binomial regression28 1.3.3 Heterogeneous Negative binomial regression34 1.3.4 A note on modelling under-dispersion36 1.4 BINOMIAL GLM FOR BINARY DATA36 1.4.1 Parasites in honeybee larvae36 1.4.2 Visualizing the data36 1.4.3 Defining the three steps of a binomial GLM38 1.4.4 Results for the bee data40 1.4.5 Likelihood function for a binomial GLM42 1.4.6 Other link functions42 1.5 BINOMIAL GLM FOR PROPORTIONAL DATA43 1.5.1 Binomial distribution43 1.5.2 Predictor function45 1.5.3 Link function45 1.5.4 Fitting the model in R45 1.6 OTHER DISTRIBUTIONS47 2 GENERALIZED LINEAR MODELLING APPLIED TO RED SQUIRREL DATA49 2.1 RED SQUIRRELS49 2.2 IMPORTING THE DATA50 2.3 DATA EXPLORATION51 2.3.1 Outliers51 2.3.2 Collinearity52 2.3.3 Relationships54 2.4 FITTING THE POISSON GLM IN R55 2.4.1 Specifying the model55 2.4.2 Execute the Poisson GLM in R55 2.4.3 Model validation57 2.5 FITTING THE NEGATIVE BINOMIAL GLM IN R60 2.5.1 Using the glm.nb function60 2.5.2 Heterogeneous negative binomial GLM63 2.6 BAYESIAN APPROACH - RUNNING THE POISSON GLM66 2.6.1 Obtaining and installing JAGS66 2.6.2 Specifying the data for JAGS67 2.6.3 Specifying the model for JAGS68 2.6.4 Specifying the initial values69 2.6.5 Parameters to store69 2.6.6 Running JAGS via R69 2.6.7 Generalizing the JAGS modelling code72 2.7 ASSESSING MIXING OF CHAINS74 2.7.1 Assess mixing of chains if R2jags is used74 2.8 MODEL VALIDATION76 2.8.1 Checking for overdispersion76 2.8.2 Obtaining Pearson residuals77 2.9 APPLYING A NEGATIVE BINOMIAL GLM IN JAGS79 2.10 MIXING OF CHAINS82 2.11 MODEL VALIDATION83 2.12 MODEL INTERPRETATION84 2.13 DISCUSSION87 2.14 WHAT TO PRESENT IN A PAPER87 3 GLM APPLIED TO PRESENCE-ABSENCE POLYCHAETA DATA89 3.1 MARINE BENTHIC DATA89 3.2 IMPORTING THE DATA AND HOUSEKEEPING90 3.3 DATA EXPLORATION91 3.4 BINARY GLM; A FREQUENTIST APPROACH94 3.4.1 Specifying the distribution and link function94 3.4.2 Specifying the predictor function95 3.4.3 Running the glm function96 3.4.4 Results of the glm function96 3.4.5 Model selection97 3.4.6 Results of the optimal model100 3.4.7 Model validation101 3.4.8 Visualizing the model102 3.5 FITTING A BERNOULLI GLM IN JAGS103 3.5.1 Specifying the data for JAGS103 3.5.2 JAGS modelling code104 3.5.3 Initial values and parameters to save105 3.5.4 Running JAGS from R105 3.5.5 JAGS results presented within R106 3.6 MODEL SELECTION USING AIC, DIC AND BIC IN JAGS107 3.7 MODEL INTERPRETATION110 3.8 DISCUSSION113 3.9 WHAT TO PRESENT IN A PAPER114 4 INTRODUCTION TO MIXED EFFECTS MODELS115 4.1 SPIDERS115 4.2 LINEAR REGRESSION APPLIED ON THE SPIDER DATA115 4.3 LINEAR MIXED EFFECTS MODELS118 4.3.1 Model formulation and interpretation118 4.3.2 Fitting a linear mixed effects model using lmer119 4.3.3 Analysis using lmer122 4.4 FITTING A LINEAR MIXED EFFECTS MODEL IN JAGS128 4.5 USING A VARIABLE AS A FIXED OR RANDOM TERM?131 4.6 RANDOM INTERCEPT AND SLOPE MODEL131 4.7 GENERALIZED LINEAR MIXED EFFECTS MODELS132 5 GLMM APPLIED ON HONEYBEE POLLINATION DATA133 5.1 HONEYBEES AND DANDELION POLLEN133 5.2 DATA DESCRIPTION AND IMPORTING THE DATA134 5.3 DATA EXPLORATION135 5.4 BUILDING UP A MODEL136 5.5 POISSON GLMM USING GLMER137 5.6 POISSON GLMM USING JAGS140 5.6.1 Data for JAGS140 5.6.2 JAGS modelling code141 5.6.3 Likelihood142 5.6.4 Priors142 5.6.5 Initial values144 5.6.6 Parameters to save144 5.6.7 Executing JAGS and obtaining results145 5.7 NEGATIVE BINOMIAL GLMM USING GLMMADMB146 5.8 NEGATIVE BINOMIAL GLMM USING JAGS147 5.8.1 Data for JAGS147 5.8.2 JAGS modelling code147 5.8.3 Initial values148 5.8.4 Parameters to save149 5.8.5 Executing JAGS and obtaining results149 5.8.6 Mixing of chains150 5.8.7 Model validation150 5.8.8 Model interpretation152 5.9 GLMM WITH AUTO-REGRESSIVE CORRELATION154 5.9.1 Simulate temporal correlated counts155 5.9.2 JAGS to estimate the Poisson GLM with AR correlation158 5.9.3 Multiple Poisson time series161 5.9.4 Poisson GLMM with AR correlation161 5.10 WHAT TO PRESENT IN A PAPER164 6 GLMM FOR STRICTLY POSITIVE DATA: BIOMASS OF RAINFOREST TREES165 6.1 RAINFOREST TREE SPECIES165 6.2 IMPORTING THE DATA AND HOUSEKEEPING167 6.3 DATA EXPLORATION168 6.3.1 Outliers168 6.3.2 Collinearity169 6.3.3 Relationships170 6.4 MULTIPLE LINEAR REGRESSION: A FREQUENTIST APPROACH173 6.5 GAMMA GLM USING A FREQUENTIST APPROACH175 6.5.1. Formulating the gamma GLM175 6.5.2 Scale and shape176 6.5.3 Visualizing the gamma distribution176 6.5.4 Different link functions178 6.5.5 Running the Gamma GLM using the glm function179 6.5.6 Scale confusion179 6.5.7 Identity link and inverse link function182 6.6 FITTING A GAMMA GLM USING JAGS183 6.6.1 Specifying the data for JAGS183 6.6.2 JAGS modelling code185 6.6.3 Priors185 6.6.4 Likelihood function185 6.6.5 Initial values and parameters to save186 6.6.6 Running JAGS from R186 6.6.7 JAGS results presented within R187 6.6.8 Model interpretation190 6.6.9 Model validation193 6.7 ADDING MORE COVARIATES TO THE GAMMA GLM IN JAGS195 6.8 GAMMA GLMM195 6.8.1 R code for a gamma GLMM in JAGS196 6.8.2 Results from JAGS for the gamma GLMM198 6.9 TRUNCATED GAUSSIAN LINEAR REGRESSION199 6.9.1 Zero trick to fit any statistical distribution in JAGS199 6.9.2 Multiple linear regression in JAGS with the zero trick200 6.9.3 Tobit model in JAGS202 6.9.4 Tobit model with random effects in JAGS205 6.10 DISCUSSION205 6.11 WHAT TO PRESENT IN A PAPER206 7 BINOMIAL, BETA-BINOMIAL, AND BETA GLMM APPLIED TO CHEETAH DATA207 7.1 STEREOTYPIC BEHAVIOURS IN CAPTIVE CHEETAHS207 7.2 IMPORTING THE DATA209 7.3 DATA EXPLORATION209 7.3.1 Outliers209 7.3.2 Collinearity210 7.4 BINOMIAL GLMM USING A FREQUENTIST APPROACH212 7.4.1 Standardizing covariates212 7.4.2 Binomial GLMM with random intercept zoo213 7.4.3 Executing the GLMM using the glmer function213 7.4.4 Overdispersion215 7.4.5 Binomial GLMM with observation level random intercept216 7.4.6 Visualization of results220 7.5 BINOMIAL GLMM WITH RANDOM INTERCEPT ZOO IN JAGS223 7.5.1 Data for JAGS223 7.5.2 JAGS modelling code for a binomial GLMM224 7.5.3 Results for the binomial GLMM226 7.5.4 Overdispersion226 7.6 BETA-BINOMIAL GLMM IN JAGS228 7.6.1 The Beta distribution228 7.6.2 From beta to beta-binomial distribution229 7.6.3 JAGS code for beta-binomial GLMM230 7.6.4 Beta-binomial GLMM results231 7.6.5 Model validation of the beta-binomial GLMM232 7.7 USING A BETA GLMM FOR PROPORTIONS234 7.8 COMPARING ESTIMATED PARAMETERS FROM ALL MODELS237 7.9 MODEL SELECTION FROM A FREQUENTIST POINT OF VIEW239 7.10 MODEL SELECTION FROM A BAYESIAN POINT OF VIEW241 7.10.1 Using the DIC, AIC and BIC242 7.10.2 Inclusion probabilities246 7.11 WHAT TO PRESENT IN A PAPER246 REFERENCES247 INDEX251 BOOKS BY HIGHLAND STATISTICS255 UPCOMING BOOKS IN 2013 AND 2014256