[R] is that possible to graph 4 dimention plot

gcheer3 gcheer3 at gmail.com
Wed Oct 7 23:51:50 CEST 2009


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 at 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.




More information about the R-help mailing list