I am connecting online manuals with old text to learn R (p. 182 - http://cran.r-project.org/doc/contrib/Faraway-PRA.pdf ). When I use the data from a package from R (as in the sample tutorials), there is no problem. However, when I use data from my text, I always end without an F value and warning.
Take a look:
in data.frame:
car.noise <- data.frame( speed = c("idle", "0-60mph", "over 60"), chrysler = c(41,65,76), bmw = c(45,67,72), ford = c(44,66,76), chevy = c(45,66,77), subaru = c(46,76,64))
check the data.frame file:
car.noise speed chrysler bmw ford chevy subaru 1 idle 41 45 44 45 46 2 0-60mph 65 67 66 66 76 3 over 60 76 72 76 77 64
melt the data.
mcar.noise<- melt(car.noise, id.var="speed")
check molten data.frame
> mcar.noise speed variable value 1 idle chrysler 41 2 0-60mph chrysler 65 3 over 60 chrysler 76 4 idle bmw 45 5 0-60mph bmw 67 6 over 60 bmw 72 7 idle ford 44 8 0-60mph ford 66 9 over 60 ford 76 10 idle chevy 45 11 0-60mph chevy 66 12 over 60 chevy 77 13 idle subaru 46 14 0-60mph subaru 76 15 over 60 subaru 64
run anova and get a warning:
> anova(lm(value ~ variable * speed, mcar.noise)) Analysis of Variance Table Response: value Df Sum Sq Mean Sq F value Pr(>F) variable 4 6.93 1.73 speed 2 2368.13 1184.07 variable:speed 8 205.87 25.73 Residuals 0 0.00 Warning message: In anova.lm(lm(value ~ variable * speed, mcar.noise)) : ANOVA F-tests on an essentially perfect fit are unreliable
Only 2 explanations I can come up with:
1: wrong coding 2: Text examples are too “perfect” for fitting as they try to show a clear example