Re: [R] is that possible to graph 4 dimention plot
Hi I tried to do similar thing and did get great answer from Alberto Monteiro http://tolstoy.newcastle.edu.au/R/e4/help/08/01/0682.html However I finally managed to do it by slicing space by combination of image and contour together with putting numbers on contour. Then I used scizors and glue to put everything into 3 dimensions with colour and numbers indicating tha values. Regards Petr r-help-boun...@r-project.org napsal dne 12.10.2009 14:40:29: I'm basically put off by the question itself. Plotting a 4-dimensional graph is rather complicated if the world has only 3 dimensions. A 4-dimensional representation is typically a movie (with time as the 4th dimension). You could try to project a heatmap on a 3D surface graph, but I doubt this will make things much more clear. So the standard (and correct) way of solving this problem, is to think about a clever way to represent the needed information in less dimensions. Ryan gives some nice examples and tips of how to do that, but those are dismissed as not helpful. People on the list answer voluntarily. They do not like to be told that you don't think it will really help. Did you actually try it out? You certainly don't give that impression. Maybe you should have another look at it, and question your own approach to the problem as well. Keep it in mind for next time, you're not making yourself popular this way. Kind regards Joris On Sat, Oct 10, 2009 at 10:01 PM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 07/10/2009 5:50 PM, gcheer3 wrote: Thanks for your reply. But I don't think it will really help. My problem is as follows: I have 20 observations y - rnorm(N,mean= rep(th[1:2],N/2),sd=th[3]) I have a loglikelihood function for 3 variables mu-(mu1,mu2) and sig loglike - function(mu,sig){ temp-rep(0,length(y)) for (i in 1:(length(y))) { temp[i]-log((1/2)*dnorm(y[i],mu[1],sig)+(1/2)*dnorm(y[i],mu[2],sig))} return(sum(temp)) } for example mu-c(1,1.5) sig-2 loglike(mu,sig) [1] -34.1811 I am interested how mu[1], mu[2], and sig changes, will effect the loglikelihood surface. At what values of mu and sig will make loglikelihood the maximum and at what values of mu and sig will make loglikelihood has local max (smaller hills) and at what values of mu and sig the loglikelihood is flat , etc. I tried contour3d also, seems doesn't work I haven't seen any replies to this. One explanation would be that everyone was turned off (as I was) by the rude remark above. On this list, before saying that something doesn't work, it's polite to give a simple, nicely formatted, self-contained reproducible example of what went wrong, and to ask whether it is your error or an error in the package. Taking that approach will usually result in someone pointing out your error (and fixing your code); sometimes it will result in a package author agreeing it's a bug, and fixing it. Duncan Murdoch Thanks for any advice Ryan-50 wrote: Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help Thanks a lot Not sure what your data looks like, but you might also consider looking at a 2 dimensional version. See ?coplot for example: coplot(lat ~ long | depth * mag, data = quakes) Or you can make 2 or 3-dimensional plots using the lattice package conditioning on some of the variables - e.g. d ~ a | b * c, etc. If a, b, and c are continuous, you can use equal.count. Here is an uninteresting example, considering a, b, and c as points along a grid: a - b - c - seq(1:10) dat - data.frame(expand.grid(a, b, c)) names(dat) - letters[1:3] dat$d - with(dat, -(a-5)^2 - (b-5)^2 - (c-5)^2) library(lattice) # 2-d: xyplot(d ~ a | equal.count(b)*equal.count(c), data=dat, type=l) # etc. # 3-d: contourplot(d ~ a * b | equal.count(c), data=dat) wireframe(d ~ a * b | equal.count(c), data=dat) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,
Re: [R] is that possible to graph 4 dimention plot
I'm basically put off by the question itself. Plotting a 4-dimensional graph is rather complicated if the world has only 3 dimensions. A 4-dimensional representation is typically a movie (with time as the 4th dimension). You could try to project a heatmap on a 3D surface graph, but I doubt this will make things much more clear. So the standard (and correct) way of solving this problem, is to think about a clever way to represent the needed information in less dimensions. Ryan gives some nice examples and tips of how to do that, but those are dismissed as not helpful. People on the list answer voluntarily. They do not like to be told that you don't think it will really help. Did you actually try it out? You certainly don't give that impression. Maybe you should have another look at it, and question your own approach to the problem as well. Keep it in mind for next time, you're not making yourself popular this way. Kind regards Joris On Sat, Oct 10, 2009 at 10:01 PM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 07/10/2009 5:50 PM, gcheer3 wrote: Thanks for your reply. But I don't think it will really help. My problem is as follows: I have 20 observations y - rnorm(N,mean= rep(th[1:2],N/2),sd=th[3]) I have a loglikelihood function for 3 variables mu-(mu1,mu2) and sig loglike - function(mu,sig){ temp-rep(0,length(y)) for (i in 1:(length(y))) { temp[i]-log((1/2)*dnorm(y[i],mu[1],sig)+(1/2)*dnorm(y[i],mu[2],sig))} return(sum(temp)) } for example mu-c(1,1.5) sig-2 loglike(mu,sig) [1] -34.1811 I am interested how mu[1], mu[2], and sig changes, will effect the loglikelihood surface. At what values of mu and sig will make loglikelihood the maximum and at what values of mu and sig will make loglikelihood has local max (smaller hills) and at what values of mu and sig the loglikelihood is flat , etc. I tried contour3d also, seems doesn't work I haven't seen any replies to this. One explanation would be that everyone was turned off (as I was) by the rude remark above. On this list, before saying that something doesn't work, it's polite to give a simple, nicely formatted, self-contained reproducible example of what went wrong, and to ask whether it is your error or an error in the package. Taking that approach will usually result in someone pointing out your error (and fixing your code); sometimes it will result in a package author agreeing it's a bug, and fixing it. Duncan Murdoch Thanks for any advice Ryan-50 wrote: Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help Thanks a lot Not sure what your data looks like, but you might also consider looking at a 2 dimensional version. See ?coplot for example: coplot(lat ~ long | depth * mag, data = quakes) Or you can make 2 or 3-dimensional plots using the lattice package conditioning on some of the variables - e.g. d ~ a | b * c, etc. If a, b, and c are continuous, you can use equal.count. Here is an uninteresting example, considering a, b, and c as points along a grid: a - b - c - seq(1:10) dat - data.frame(expand.grid(a, b, c)) names(dat) - letters[1:3] dat$d - with(dat, -(a-5)^2 - (b-5)^2 - (c-5)^2) library(lattice) # 2-d: xyplot(d ~ a | equal.count(b)*equal.count(c), data=dat, type=l) # etc. # 3-d: contourplot(d ~ a * b | equal.count(c), data=dat) wireframe(d ~ a * b | equal.count(c), data=dat) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is that possible to graph 4 dimention plot
On 07/10/2009 5:50 PM, gcheer3 wrote: Thanks for your reply. But I don't think it will really help. My problem is as follows: I have 20 observations y - rnorm(N,mean= rep(th[1:2],N/2),sd=th[3]) I have a loglikelihood function for 3 variables mu-(mu1,mu2) and sig loglike - function(mu,sig){ temp-rep(0,length(y)) for (i in 1:(length(y))) { temp[i]-log((1/2)*dnorm(y[i],mu[1],sig)+(1/2)*dnorm(y[i],mu[2],sig))} return(sum(temp)) } for example mu-c(1,1.5) sig-2 loglike(mu,sig) [1] -34.1811 I am interested how mu[1], mu[2], and sig changes, will effect the loglikelihood surface. At what values of mu and sig will make loglikelihood the maximum and at what values of mu and sig will make loglikelihood has local max (smaller hills) and at what values of mu and sig the loglikelihood is flat , etc. I tried contour3d also, seems doesn't work I haven't seen any replies to this. One explanation would be that everyone was turned off (as I was) by the rude remark above. On this list, before saying that something doesn't work, it's polite to give a simple, nicely formatted, self-contained reproducible example of what went wrong, and to ask whether it is your error or an error in the package. Taking that approach will usually result in someone pointing out your error (and fixing your code); sometimes it will result in a package author agreeing it's a bug, and fixing it. Duncan Murdoch Thanks for any advice Ryan-50 wrote: Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help Thanks a lot Not sure what your data looks like, but you might also consider looking at a 2 dimensional version. See ?coplot for example: coplot(lat ~ long | depth * mag, data = quakes) Or you can make 2 or 3-dimensional plots using the lattice package conditioning on some of the variables - e.g. d ~ a | b * c, etc. If a, b, and c are continuous, you can use equal.count. Here is an uninteresting example, considering a, b, and c as points along a grid: a - b - c - seq(1:10) dat - data.frame(expand.grid(a, b, c)) names(dat) - letters[1:3] dat$d - with(dat, -(a-5)^2 - (b-5)^2 - (c-5)^2) library(lattice) # 2-d: xyplot(d ~ a | equal.count(b)*equal.count(c), data=dat, type=l) # etc. # 3-d: contourplot(d ~ a * b | equal.count(c), data=dat) wireframe(d ~ a * b | equal.count(c), data=dat) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is that possible to graph 4 dimention plot
Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help Thanks a lot Not sure what your data looks like, but you might also consider looking at a 2 dimensional version. See ?coplot for example: coplot(lat ~ long | depth * mag, data = quakes) Or you can make 2 or 3-dimensional plots using the lattice package conditioning on some of the variables - e.g. d ~ a | b * c, etc. If a, b, and c are continuous, you can use equal.count. Here is an uninteresting example, considering a, b, and c as points along a grid: a - b - c - seq(1:10) dat - data.frame(expand.grid(a, b, c)) names(dat) - letters[1:3] dat$d - with(dat, -(a-5)^2 - (b-5)^2 - (c-5)^2) library(lattice) # 2-d: xyplot(d ~ a | equal.count(b)*equal.count(c), data=dat, type=l) # etc. # 3-d: contourplot(d ~ a * b | equal.count(c), data=dat) wireframe(d ~ a * b | equal.count(c), data=dat) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is that possible to graph 4 dimention plot
Thanks for your reply. But I don't think it will really help. My problem is as follows: I have 20 observations y - rnorm(N,mean= rep(th[1:2],N/2),sd=th[3]) I have a loglikelihood function for 3 variables mu-(mu1,mu2) and sig loglike - function(mu,sig){ temp-rep(0,length(y)) for (i in 1:(length(y))) { temp[i]-log((1/2)*dnorm(y[i],mu[1],sig)+(1/2)*dnorm(y[i],mu[2],sig))} return(sum(temp)) } for example mu-c(1,1.5) sig-2 loglike(mu,sig) [1] -34.1811 I am interested how mu[1], mu[2], and sig changes, will effect the loglikelihood surface. At what values of mu and sig will make loglikelihood the maximum and at what values of mu and sig will make loglikelihood has local max (smaller hills) and at what values of mu and sig the loglikelihood is flat , etc. I tried contour3d also, seems doesn't work Thanks for any advice Ryan-50 wrote: Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help Thanks a lot Not sure what your data looks like, but you might also consider looking at a 2 dimensional version. See ?coplot for example: coplot(lat ~ long | depth * mag, data = quakes) Or you can make 2 or 3-dimensional plots using the lattice package conditioning on some of the variables - e.g. d ~ a | b * c, etc. If a, b, and c are continuous, you can use equal.count. Here is an uninteresting example, considering a, b, and c as points along a grid: a - b - c - seq(1:10) dat - data.frame(expand.grid(a, b, c)) names(dat) - letters[1:3] dat$d - with(dat, -(a-5)^2 - (b-5)^2 - (c-5)^2) library(lattice) # 2-d: xyplot(d ~ a | equal.count(b)*equal.count(c), data=dat, type=l) # etc. # 3-d: contourplot(d ~ a * b | equal.count(c), data=dat) wireframe(d ~ a * b | equal.count(c), data=dat) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/is-that-possible-to-graph-4-dimention-plot-tp25741135p25795063.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is that possible to graph 4 dimention plot
sorry for y y=rnorm(20,mean= rep(th[1:2],10),sd=th[3]) th=c(0, 0.5, 1) gcheer3 wrote: Thanks for your reply. But I don't think it will really help. My problem is as follows: I have 20 observations y - rnorm(N,mean= rep(th[1:2],N/2),sd=th[3]) I have a loglikelihood function for 3 variables mu-(mu1,mu2) and sig loglike - function(mu,sig){ temp-rep(0,length(y)) for (i in 1:(length(y))) { temp[i]-log((1/2)*dnorm(y[i],mu[1],sig)+(1/2)*dnorm(y[i],mu[2],sig))} return(sum(temp)) } for example mu-c(1,1.5) sig-2 loglike(mu,sig) [1] -34.1811 I am interested how mu[1], mu[2], and sig changes, will effect the loglikelihood surface. At what values of mu and sig will make loglikelihood the maximum and at what values of mu and sig will make loglikelihood has local max (smaller hills) and at what values of mu and sig the loglikelihood is flat , etc. I tried contour3d also, seems doesn't work Thanks for any advice Ryan-50 wrote: Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help Thanks a lot Not sure what your data looks like, but you might also consider looking at a 2 dimensional version. See ?coplot for example: coplot(lat ~ long | depth * mag, data = quakes) Or you can make 2 or 3-dimensional plots using the lattice package conditioning on some of the variables - e.g. d ~ a | b * c, etc. If a, b, and c are continuous, you can use equal.count. Here is an uninteresting example, considering a, b, and c as points along a grid: a - b - c - seq(1:10) dat - data.frame(expand.grid(a, b, c)) names(dat) - letters[1:3] dat$d - with(dat, -(a-5)^2 - (b-5)^2 - (c-5)^2) library(lattice) # 2-d: xyplot(d ~ a | equal.count(b)*equal.count(c), data=dat, type=l) # etc. # 3-d: contourplot(d ~ a * b | equal.count(c), data=dat) wireframe(d ~ a * b | equal.count(c), data=dat) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/is-that-possible-to-graph-4-dimention-plot-tp25741135p25795078.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] is that possible to graph 4 dimention plot
Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help Thanks a lot -- View this message in context: http://www.nabble.com/is-that-possible-to-graph-4-dimention-plot-tp25741135p25741135.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is that possible to graph 4 dimention plot
On 04/10/2009 3:14 PM, gcheer3 wrote: Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help contour3d in the misc3d package can do something like that. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is that possible to graph 4 dimention plot
How about : google r graph gallery 4d ? abs On Sun, Oct 4, 2009 at 3:31 PM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 04/10/2009 3:14 PM, gcheer3 wrote: Suppose there are 4 variables d is a function of a , b and c I want to know how a, b and c change will make d change It will be straightforward to see it if we can graph the d surface if d is only a function of a and b, I can use 'persp' to see the surface of d. I can easily see at what values of a and b, d will get the maxium or minium or multiple modes, etc But for 4 dimention graph, is there a way to show the surface of d Will use color help contour3d in the misc3d package can do something like that. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.