On Fri, 2009-01-16 at 12:36 +0100, Robbert Langenberg wrote: > Dear, > > I am trying to get a prediction of my GAM on a response type. So that I > eventually get plots with the correct values on my ylab. > I have been able to get some of my GAM's working with the example shown > below: > * > model1<-gam(nsdall ~ s(jdaylitr2), data=datansd) > newd1 <- data.frame(jdaylitr2=(244:304)) > pred1 <- predict.gam(model1,newd1,type="response")*
Hi Robert, You want predictions for the covariate over range 244:304 for each of your 8 mapID's, yes? This is not tested, but why not something like: newd2 <- data.frame(jdaylitr2 = rep(seq(244, 304, length = 100), 8), mapID = rep(levels(datansd$mapID), each = 100)) Then use newd2 in your call to predict. I am assuming that datansd$mapID is a factor in the above. If it is just some other indicator variable, then perhaps something like: newd2 <- data.frame(jdaylitr2 = rep(seq(244, 304, length = 100), 8), mapID = rep(sort(unique(datansd$mapID)), each = 100)) Does that work for you? HTH G > > The problem I am encountering now is that I cannot seem to get it done for > the following type of model: > > *model3<-gam(y_no~s(day,by=mapID),family=binomial, data=mergeday)* > > My mapID consists of 8 levels of which I get individual plots with * > plot(model3)*. When I do predict with a newdata in it just like my first > model I need all columns to have the same amount of rows or else R will not > except it ofcourse, the col.names need to at least include day and mapID. > This way I can not get a prediction working for this GAM, I am confused > because of this part in the model: *s(day,by=mapID). > > *I have been reading through the GAM, an introduction with R book from Wood, > S. but could not find anything about predictions with BY in the model. > > I hope someone can help me out with this, > > Sincerely yours, > > Robbert Langenberg > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
signature.asc
Description: This is a digitally signed message part
______________________________________________ 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.