I was reading "The lm() function with categorical predictors", and am confused.
What does the regression model with a categorical predictor look like, with the following R code:
n = 30 sigma = 2.0 AOV.df <- data.frame(category = c(rep("category1", n) , rep("category2", n) , rep("category3", n)), j = c(1:n , 1:n , 1:n), y = c(8.0 + sigma*rnorm(n) , 9.5 + sigma*rnorm(n) , 11.0 + sigma*rnorm(n)) ) AOV.lm <- lm(y ~ category, data = AOV.df) summary(AOV.lm)
The output is:
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 8.4514 0.3405 24.823 < 2e-16 *** categorycategory2 0.8343 0.4815 1.733 0.0867 . categorycategory3 3.0017 0.4815 6.234 1.58e-08 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.865 on 87 degrees of freedom Multiple R-squared: 0.3225, Adjusted R-squared: 0.307 F-statistic: 20.71 on 2 and 87 DF, p-value: 4.403e-08
Is the model:
y = 8.4514 + 0.8343 for category 1,
y = 8.4514 + 0.8343 for category 2 or
y = 8.4514 + 3.0017 for cateogry 3?
What is the model if the R code looks like:
> X <- read.table("http://www.stat.umn.edu/geyer/5102/data/ex5-4.txt", header=T) > lm(y ~ color + x * color, data=X) Call: lm(formula = y ~ color + x * color, data = X) Coefficients: (Intercept) colorgreen colorred x colorgreen:x 13.96118 0.25243 6.10543 0.97241 0.07347 colorred:x 0.01962
Thanks!