I'm using library(mgcv) I did a gam regression like this model <- gam(formula = y ~ s(x), family="binomial") Now I'd like to get 2 vectors x and z (with z=s(x)), so that I can implement the model outside R. How can I do this? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/How-to-get-curve-information-from-a-gam-model-tp4642785.html Sent from the R help mailing list archive at Nabble.com.
How to get curve information from a gam model
4 messages · David Winsemius, exu
On Sep 11, 2012, at 8:08 AM, exu wrote:
I'm using library(mgcv) I did a gam regression like this model <- gam(formula = y ~ s(x), family="binomial") Now I'd like to get 2 vectors x and z (with z=s(x)), so that I can implement the model outside R. How can I do this?
?predict.gam
David Winsemius, MD Alameda, CA, USA
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120911/ffa500f9/attachment.pl>
On Sep 11, 2012, at 12:10 PM, exu wrote:
Thanks for the response. But I'm relatively new to R, could you elaborate a bit? I tried P <-predict.gam(model,type=terms") But I'm having a hard time to trying to make sense of the resulting data.
And I'm having even greater difficulty because I cannot see any of it. (My prediction: It gave you linear predictors at your original data points, since you did not give it a newdata argument and you only have one term. I suspect that the chosen smoothing basis might have constructed a matrix output.) The help page ?mgcv::predict.gam has worked examples. In fact the first example illustrated what I thought you would be attempting. Working through all the examples on a help page is a great way to learn a function's capabilities.
David. > > Regards, > > Eugene Xu > LIBREMAX CAPITAL, LLC. > 830 Third Avenue > Suite 801 > NewYork, NY 10022 > (212) 612-1598 (O) > (908) 656-0306 (M) > (646) 380-2689 (F) > > From: David Winsemius [via R] [mailto:ml-node+s789695n4642822h94 at n4.nabble.com] > Sent: Tuesday, September 11, 2012 3:00 PM > To: Eugene Xu > Subject: Re: How to get curve information from a gam model > > > On Sep 11, 2012, at 8:08 AM, exu wrote: > >> I'm using library(mgcv) >> >> I did a gam regression like this >> >> model <- gam(formula = y ~ s(x), family="binomial") >> >> Now I'd like to get 2 vectors x and z (with z=s(x)), so that I can implement >> the model outside R. How can I do this? > > ?predict.gam > > -- > > David Winsemius, MD > Alameda, CA, USA > David Winsemius, MD Alameda, CA, USA