Thanks so much. This works perfectly for me.

Sun

On Mon, Apr 19, 2010 at 1:34 PM, Hao Yu <hyu@stats.uwo.ca> wrote:

> The first argument of mpi.parLapply is x which is mixed with your x.
> Change your x to a different one and your codes should work.
>
> Hao
>
> Xiaochun Sun wrote:
> > Hi,
> >
> > I am using Rmpi and met a problem about using Rmpi to call a function to
> > do
> > matrix manipulation. I can run the following code using lapply but when I
> > use mpi.parLapply the error pop out and saying
> > "Error in x %*% b : non-conformable arguments\n"
> >
> > Could anyone help me handle the problem? Thanks in advance.
> >
> > Sun
> >
> >
> >
> > below is the code:
> > n.chains = 2
> > ib <- runif(n.chains)
> > b <- t(matrix(ib,nrow=n.chains,ncol=500))
> > isbeta <- matrix(runif(n.chains,0,0.01),nrow=ncol(x),ncol=n.chains)
> > niter=50
> > y<- rep(1,500)
> > x<- matrix(1,500,500)
> > l <- rep(1,500)
> >
> > Gibbs <- function(y,x,l,isbeta,b,niter){
> >    ll <- t(l) %*% l
> >    XX <- t(x) %*% x
> >    y_star <- y - x %*% b
> >    lY <- t(l) %*% y_star
> >    XY <- t(x) %*% y
> >    ibeta_covar=solve(diag(sbeta))
> > }
> >
> > library(Rmpi)
> > mpi.spawn.Rslaves()
> >
> > bbb_1<- mpi.parLapply(1:2, fun=function(i,Gibbs,y,x,l,isbeta,b,niter){
> >
> >
> Gibbs(y,x,l,isbeta[,i],b[,i],niter)},Gibbs=Gibbs,y=y,x=x,l=l,isbeta=isbeta,b=b,niter=niter)
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-hpc mailing list
> > R-sig-hpc@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
> >
>
>
> --
> Department of Statistics & Actuarial Sciences
> Fax Phone#:(519)-661-3813
> The University of Western Ontario
> Office Phone#:(519)-661-3622
> London, Ontario N6A 5B7
> http://www.stats.uwo.ca/faculty/yu
>

	[[alternative HTML version deleted]]

