Hi Chloe,

Try this:

NUMBER.OF.RUNS<-10 #change here
for (NR in 1:NUMBER.OF.RUNS)
{
number.simulation<-1000
sample.size=15;
variance.list<-NULL
for(i in 1:number.simulation)
   {
   mysample<-rnorm(sample.size)
   variance.list<- c(variance.list, var(mysample))
   } #i
hist(variance.list)
} #NR


Bests

milton
brazil=toronto

On Wed, May 20, 2009 at 8:16 PM, Chloe Smith <hapiasfion@hotmail.com> wrote:

>
> Dear R users,
>
> I am a beginner to R. I generated 1000 samples with 15 data in each sample
>
> I tried finding the variance for each sample
>
> I used the code:
>
> m=1000;n=15
> > r<-rnorm(15000)
> > for(i in 1:m){
> x=data[,i]
> v=var(x)}
>
> what I got was just the variance for the last sample i.e. the 1000th sample
>
> but what I want is 1000 variance.
>
> Does anyone know what I did wrong?
>
> Thanks
>
> Chloe Smith
>
> --
> View this message in context:
> http://www.nabble.com/Problems-with-sample-variance-tp23645919p23645919.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]


