[R] Random number generator in R compared to S

Paul Gilbert pgilbert at bank-banque-canada.ca
Tue Jan 14 16:52:07 CET 2003


Alain LE TERTRE wrote:
> 
> I'm doing some simulations for which i need to use both S-plus and R.
> I generate in S+ some random normal distributions to define one dataset by
> iteration.  I need to use the same dataset generated in S-plus in R.
> I was first thinking to generate in R the same dataset by using the same
> random number generator with a fixed seed. But It seems that S-plus and R
> don't use the same random number generator.
> So my question is: Is there a way to pass dynamically dataset generated in
> S-plus to R, run a command, extract results, and pass them back to S-plus?
> Or is it more efficient to generate all the datasets in S-plus and export
> them to R?
> Or anything else?
> 
> Any hints will be greatly appreciated.

I do this in a slightly different way, by implementing one of the R
generators (and normal transformation) in Splus. The generator and
transformation I am using may not be the best choice among those in R,
but I have used it for several years now and it has worked very well for
checking that simulation and estimation code give the same results in
both Splus and R. My code for this is available in the syskern package
in the dse bundle on CRAN, but I am in the process of moving it into a
package called setRNG in a new version of dse which I will put on CRAN
soon.

Paul Gilbert




More information about the R-help mailing list