[R] statistics for ragged arrays: loop to vector

Elena Moltchanova Elena.Moltchanova at ktl.fi
Mon Oct 22 13:44:10 CEST 2001

Dear R users,

I am currently writing a MCMC algorithm for spatial Poisson model. One
problem which I need to solve is as follows:

I have a vector X[1:J] which describes characteristics of cells of a
rectangular grid. Further, for each cell I have a list of adjascent
cells adj[] and the vector listing numbed of adjascent cells num[].

Thus if I want to list cells adjascent to cell i I write


and if I want to calculate some function, say mean, over the adjascent
cells I write


This works fine, but if I need the function to be calculated for each
cell of the field a couple of times for each MCMC iteration, the amount
of time which is used by the loop is too large. My question is: can this
loop be written in some vector form?

Thanks for any comments

Elena Moltchanova
-------------- next part --------------
A non-text attachment was scrubbed...
Name: emor.vcf
Type: text/x-vcard
Size: 270 bytes
Desc: Card for Elena Moltchanova
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20011022/ce59b19a/emor.vcf

More information about the R-help mailing list