首页 > > 详细

调试R、R辅导、辅导R编程、R程序讲解、讲解留学生R语言、Statistics

Statistics 471 { Homework 1
Homework Assignment Policy and Guidelines
(a) Homework assignments should be well organized and reasonably neat. It is required
that you show your work in order to receive credit.
(b) Unless otherwise stated in a problem, please use R Markdown to write homework
answers.
(c) Homework assignments are due in class unless otherwise noted. Credit will not be
given for homework turned in late.
(d) You may be asked to submit some homework problems online, in addition to a hard
copy that you turn in in class. Such homework problems will be marked online submission .
Your submission should be combined into one PDF or HTML document.
(e) Unless it is speci cally stated otherwise, you may work on and submit your homework
in groups of 1 or 2. If you choose to work as a group of 2, both of you should con-
tribute signi cantly to the solution for every question and submit only one copy of the
homework with both your names on it. Whether you submit on your own or with a
partner, discussing homework with your fellow students is encouraged. However, after
discussions, every group must ultimately produce their own homework to be graded.
Verbatim copying of homework is absolutely forbidden.
1. online submission Recall that the Harmonic Series is given by:
Hn =
nX
k=1
1
k
so for example: H4 = 1 + 12 + 13 + 14:
(a) Suppose you want to nd Hn given a certain n. Write a for loop to nd this, within
the following function:
FindHn B, for some B. For example, if B = 4, then n = 31. Write a
while loop to determine the smallest n for any B, within the following function:
FindN<-function(B){
# Put your loop here
}
2. online submission Computer simulations provide a powerful set of tools for studying
various statistical ideas. In particular, simulations can be used to study various statistical
methods, especially when mathematical or theoretical approaches are not available. We
assume that we know the population. We then take a random sample from that population,
and calculate something for that sample, like the mean. Of course, the result of this is
random, because it is based on a random sample. To study things in greater generality, we
repeat the sampling many times.
(a) Sample n = 10 observations from N(2;4); that is = 2 and = 2. Repeat this sam-
pling S = 100 times, so at the end we will have 100 samples, each with 10 observations,
and for each sample, compute the sample mean. Provide the histogram of the sample
means from the 100 samples.
(b) Repeat (a) but this time let n = 40.
(c) Repeat (a) but this time let n = 160.
(d) What observations can you make about the histograms in (a){(c)?
(e) Repeat (a){(d), but this time, replace N(2;4) with 22.
(f) Repeat (a){(d), but this time, replace N(2;4) with Bin(10;0:2).
2
3. online submission Conduct a simulation study to evaluate the robustness and resis-
tance of a one-sample T test.
(a) Draw a random sample of size n = 10 from N(0;1). Repeat this sampling S = 1000
times and for each sample, perform. a T test for H0 : = 0 vs. HA : 6= 0 at the
= 0:05 level and construct a 95% con dence interval (CI) for . Provide the Type I
error rate of the T test and the coverage probability of the CI from the 1000 samples.
(b) Repeat (a) but this time let n = 50.
(c) Repeat (a) but this time let n = 200.
(d) What observations can you make about the results in (a){(c)?
(e) Repeat (a){(d), but this time, replace N(0;1) with T2 rst and then with T6.
(f) Repeat (a){(d), but this time, replace N(0;1) with 22 rst and then with 26. The null
hypotheses are H0 : = 2 and H0 : = 6 for 22 and 26, respectively.
4. online submission The number of accidents per week at a hazardous intersection
follows a Poisson distribution with mean 2.2. We observe the intersection for a full year (52
weeks) and calculate X the mean number of accidents per week.
(a) What is the approximate distribution of X according to the Central Limit Theorem?
(b) What is the approximate probability that X is less than 2?
(c) Simulate n = 52 observations from a Poisson distribution with mean 2.2. Repeat this
sampling S = 1000 times, so at the end we will have 1000 samples, each with 52
observations, and for each sample compute the sample mean.
(i) Construct a scaled histogram (i.e., scale the histogram to a probability density)
of the sample means from the 1000 samples and superimpose the density curve
identi ed in Part (a) over the histogram. Comment on the graph. (Remark: check
the R code on page 364 of JMR for how to add a curve to histogram.)
(ii) Count N the number of the sample means that are less than 2. Then compare
N=1000 with the approximate probability obtained in Part (b).
5. online submission Consider the dataset chickwts in the R. We are interested in the
weight of chicks fed horsebean and soybean supplements and the hypotheses of interest are
H0 : 1 = 2; Ha : 1 6= 2
where 1 ( 2) is the mean chick weight for the soybean (horsebean) group.
(a) Perform. a Welch’s two-sample T test. Use = 0:05. Construct the corresponding 95%
con dence interval for the di erence of the mean chick weight between the two groups.
(b) Implement the Welch’s two-sample T test as a permutation test. Use = 0:05.
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!