Christoph´s mixed R functions
This is a continuously updated file containing useful snippets of R code.
When fitting multinomial models with the nnet package (multinom() function), it is sometimes desirable to increase the number of weights (especially when there is a large number of response categories). This may happen for example in the analysis of next-generation sequencing data. The Anova() function from John Fox´s package "car" can not deal with the MaxNWts argument and hence cannot be used for multinomial models with user-specified maximum number of weights. Below, I provide a function called Anova.multinom2, which allows MaxNWts to be set to any desirded number.
Anova for models with user-specified weights, fitted with the multinom() function
In nonlinear regression situations, one often wishes to use power law functions of the form y=a+b*x^c. The following code allows starting estimates for this function to be estimated automatically.
Self-starting non-linear power law function in R
StepAICc function for linear, generalized linear and mixed models
selMod function for model selection in mixed models
Linear mixed models
Generalized linear mixed models
Time series analysis
Seed bank data analysis