dwarton / mvabund

mvabund updates
10 stars 14 forks source link

Categorical levels of L matrix in fourth corner model #118

Closed joshgsmith closed 1 year ago

joshgsmith commented 1 year ago

Hi team, I am cross-posting a question on StackOverflow related to the application of a fourth corner model in mvabund using categorical levels in the R matrix. Typically, the R matrix includes continuous environmental variables recorded at a site or observation, but is it appropriate to substitute R with categorical levels that describe the environment? I am specifically interested in the relationship between environmental periods (R; before, during, after) and their interaction with species traits (Q) on the relative abundance of taxa (L) in my multivariate community. The model runs when using categorical levels in R, and the results seem correct, but I am not sure what is going on under the hood in traitglm() and whether this is an appropriate use of the function.

Cheers!

dwarton commented 1 year ago

yes categorical variables are fine, how they are interpreted depends how they are estimated. The default, method="manyglm", will create dummy variables in the standard way (e.g. before-after, during-after), but method="glm1path" or similar will create a dummy variable for each level (before, during AND after) and will let the LASSO weave its magic to work out which to include.

If planning to text for a env*trait interaction I would recommend using latent variables to do this, there are known issues with the default anova.traitglm, but I haven't coded traitglm to do this as yet...