##chapter 6 exercise ## part a) > sample=rpois(1000,1) > samples=as.data.frame(matrix(rbinom(1000*40,1,0.5),ncol = 40)) ## part b) #mean_n=rowMeans(samples[,1:n]) ##row means for a sample size of n > mean_5=rowMeans(samples[,1:5]) > mean_15=rowMeans(samples[,1:15]) > mean_40=rowMeans(samples[,1:40]) ## c) 6 lines; means and sd of each sample size ^ #mean(mean_n) and sd(mean_n) <- where "mean_n" is a generic vector of 1000 means from b ^ > mean(mean_5) > sd(mean_5) > mean(mean_15) > sd(mean_15)*15 > mean(mean_40) > sd(mean_40)*40 ## d) 4 lines; shapiro test a single column of 'samples' & each set of means ^^ #shapiro.test(samples[,1]) > shapiro.test(samples[,1]) > shapiro.test(samples[,5]) > shapiro.test(samples[,15]) > shapiro.test(samples[,40]) ## e) gen 'by groups' boxplot; groups are the single col of 'samples' & each set o means ^^^ > boxplot(cbind(samples[,1],samples[,5],samples[,15],samples[,40])) > boxplot(cbind(samples[,1])) ############################################## # questions # # 1. # 2. population is skewed high, negative # n=5 is skewed high, negative # n=15 is skewed low, positive # n=40 is skewed high, positive # 3. As the sample size increases I expect the mean of the sample means to become closer to the population mean. # The results from question 1 support this by having the sample mean increase as the sample size increased from 5 to 15 to 40