  Maybe I am missing something, but I do believe that the function
  dmvnorm is in the package 'mvtnorm'.
  If you take a look at ?dmvnorm you'll see that you must specify the
  variance/covariance, while dnorm takes the standard deviation, so your code should be
  > dnorm((-100:100)/100,mean(X),sd(X))
   
  

saverio vicario <saverio.vicario@yale.edu> wrote:
  Dear R community,
I was trying to estimate density at point zero of a multivariate 
distribution (9 dimensions) and for this I was using a multinormal 
approximation and the function dmvnorm , gtools package.
To have a sense of the error I tried to look the mismatch between a 
unidimensional version of my distribution and estimate density at 
point zero with function density, dmvnorm and dnorm.
At my big surprise dmvnorm and dnorm give very different result and 
dmvnorm match even better the theoritical distribution than the 
function density. How come?

#sampling from triangular distribution
X<-runif(10000)- runif(10000)
X<-matrix(X,length(X),1)

#dnorm estimate
plot(-100:100/100, dnorm((-100:100)/100,mean(X),var(X)),col=2,type="l")
#kernel density estimate
lines(density(X))
#dmvnorm estimate
res<-rep(NA,201);for ( i in 
-100:100){res[i+101]<-dmvnorm(i/100,mean(X),var(X))}
lines(-100:100/100, res,col=3)
#Theoretic triangular distribution
lines(-1:1,c(0,1,0),col=4)

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
  



		
---------------------------------

 Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.
	[[alternative HTML version deleted]]


