user9292
user9292

Reputation: 1145

Data simulation in R

Suppose I want to simulate 10 observations from lognormal distribution and repeat this 100 times. I wrote some R code, but for some reason it's not working. Here is the code:

for(i in 1:100) 
 {

x = rlnorm(10, meanlog = 0, sdlog = 1)

 }

Any thoughts?

Upvotes: 0

Views: 2559

Answers (1)

Stat
Stat

Reputation: 681

Try this code as well:

> x=matrix(0,nrow=10,ncol=100)
> for(i in 1:100) 
+  {
+ 
+ x[,i] = rlnorm(10, meanlog = 0, sdlog = 1)
+ 
+  }
> 
> apply(x,2,mean)
> apply(x,2,sd)
> library(moments)
> apply(x,2,skewness)

Upvotes: 5

Related Questions