Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

r language, use r studio 1. Simulate 20 observations from a normal distribution with mean 4, standard deviation .75, using set.seed (87612345) data-rnorm (20,mean-4,sd-.75) In

r language, use r studio

image text in transcribed

1. Simulate 20 observations from a normal distribution with mean 4, standard deviation .75, using set.seed (87612345) data-rnorm (20,mean-4,sd-.75) In assignment 2, you found that you could calculate a 95% confidence interval for the mean using t.test (data, conf.level-.95) ## One Sample t-test ##data: data ## t 24.626, df 19, p-value 7.037e-16 ## alternative hypothesis: true mean is not equal to 0 ## 95 percent confidence interval: ## 3 . 740388 4 . 435262 ## sample estimates: ## mean of x ## 4.087825 Carry out the following bootstrap sampling scheme. Draw 1000 bootstrap samples. For each sample, calculate the sample average, using the builtin function "mean". You can use a for loop to do this, where the loop index runs from 1 to 1000. Inside the loop you can do the bootstrap sampling with "bdata-sample(data,20,replace-T)", and then you need something similar to "bootstrapmeans c(bootstrapmeans.mean(bdata))". . (la) make a histrogram of the bootstrapmeans with 20 bars, using something like "hist(bootstrapmeans,nclass-20)". Does the histogram look like it has a normal shape? . (1b) calculate the 2.5'th and 97.5'th percentiles of the bootstrapped means using "quantile(bootstrapmeans,probs-c(.025,.975))". This is a valid 95% bootstrap confidence interval for the unknown population mean, which does not depend on the assumption of normality. This interval uses the so-called "bootstrap percentile method". 2. Repeat problem 1, but using a sample of size 20 from a x2 distribution with 1 degree of freedom set.seed (117426) data-rchisq(20,1) . (2a) make the histrogram of the bootstrap means with 20 bars. Does the historgram look a close to normal as it did when you sampled from a normal distribution? (2b) make a 95% confidence interval for the population mean using the percentile method (2c) calculate the usual 95% t-interval assuming normality, using the t-test procedure. Are the percentile and t-interval as close as they were in problem 1? 1. Simulate 20 observations from a normal distribution with mean 4, standard deviation .75, using set.seed (87612345) data-rnorm (20,mean-4,sd-.75) In assignment 2, you found that you could calculate a 95% confidence interval for the mean using t.test (data, conf.level-.95) ## One Sample t-test ##data: data ## t 24.626, df 19, p-value 7.037e-16 ## alternative hypothesis: true mean is not equal to 0 ## 95 percent confidence interval: ## 3 . 740388 4 . 435262 ## sample estimates: ## mean of x ## 4.087825 Carry out the following bootstrap sampling scheme. Draw 1000 bootstrap samples. For each sample, calculate the sample average, using the builtin function "mean". You can use a for loop to do this, where the loop index runs from 1 to 1000. Inside the loop you can do the bootstrap sampling with "bdata-sample(data,20,replace-T)", and then you need something similar to "bootstrapmeans c(bootstrapmeans.mean(bdata))". . (la) make a histrogram of the bootstrapmeans with 20 bars, using something like "hist(bootstrapmeans,nclass-20)". Does the histogram look like it has a normal shape? . (1b) calculate the 2.5'th and 97.5'th percentiles of the bootstrapped means using "quantile(bootstrapmeans,probs-c(.025,.975))". This is a valid 95% bootstrap confidence interval for the unknown population mean, which does not depend on the assumption of normality. This interval uses the so-called "bootstrap percentile method". 2. Repeat problem 1, but using a sample of size 20 from a x2 distribution with 1 degree of freedom set.seed (117426) data-rchisq(20,1) . (2a) make the histrogram of the bootstrap means with 20 bars. Does the historgram look a close to normal as it did when you sampled from a normal distribution? (2b) make a 95% confidence interval for the population mean using the percentile method (2c) calculate the usual 95% t-interval assuming normality, using the t-test procedure. Are the percentile and t-interval as close as they were in problem 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions