Vote count:
0
d = data.frame(
Temperature = c(rep("Cool", 6), rep("Warm", 6)),
Bact = c(rep("Bact 1", 2), rep("Bact 2", 2), rep("Bact 3", 2), rep("Bact 1", 2), rep("Bact 2", 2), rep("Bact 3", 2)),
Time = c(15.23,14.32,14.77,15.12,14.05,15.48,14.13,16.13,16.44,14.82,17.96,16.65)
)
I self-created a small data frame for a two-way ANOVA. I want to test a two-way ANOVA by
summary(aov(Time~Bact*Temperature, data=d))
Time is the dependent variable while Bact and Temperature are two categorical independent variables.
My goal is to learn and prove ANOVA can be done with a linear regression model. I want to convert convert my data into dummy variable and perform a linear regression on it. I expect I'll recover the same results.
The problem is that, I don't know how to convert my data frame into dummy variables such that it can be used in the lm() function.
asked 29 secs ago
Create dummy variable to do two-way ANOVA
Aucun commentaire:
Enregistrer un commentaire