Subset rows within one predictor in GLM without disturb other

41 views Asked by At

I fit parasitoid abundance to two factors, flower availability and distance of the crop to flower.

Firstly, I fit separate glm equation:

glm(abundance ~ flower, data = data, family = poisson(link"log"))

which in this case, flower had two classes: "yes" and "no" the class "no" here regarded as control.

Then I fit abundance ~ distance

The data$distance had three classes (0,10, and 20), but in dataframe, this column contains additional classes from data$flower= "no" .

Consequently, I eliminated the rows containing flower = "No" (or control) by subsetting it, because it not make sense for me to include the distance observation from control data,

glm(abundance ~ distance, data = data, family = poisson(link"log"),
    subset = flower != "No")

The problem arises when I try to merge both factors into a single glm equation:

glm(abundance ~ flower + distance, data = data, family = poisson(link"log"))

how to pass the subset = flower != "No" , only to the variable data$distance without disturb other factor?

any suggestion?

0

There are 0 answers