Hi all! I am a grad stat student and is fairly new in using R. I am doing a regression tree in one of my problem sets. I have already identified the cut-points (using Stata) for the regression. My problem is how to graph the fitted values of z against the independent variables x and y. Basically, I want to graph the following: z=87.67 if 0<x<=29 & 0<y<=48 z=75 if 0<x<=29 & 48<y<=62 z=67 if 29<x<=36 & 0<y<=62 z=56.71 if 36<x<=45 & 0<y<=62 z=40.8 if 36<x<=55 & 0<y<=62 I have some idea (still to be implemented) on how to graph them piece-wise using "persp". My question is this:how do one combine multiple 3D graphs (using "persp") in R? better yet, is there a way to graph them all in just one go? Any help would be welcome. Many thanks in advance. Cheers, Mykel -- "I am most anxious for liberties for our country... but I place as a prior condition the education of the people so that our country may have an individuality of its own and make itself worthy of liberties... " Jose Rizal,1896 [[alternative HTML version deleted]]
On 10/21/2009 9:03 AM, Michael Ralph M. Abrigo wrote:> Hi all! > I am a grad stat student and is fairly new in using R. I am doing a > regression tree in one of my problem sets. I have already identified the > cut-points (using Stata) for the regression. My problem is how to graph the > fitted values of z against the independent variables x and y. Basically, I > want to graph the following: > z=87.67 if 0<x<=29 & 0<y<=48 > z=75 if 0<x<=29 & 48<y<=62 > z=67 if 29<x<=36 & 0<y<=62 > z=56.71 if 36<x<=45 & 0<y<=62 > z=40.8 if 36<x<=55 & 0<y<=62 > I have some idea (still to be implemented) on how to graph them piece-wise > using "persp". My question is this:how do one combine multiple 3D graphs > (using "persp") in R? better yet, is there a way to graph them all in just > one go?I would define a function of x and y which evaluates to your fitted values, evaluate it on a grid, and then use persp. You might already have code to do this, or you might have to write it something like this: f <- function(x,y) { ifelse( 0 < x & x <= 29 & 0 < y & y <= 48, 87.67, ifelse( 0 < x & x <= 29 & y < 48 & y <= 62, 75, } etc. I leave the difficult problem of properly closing all the parentheses to you! Duncan Murdoch
Seemingly Similar Threads
- replacing elements of distance matrix
- Where can I find more information on the recent update to the 4.18.0-373 kernel
- persp graphs
- persp or wireframe 3D plot: how can I independently adjust linewidth of the 'surface' and framebox?
- 3D surface plot with wireframe or persp?