[R] How can I get the interpolated data?
dwinsemius at comcast.net
Sun Dec 21 16:10:56 CET 2008
If you look at the CR.rsm object with str() you will see that it
inherits from the lm class of objects. Therefore the predict.lm method
will be available and if you further look at:
You see that all you need to do is give it a dataframe that has the
variables that match up with you model terms so this is a minimal
> predict(CR.rsm, newdata=data.frame(x1=84,x2=171))
To get the entire range that you desire (and which the plotting
function for GSM already produced) you need:
z <- predict(CR.rsm, expand.grid(x1=seq(86.88,len=21),
z = predict(CR.rsm, expand.grid(x1=seq(86.88,len=21),
Since you are narrowing the range for your prediction, it's possible
that you already realize that the original example plot was not just
interpolating but also extrapolating considerably beyond the available
data in places. That dataset only had 14 observations and rather
sketchy or non-existent in the extremal regions of the x1 cross x2
I greatly value the ability of the Hmisc/Design packages ability to
restrict estimation and plotting to only those regions where the data
will support estimates. I tried applying the perimeter function in
Harrell's packages to your example, but the plot.Design function
recognized that I was giving it a construct from a different package
and refused to play.
At any rate, HTH.
On Dec 21, 2008, at 7:33 AM, pinwheels wrote:
> I am a beginner of R.
> And I want to ask a question. If anybody would help me, thank you
> very much
> I want to plot something like a response surface, and I find the "rsm"
> Some commands are like this:
> #code head
> CR = coded.data(ChemReact, x1 ~ Time, x2 ~ Temp)
> CR.rsm = rsm(Yield ~ SO(x1,x2), data = CR)
> #code end
> What if I want the data interpolated, what should I do?
> For example:
> There is a data frame like:
> z<- ... # referring site(xa1,xa2) from the contour plotted above
> xa1 xa2 z
> 86 175 ???
> 86.1 175 ???
> ... ... ...
> 86.7 177.3 ???
> ... .... ...
> 88 179 ???
> or something alike.
> How could I get the z value(???) from the CR.rsm or the plotted
> View this message in context: http://www.nabble.com/How-can-I-get-the-interpolated-data--tp21114660p21114660.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help