I need help coding in R Have spent the past couple hours sea
I need help coding in R. Have spent the past couple hours searching online with no luck..ANY help is appreciated.
1. Generate a Gamma(1,2) population of size N=5000 and show it density plot and descriptive statistics.
2. Create the sampling distribution of the sample mean from 200 samples, each of size n=35, drawn from the above population.
3. Show a density plot, descriptive statistics for this sampling distribution
4. Are your results in agreement with the central limit theorem (CLT)? Did you expect that?
Solution
1.
> set.seed(12345)
> x<-rgamma(5000,1,2)
The above command will create a gamma population that is specified in the problem.
> plot(density(x),main=\"density plot of gamma population\")
The above function will create its density plot.
> summary(x)
Gives basic descriptive statistics of the population.
2.
> draws<-sample(x,size=35*200,replace=TRUE)
> draws<-matrix(draws,35)
> drawsmeans<-apply(draws,2,mean)
This will have created and found the required sample of 200 with mean of 35 draws each.
3.
Again for its density we will use the same density function used above.
> plot(density(drawsmeans),main=\"200 means of 35 draws\")
For descriptive statistics,
> summary(drawsmeans)
4. I will leave you to it.
