Help! I have convergence warnings

After all the hard work of collecting the data, thinking about appropriate models, formatting the data, you are finally running your model, this is it you are going to get the long awaited results and BOUM you get out such kind of message: ## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = ## control$checkConv, : Model … Continue reading Help! I have convergence warnings

Interpreting three-way interactions in R

A reader asked in a comment to my post on interpreting two-way interactions if I could also explain interaction between two categorical variables and one continuous variable. Rather than just dwelling on this particular case, here is a full blog post with all possible combination of categorical and continuous variables and how to interprete standard … Continue reading Interpreting three-way interactions in R

Plotting regression curves with confidence intervals for LM, GLM and GLMM in R

[Updated 22nd January 2017, corrected mistakes for getting the fixed effect estimates of factor variables that need to be averaged out] [Updated 14th July 2017, the function is now on github: https://github.com/Lionel68/Blog/tree/master/PlotFit any modifications to it will be posted there before updating the post. The function has 2 new functionalities: (i) taking into account offset … Continue reading Plotting regression curves with confidence intervals for LM, GLM and GLMM in R

Count data: To Log or Not To Log

Count data are widely collected in ecology, for example when one count the number of birds or the number of flowers. These data follow naturally a Poisson or negative binomial distribution and are therefore sometime tricky to fit with standard LMs. A traditional approach has been to log-transform such data and then fit LMs to … Continue reading Count data: To Log or Not To Log

A function to help graphical model checks of lm and ANOVA

As always a more colourful version of this post is available on rpubs. Even if LM are very simple models at the basis of many more complex ones, LM still have some assumptions that if not met would render any interpretation from the models plainly wrong. In my field of research most people were taught … Continue reading A function to help graphical model checks of lm and ANOVA

Using and interpreting different contrasts in linear models in R

When building a regression model with categorical variables with more than two levels (ie “Cold”, “Freezing”, “Warm”) R is doing internally some transformation to be able to compute regression coefficient. What R is doing is that it is turning your categorical variables into a set of contrasts, this number of contrasts is the number of … Continue reading Using and interpreting different contrasts in linear models in R

Checking (G)LM model assumptions in R

(Generalized) Linear models make some strong assumptions concerning the data structure: Independance of each data points Correct distribution of the residuals Correct specification of the variance structure Linear relationship between the response and the linear predictor For simple lm 2-4) means that the residuals should be normally distributed, the variance should be homogenous across the … Continue reading Checking (G)LM model assumptions in R