[R] Multivariate Normal: Help wanted!
Dennis Murphy
djmuser at gmail.com
Wed Aug 31 03:38:43 CEST 2011
Hi:
It's polite to mention from which package you extract certain
functions. For example, the function dmvnorm() exists in at least the
following packages (following a search from the sos package):
mixtools, emdbook, klaR and mvtnorm, not to mention related functions
in three other packages. Since I can't discern which package your
dmvnorm() comes from, I am loath to test your code.
However, if the objective is to apply the MV.MSE function to all
elements of the list EP, then try (untested)
EPres <- lapply(EP, function(x) MV.MSE(10, x, c(.25, .25), diag(c(1, 2))))
HTH,
Dennis
On Tue, Aug 30, 2011 at 3:01 PM, meddee <meddee1000 at gmail.com> wrote:
> I have the following function, a MSE calc based on some Multivariate normals:
>
> MV.MSE<-function(n,EP,X,S){
> (dmvnorm(X,mean=rep(0,2),I+S+EP)-dmvnorm(X,mean=rep(0,2),I+S))^2
> +
> 1/n*(dmvnorm(X,mean=rep(0,2),1+S+EP/2)*det(4*pi*EP)^-.5-
> (dmvnorm(X,mean=rep(0,2),I+S+EP ))^2)}
>
> I can get the MV.MSE for given values of the function e.g
> MV.MSE(10,diag(0.5,2),c(.25,.25),diag(1,2))
>
> But I would like to how MV.MSE varies for different EP matrices. I tried
> this,
> ep<-seq(0,10,by=.01)
> EP <- lapply(ep, function(d) diag(d, 2)) # thanks Joshua, Mark!
> MV.MSE(10,EP,c(.25,.25),diag(1,2))
>
> but got this error: *Error in diag(1, 2) + S + EP : non-numeric argument to
> binary operator*
>
> Any help would be most welcome!
>
> Meddee
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Multivariate-Normal-Help-wanted-tp3779831p3779831.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list