An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20101116/d29b97e7/attachment.pl>
declaring the variables
4 messages · Michael Larkin, Andrew Dolman, Petar Milin
Hi Michael, You will need to use a different function than glm(). Something from an additional R package such as nlme or lme4. There's some information here: http://glmm.wikidot.com/ With glmm() from lme4 your model specification would look something like this: fish <- glmm(Catch ~ Season + Tide + (1|Angler), family=gaussian(identity), data=fishcatch) Assuming Catch is appropriately modelled as gaussian that is. andydolman at gmail.com
On 17 November 2010 05:57, Michael Larkin <mlarkin at rsmas.miami.edu> wrote:
I am running a GLM with catch data from a fishery. ?I understand how to run a GLM in R. ?What I don't understand is how to declare the types of variables that I have. ?For example, I am modeling catch with several different types of variables. ?Here are details on my variables: Variable ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Type comment Anglers ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? random factor ? ? ? ? ? ? ? ? ? I have the names of over 100 anglers. Season ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fixed factors ? ? ? ? ? ? ? ? ? ? ? I broke it up into the 4 seasons Tide phase ? ? ? ? ? ? ? ? ? ? ? ? ?Continuous variable ? ? ? ?I have the proportion of the tide phase during the fishing event My R code for the GLM is: fish <- glm(Catch ~ Angler +Season + Tide, family=gaussian(identity), data=fishcatch) However, how do declare the types of variables used in the model? ?For example, how do I declare that the angler variable is a random factor? Any help would be greatly appreciated. Mike ? ? ? ?[[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Hello! Maybe I am missing something, but I think you should first check how R "understands" your data structure: > str(<data-frame-name>) From this you can explitily define type that you need/want, like: > <data-frame-name>$Anglers = as.factor(<data-frame-name>$Anglers) > <data-frame-name>$Season = as.factor(<data-frame-name>$Season) > <data-frame-name>$Tide.phase = as.numeric(<data-frame-name>$Tide.phase) Also, you can use: as.logical(), as.integer(), even as.character() and some others. Again, I apologize if I understood you problem wrongly, but this seems to me a solution. Best, PM
On 17/11/10 05:57, Michael Larkin wrote:
I am running a GLM with catch data from a fishery. I understand how to run a GLM in R. What I don't understand is how to declare the types of variables that I have. For example, I am modeling catch with several different types of variables. Here are details on my variables: Variable Type comment Anglers random factor I have the names of over 100 anglers. Season fixed factors I broke it up into the 4 seasons Tide phase Continuous variable I have the proportion of the tide phase during the fishing event My R code for the GLM is: fish<- glm(Catch ~ Angler +Season + Tide, family=gaussian(identity), data=fishcatch) However, how do declare the types of variables used in the model? For example, how do I declare that the angler variable is a random factor? Any help would be greatly appreciated. Mike [[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Sorry, again, mail went before I concluded. As to second part:
fish<- glm(Catch ~ Angler +Season + Tide, family=gaussian(identity), data=fishcatch) However, how do declare the types of variables used in the model? For example, how do I declare that the angler variable is a random factor?
Then, you should use something like: fish <- lmer(Catch ~ Season + Tide + (1|Angler), data=fishcatch) In lmer(), Gaussian is the default and linear mixed-model is fit, but you can also use 'binomial', 'poisson' etc, and then generalized linear mixed-model is fit. Best, PM