[R] Simulation
Linlin Yan
yanlinlin82 at gmail.com
Thu May 14 15:19:06 CEST 2009
Since you got the most suitable way to get x, why can't you get the
variances in the same way? Just like:
v = vector()
for (i in 1:length(x)) v[i] = var(x[[i]])
BTW, it is much better to use lapply, like this:
lapply(x, var)
On Thu, May 14, 2009 at 8:26 PM, Debbie Zhang <debbie0621 at hotmail.com> wrote:
>
> Thanks for everyone.
>
>
>
> I think the approach below is most suitable for me, as a beginner.
>
> x=list()
>> > for(i in 1:n){
>> > x[[i]]=rnorm(i,0,1)
>> > }
>
>
>
> Now, I am trying to obtain the sample variance (S^2) of the 1000 samples that I have generated before.
>
> I am wondering what command I should use in order to get the sample variance for all the 1000 samples.
>
>
>
> What I am capable of doing now is just typing in
>
> var(z[[1]])
>
> var(z[[2]]).....................
>
>
>
> Thanks for help.
>
>
>
> Debbie
>
More information about the R-help
mailing list