+ Reply to Thread
Results 1 to 1 of 1

Thread: Comparing count data and cultivars in R

  1. #1
    Points: 6,415, Level: 52
    Level completed: 33%, Points required for next Level: 135

    Thanked 1 Time in 1 Post

    Comparing count data and cultivars in R

    I'm trying to analyse an experiment with this setup:

    A plant species with 16 different cultivars of 4-5 plants per cultivar (completely randomised within greenhouse, no blocks)
    An insect species that was allowed to spread freely for 4 days on the plants.
    The insect number per plant was counted.
    So I have cultivar and insect number as variables and want to know if the cultivars host significantly different insect numbers.

    My idea is to use a GLM with family quasi-poisson followed by an ANOVA (or better Analysis of Deviance) and a post-hoc test (which is possible with GLM as far as I know).

    Anyway I use R and my approach seems to suck (not really experienced with R so far).
    My code is very simple:

    fit1<-glm(numberinsects ~ cultivar, data=mydata, family=quasipoisson())
    anova(fit1, test="F")

    summary(glht(fit1, mcp(cultivar="Tukey")))

    Two problems occur:
    The GLM works, but I'm not sure if it's correct since the cultivars are coded as 1,2,3 etc and might be estimated as numeric variable and not a factor (I guess they should be) and so the results might be just an artefact. Not sure if this data-type issue is really a problem.

    Second, the post-hoc test ends up with an error:
    "Error in mcp2matrix(model, linfct = linfct) :
    Variable(s) ‘cultivar’ of class ‘integer’ is/are not contained as a factor in ‘model’.
    (if I change the variable type to numeric the same occurs).

    Can anybody help?
    Thank you very much!
    Last edited by hobglobin; 09-03-2014 at 02:19 PM. Reason: addition

+ Reply to Thread


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Advertise on Talk Stats