[R] Question about predict function

Thomas L Jones DrJones at alum.MIT.edu
Wed Dec 27 19:43:39 CET 2006


I am working with a non-parametic smoothing operation using a 
Generalized Additive Model. It is a bivariate data set. I know how to 
do the smooth, and out comes a nice smooth curve.

Now I want to find the value of the smoothed curve for several values 
of x (the abscissa). This can be done (please correct me if I am 
wrong) by using the predict.gam function. You feed the predict.gam 
function a data frame, telling it what you want.

Let's start with the predict.gam function. Are you supposed to be able 
to look up how to use it? E.g., what goes into the various columns of 
the data frame? I do have a working function call for predict. It 
says:

pred_out <- predict (mod, data.frame (x = x), type = "response")

(mod is the model)

Now, if you tell me that x = x, I will believe you. But what is meant 
by "data.frame (x = x)", I know not.

Or would it better to call the class, names, and str functions, using 
some well chosen objects?

Tom Jones



More information about the R-help mailing list