关键词 > STAT6/4365

STAT 6/4365 HW 5

发布时间:2022-11-02

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

STAT 6/4365

HW 5

1)   Use R Markdown and create a report (PDF preferred) containing your answers. The report should include your code too. Upload the report, by the deadline to the submission folder on eLC.

Remember that you helped Laura select the best school for her. Now, she needs your help with creating a function. She wants you to create a function that demonstrates the             Confidence Level concept. For example, a ‘95% confidence’ indicates, if you construct 100 intervals, approximately 95 would contain the true parameter value.

Laura is only interested in confidence intervals for mean and your function should accept following arguments :

o population mean

o population SD default is unknown

o sample size

o number of samples this should be at least 100

o confidence level default is 95%

Don’t forget to do basic error handling -- For example, your sample size should be larger than 1.

Your function should return the capture rate -- The proportion of intervals that would contain the population mean.

2.   The point of this problem is to practice vectorized calculation. Therefore, you should not      use any loops in completing the problem. Make a data frame consisting of 30 rows and 10   columns. Each column j should consist of 30 values from a normal distribution with mean (j-

1) and standard deviation 0.5*j. For example, the third column should have values from normal (mean=2, sd=1.5). Using this data frame, do each of the following (using code, of course):

a.    Find the mean and standard deviation for each column.

b.   Counts the number of columns for which the sample mean and sample standard deviation are within 25% of the mean and standard deviation values used to        generate the data.

c.    Write code that writes the columns from part b) to a new data frame.

d.   For each value in the new data frame, subtract its column mean and divide by    the column standard deviation. Do NOT use the scale function in R, or any other function that does this automatically.