3
$\begingroup$

I have this data below which I am analyzing using R. First, I am trying to find which predictors (chem1, chem2 and chem3) have effects on yield for this data. I did this model test below and found that chem3 has significant effect on yield.

## model test
model1 <- glm(yield ~ chem1, data = cc, family=gaussian())
summary(model1)
model2 <- glm(yield ~ chem2,data = cc, family=gaussian())
summary(model2)
model3 <- glm(yield ~ chem3,data = cc, family=gaussian())
summary(model3)  
# this has significant effect
> summary(model3)$coef
               Estimate  Std. Error   t value     Pr(>|t|)
(Intercept) 3488.033686 342.8288848 10.174270 7.538577e-08
chem3          1.970147   0.4943079  3.985667 1.353573e-03
model4 <- glm(yield ~ chem1 + chem2 + chem3 + chem1 * chem2 * chem3,data = cc, family=gaussian())
summary(model4)
model5 <- glm(yield ~ chem1 + chem2 + chem3,data = cc, family=gaussian())
summary(model5)  
#run an anovva on the 5 different models to find the best model
anov <- anova(model1,model2,model3,model4, model5,test='Chisq')
anov

Now the question I am trying to answer is that whether any of the four treatments have significant effect on the yield. There are four treatments in my data and would like to know which treatment has significant effect on yield. How do I determine this using R?

Here is my data in R:

cc<- structure(list(Location = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Monmouth", 
"Urbana"), class = "factor"), treatment = structure(c(1L, 1L, 
1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), .Label = c("CC", 
"CCS", "CS", "SCS"), class = "factor"), block = c(1L, 2L, 3L, 
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), chem1 = c(1.600946, 
1.474084, 1.433078, 1.532492, 1.198667, 1.193193, 1.214941, 1.360981, 
1.853056, 1.690117, 1.544357, 1.825132, 1.695409, 1.764123, 1.903743, 
1.538684), chem2 = c(6212.631579, 5641.403509, 4392.280702, 7120.701754, 
5305.964912, 4936.842105, 5383.157895, 6077.894737, 5769.122807, 
5016.842105, 5060.350877, 5967.017544, 5576.842105, 5174.035088, 
5655.438596, 5468.77193), chem3 = c(810.3024, 835.5242, 856.206, 
759.8589, 726.2298, 792.6472, 724.7165, 699.3266, 500.9153, 634.8698, 
637.9536, 648.8814, 641.0357, 623.3822, 555.2834, 520.8119), 
    yield = c(5156L, 5157L, 5551L, 5156L, 4804L, 4720L, 4757L, 
    5021L, 4826L, 4807L, 4475L, 4596L, 4669L, 4588L, 4542L, 4592L
    )), row.names = c(NA, 16L), class = "data.frame")

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.