Skip to content
Prev 165289 / 398506 Next

How can I get the interpolated data?

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:

?predict.lm

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  
example:

 > predict(CR.rsm, newdata=data.frame(x1=84,x2=171))
        1
80.58806

To get the entire range that you desire (and which the plotting  
function for GSM already produced) you need:

?expand.grid

z <- predict(CR.rsm, expand.grid(x1=seq(86.88,len=21),  
x2=seq(175,179,len=21)))

# or
data.frame(expand.grid(x1=seq(86.88,len=21), x2=seq(175,179,len=21)),
            z = predict(CR.rsm, expand.grid(x1=seq(86.88,len=21),  
x2=seq(175,179,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  
space.

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.