First you must learn to be more specific in your description of what you want.
That will allow others to understand what you actually want rather than
guessing.
Perhaps try creating a small (3 var by 10 values) example, and describe the
actual correlations you have created.
If your problem is
You didn't say how you want these variables to be distributed, but in
case you want a multivariate normal, then have a look at function
mvrnorm() from package MASS, and especially at the 'empirical' argument,
e.g.,
library(MASS)
# assumed covariance matrix
V <- cbind(c(2, 1), c(1, 1.2))
V
x1
Hi!
I want to create a random matrix with 15 variables, each variable having
1000 observations.
Between each two variables, I want to define a specific (*not *random)
correlations between them, but still saving the "randomness" of each
variable (mean=zero, s.d=1).
How can I do this in R?
thanks,
Thanks. bb=replicate(2, rnorm(20)) was very useful for me.
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-create-a-random-matrix-tp901667p3912806.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.
Like tris:
NCols=5
NRows=7
myMat<-matrix(runif(NCols*NRows), ncol=NCols)
myMat
bests
milton
On Mon, Aug 24, 2009 at 6:17 PM, Peng Yu wrote:
> Hi,
>
> I did a search but I was able to find how to generate a random matrix.
> Can somebody let me know how to do it?
>
> Regards,
> Peng
>
>
Here is another nice way of doing it:
replicate(10, rnorm(20))
# this will give you 10 columns of vectors with 20 random variables taken
from the normal distribution.
If any one got a faster way of doing this, please let me know.
Tal galili
On Tue, Aug 25, 2009 at 1:30 AM, Rolf Turner wrot
On 25/08/2009, at 10:17 AM, Peng Yu wrote:
Hi,
I did a search but I was able to find how to generate a random matrix.
Can somebody let me know how to do it?
Uhhh, generate some random numbers and then arrange them in a matrix?
?matrix
?runif
?rnorm
?rgamma
.
.
.
cheers,
Hi,
I did a search but I was able to find how to generate a random matrix.
Can somebody let me know how to do it?
Regards,
Peng
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://ww
8 matches
Mail list logo