Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

R studio # 1. Simulate $n=50$ observations from a normal distribution with mean 3, standard deviation .80, using: ANSWER: '{r} set.seed(87612345) # add your own

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedR studio

# 1. Simulate $n=50$ observations from a normal distribution with mean 3, standard deviation .80, using: ANSWER: '{r} set.seed(87612345) # add your own R code below this line Calculate a 98% t-confidence interval for the mean of 'data' ANSWER: '{r} # add your own R code below this line Carry out the following bootstrap sampling scheme. Draw $B=2000$ bootstrap samples. For each sample, calculate the sample average, using the R built-in function "mean". You can use a for loop to do this, where the loop index $i$ runs from 1 to $B$. Inside the loop you can do the bootstrap sampling with "bdata=sample(data, n, replace=T)", where $n$ is the number of sample in your dataset. and then you need something similar to: "bootstrapmeans=c(bootstrapmeans, mean(bdata))". ANSWER: {r} set.seed(87612345) # add your own R code below this line # use a variable called B for the number of bootstrap sample (2000) # use a variable called n for the number of sample + (1a) make a histrogram of the bootstrapmeans with 20 bars, using something like: "hist(bootstrapmeans, nclass=20)". ANSWER: '{r} # add your own R code below this line Does the histogram look like it has a normal shape? ANSWER: + (1b) calculate the l'th and 99'th percentiles of the bootstrapped means using the quantile function. ANSWER: {r} # add your own R code below this line This is a valid 98% 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" (7 points: 5 points for histogram, 2 points for percentiles) # 2. Repeat problem 1, but using a sample of size $n=60$ from a chi-square distribution with $0.2$ degree of freedom (note that this does not need to be an integer). Use $B=1500$ bootstrap samples. You will need first to generate the data, and then to write a loop for producing bootstrap samples from this data. ANSWER: '{r} set.seed(117426) # add your own R code below this line (2a) make the histogram of the bootstrap means with 25 bars. ANSWER: '{r} # add your own R code below this line Does the histogram look a close to normal as it did when you sampled from a normal distribution? ANSWER: (5 points for histogram) (2b) make a 96% confidence interval for the population mean using the percentile method ANSWER: {r} # add your own R code below this line (2 points for the interval) (2c) calculate the usual 96% t-interval assuming normality, using the t-test procedure. ANSWER: {r} # add your own R code below this line Compare the percentile (bootstrap method) confidence interval obtained in 2b and and t-confidence intervals obtained in 2c. Do you expect the two methods to give similar results or not for this distribution (which is not normal)? ANSWER: (2 points for extracting the confidence interval from the t.test output, or for calculating using first principles.) # 1. Simulate $n=50$ observations from a normal distribution with mean 3, standard deviation .80, using: ANSWER: '{r} set.seed(87612345) # add your own R code below this line Calculate a 98% t-confidence interval for the mean of 'data' ANSWER: '{r} # add your own R code below this line Carry out the following bootstrap sampling scheme. Draw $B=2000$ bootstrap samples. For each sample, calculate the sample average, using the R built-in function "mean". You can use a for loop to do this, where the loop index $i$ runs from 1 to $B$. Inside the loop you can do the bootstrap sampling with "bdata=sample(data, n, replace=T)", where $n$ is the number of sample in your dataset. and then you need something similar to: "bootstrapmeans=c(bootstrapmeans, mean(bdata))". ANSWER: {r} set.seed(87612345) # add your own R code below this line # use a variable called B for the number of bootstrap sample (2000) # use a variable called n for the number of sample + (1a) make a histrogram of the bootstrapmeans with 20 bars, using something like: "hist(bootstrapmeans, nclass=20)". ANSWER: '{r} # add your own R code below this line Does the histogram look like it has a normal shape? ANSWER: + (1b) calculate the l'th and 99'th percentiles of the bootstrapped means using the quantile function. ANSWER: {r} # add your own R code below this line This is a valid 98% 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" (7 points: 5 points for histogram, 2 points for percentiles) # 2. Repeat problem 1, but using a sample of size $n=60$ from a chi-square distribution with $0.2$ degree of freedom (note that this does not need to be an integer). Use $B=1500$ bootstrap samples. You will need first to generate the data, and then to write a loop for producing bootstrap samples from this data. ANSWER: '{r} set.seed(117426) # add your own R code below this line (2a) make the histogram of the bootstrap means with 25 bars. ANSWER: '{r} # add your own R code below this line Does the histogram look a close to normal as it did when you sampled from a normal distribution? ANSWER: (5 points for histogram) (2b) make a 96% confidence interval for the population mean using the percentile method ANSWER: {r} # add your own R code below this line (2 points for the interval) (2c) calculate the usual 96% t-interval assuming normality, using the t-test procedure. ANSWER: {r} # add your own R code below this line Compare the percentile (bootstrap method) confidence interval obtained in 2b and and t-confidence intervals obtained in 2c. Do you expect the two methods to give similar results or not for this distribution (which is not normal)? ANSWER: (2 points for extracting the confidence interval from the t.test output, or for calculating using first principles.)

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Know how productivity improvements impact quality and value.

Answered: 1 week ago

Question

Recommend the key methods to improve service productivity.

Answered: 1 week ago