Question: You have to slove question 2 by using question the code in Q1 and I have also included the code for Q1 in R #

You have to slove question 2 by using question the code in Q1 and I have also included the code for Q1 in R

# 1

Simulate $n=50$ observations from a normal distribution with mean 3, standard deviation .80, using:

ANSWER: ```{r} set.seed(87612345) data = rnorm(50, mean = 3.0, sd = 0.80) ```

Calculate a 98% t-confidence interval for the mean of 'data'

ANSWER:

```{r} t.test(data,conf.level = 0.98) ```

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)

B=2000 bootstrapmeans = c()

for(i in 1:B) { n=i bdata=sample(data,n,replace=T) bootstrapmeans=c(bootstrapmeans,mean(bdata)) } ``` + (1a) make a histrogram of the bootstrapmeans with 20 bars, using something like: "hist(bootstrapmeans,nclass=20)". ANSWER: ```{r} hist(bootstrapmeans,nclass = 20) ``` Does the histogram look like it has a normal shape? ANSWER: + (1b) calculate the 1'th and 99'th percentiles of the bootstrapped means using the quantile function. ANSWER: ```{r}

quantile(bootstrapmeans,probs=c(0.01,0.99)) ``` 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". # 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:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!