[R] Obtaining the transformation matrix from the "persp" function without plotting
Erin Hodgess
erinm.hodgess at gmail.com
Mon Jul 6 03:48:00 CEST 2015
Hello again.
I am looking at the "persp" function and would like to obtain the the
transformation matrix value that is output rather than the plot itself. I
will use this matrix to pass into 3D plotting functions.
This is what I am doing:
library(rsm)
library(rgl)
tool.df <- read.table("tool.txt",header=TRUE)
tool.code <- coded.data(tool.df,x1~(speed-150)/25,x2~(angle-20)/5)
tool.rsm <- rsm(life ~ SO(x1,x2), data=tool.code)
summary(tool.rsm)
Note: the tool.txt file is attached.
Update the model:
tool2.rsm = update(tool.rsm, . ~ . + I(x1^2*x2) + I(x1*x2^2) +
I(x1^2*x2^2))
Now plot:
persp3d.rsm(tool2.rsm, x1~x2, bounds=list(x1=c(-1,1),x2=c(-1,1)),
zlim=c(-6,6),
contour=TRUE)
Similarly, the persp3d.rsm.R file is attached.
As you can see, about half way in the persp3d.rsm function, I try to run a
regular persp function to get the transformation matrix:
transf2 = persp(dat$x, dat$y, dat$z, zlim = dat$zlim,
theta = theta, phi = phi, r = r, col = NA, border = NA,
box = FALSE, ...)
However, this produces a set of contour lines on a separate plot, rather
than the 3D plot.
I tried to used "plot=FALSE" in the persp function call, but that gave me a
warning message that the parameter did not exist.
This is from Russell Lenth's work. Thanks to him for the rsm package.
Thank you for any suggestions.
Sincerely,
Erin
--
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
-------------- next part --------------
speed angle life
125 15 -2
150 15 -3
175 15 2
125 15 -1
150 15 0
175 15 3
125 20 0
150 20 1
175 20 4
125 20 2
150 20 3
175 20 6
125 25 -1
150 25 5
175 25 0
125 25 0
150 25 6
175 25 -1
More information about the R-help
mailing list