1
$\begingroup$

I am currently running some GLM's looking at different carnivore species and environmental variables. One of my variables is habitat which I have coded from 1-6. I ran the models with Poisson, but I think I need to use a different model as it may be assuming my habitat data is continuous like my other variables. Can anybody please tell me what type of model I should be using that can account for both numerical and categorical data sets combined (if that makes sense).

    glm1<-glm(Jaguar_RAI~Habitat+Dist_river+Human_RAI+Fox_RAI+
    Pu‌​ma_RAI + Tayra_RAI+Ocelot_RAI,family = poisson()) 
    summary(glm1) 
    plot(glm1) 
    #now test the sig relationship with spearmans because it's non parametric 
    cor.test(Jaguar_RAI,Habitat,method = "spearman")
$\endgroup$
  • $\begingroup$ Is the variable stored as a factor? Also it would be good to add a small example similar to your code. $\endgroup$ – Elin Sep 9 '17 at 15:48
  • $\begingroup$ No I just checked, its not a factor $\endgroup$ – sarah_finnegan Sep 9 '17 at 15:52
  • $\begingroup$ Well that is the problem. In your formula wrap it with as.factor(). $\endgroup$ – Elin Sep 9 '17 at 15:54
  • $\begingroup$ glm1<-glm(Jaguar_RAI~Habitat+Dist_river+Human_RAI+Fox_RAI+Puma_RAI +Tayra_RAI+Ocelot_RAI,family = poisson()) summary(glm1) plot(glm1) #now test the sig relationship with spearmans because its non parametric cor.test(Jaguar_RAI,Habitat,method = "spearman") This is one part of the code, I am looking at 5 species independently.. all other varibles are numbers, but habitat numbers relates to a category $\endgroup$ – sarah_finnegan Sep 9 '17 at 15:54
  • 1
    $\begingroup$ In R categorical variables are factors. So as.factor(Habitat) . $\endgroup$ – Elin Sep 9 '17 at 15:59