[R] ANOVA Lack of fit test results not matching
Bart Joosen
bartjoosen at hotmail.com
Tue Apr 24 10:53:25 CEST 2012
Hi,
we have a validated program to do our calculations, but sometime I want to
use R to do some quick statistical calculations.
But for our linearity test, I can't reproduce in R.
Suppose the following data set:
dat <-
structure(list(Level = structure(c(1L, 2L, 3L, 4L, 5L, 1L, 2L,
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), .Label = c("A", "B", "C", "D",
"E"), class = "factor"), x = c(1.6882, 1.8992, 2.1103, 2.3213,
2.5323, 1.791, 1.99, 2.189, 2.388, 1.592, 1.6, 1.8, 2, 2.2, 2.4
), y = c(845467.4698, 951160.9668, 1059023.406, 1164772.671,
1267586.471, 885310.2247, 980398.3656, 1078975.303, 1174925.069,
785042.962, 802448.3644, 900011.1168, 998232.6022, 1098189.112,
1200127.806)), .Names = c("Level", "x", "y"), row.names = c(NA,
-15L), class = "data.frame")
Now I wanted to do a Lack of fit test (in our program: residual ANOVA).
I did some searching, and found: anova(lm(y~x + Level, dat)) and look at the
p-value for Level.
But the resulting value (F value 0.0704) doesn't corresponds with the F
value from our program (0.0599).
Also the MS and SS values don't match.
As it is called residual ANOVA, I tried to fit a model (mod <- lm(y~x,dat))
and then did a regression of Level agains the residuals of the model: anova
(lm(resid(mod)~dat$Level)).
But again no match. Also the degrees of freedom dont match anywhere (in our
program: 3).
Here is the table from our program, any ideas about how to come to this
result?
Source SS DF MS F-Ratio p-Value
1 Total 8.601108e+008 13 66162368.020
2 Error (Intra) 8.449211e+008 10 84492107.090
3 Model (Inter) 1.518971e+007 3 5063237.787 0.059926 0.979704
Thanks
Bart
--
View this message in context: http://r.789695.n4.nabble.com/ANOVA-Lack-of-fit-test-results-not-matching-tp4582774p4582774.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list