Reputation: 1145
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
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