I'm fairly new to R and have been trying to find the solution to this on here, but none of the advice has helped my specific case. I hope I'm not missing something obvious.
I want to fit a generalized linear mixed model to get an idea which radius has the most effect on species richness in my study (250 m, 500 m etc). This is the code I used. all the variables in the formula have been correctly assigned beforehand (but the columns have the same name in the original data, just to be extra sure) and I had no issues before I got to this specific line of code:
mod_cover.radii <- glmmTMB(
species.richness ~ forest.cover.250 +
forest.cover.500 +
forest.cover.750 + forest.cover.1000 +
forest.cover.1500,
data=bees, family=gaussian, na.action)
R tells me this line of code has invalid model formula in ExtractVars. I've tried different ways of writing the formula (using $, leaving out spaces), but I just can't figure out what's wrong here.
For some reason, I don't run into the same issue with this:
mod_complex <- glmmTMB(
species.richness ~ forest.cover.250 +
forest.edge.250 + size +
flower.species.richness,
data = bees, family = gaussian)
mod_nested <- glmmTMB(
species.richness ~ forest.cover.250 +
forest.edge.250,
data = bees, family = gaussian)
To be more specific: here is the result of
args(glmmTMB):You can see that the next argument after
familyisziformula, so the objectna.action(which in this case is an S3 generic method) gets passed asziformula.I guess it would be possible to try to detect this kind of typo, but the general case would be complicated.