On Aug 21, 2009, at 5:03 PM, Lucía Rueda wrote:
Hi,
I am comparing the observed and fitted values of my GAM model, which
includes the explanatory variables: longitude, depth, ssh, year and
month. When I compare observed and fitted values for longitude,
depth and ssh it works. But when I try to do it for month and year
(which are as factors in the GAM model) it doesn't work. My observed
and fitted values are exactly the same..
So then, you are complaining because it "works" but _unexpectedly_
well.
How is that possible? Thanks
If you have a balanced design in Year and it is the only covariate,
then that is precisely what should happen with any regression method:
> newdat <- data.frame(val=rnorm(40), cat=factor(1:4))
> aggregate(newdat$val, list(newdat$cat), mean)
Group.1 x
1 1 0.4972092
2 2 -0.1042936
3 3 0.1549305
4 4 -0.1500513
> lm(val~cat, newdat)
Call:
lm(formula = val ~ cat, data = newdat)
Coefficients:
(Intercept) cat2 cat3 cat4
0.4972 -0.6015 -0.3423 -0.6473
> 0.4972092 + coef(lm(val~cat, newdat))[2:4]
cat2 cat3 cat4
-0.1042937 0.1549304 -0.1500514
snipped output from OP
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.