[R] building random matrices from vectors of random parameters
evan.cooch at gmail.com
Thu Sep 28 02:47:49 CEST 2017
Suppose I have interest in a matrix with the following symbolic
structure (specified by 3 parameters: sa, so, m):
What I can't figure out is how to construct a series of matrices, where
the elements/parameters are rnorm values. I'd like to construct separate
matrices, with each matrix in the series using the 'next random
parameter value'. While the following works (for generating, say, 5 such
its inelegant, and a real pain if the matrix gets large (say, 20 x 20).
I'm wondering if there is an easier way. I tried
> sa <- rnorm(5,0.8,0.1)
> so <- rnorm(5,0.5,0.1)
> m <- rnorm(5,1.2,0.1)
but that only returns a single matrix, not 5 matrices as I'd like. I
also tried several variants of the 'replicate' approach (above), but
didn't stumble across anything that seemed to work.
So, is there a better way than something like:
Many thanks in advance...
More information about the R-help