首页 > > 详细

讲解R、R程序讲解、调试R、R讲解、辅导R、R设计辅导留学生

Send your code to . Follow the following format exactly. In subject line
write \MATH 185 (Final)" and nothing else in the body. There should only be one le attached to
the email, named nal-lastname- rstname.R. Make sure your code is clean, commented and running.
Keep your code simple, using packages only if really necessary. If your code does not run, include
an explanation (as a comment in the code) of what is going on.
AGREEMENT
By taking this exam, you agree to not discuss the exam with anyone, starting now,
neither with a classmate or anyone else, neither in person nor through other means,
including electronic. Unless otherwise speci ed, it is acceptable to copy-paste from the
lecture or homework solution code.
Problem 1. (A simple example where the bootstrap fails.) Consider the situation where
X1;:::;Xn are iid from a distribution with mean and variance 1. It is desired to provide a
con dence interval for j j. The plug-in estimator is j Xnj, the absolute value of the sample mean.
The pivotal bootstrap con dence interval is based on estimating the distribution of j Xnj j j by
the bootstrap distribution of j X nj j Xnj. This happens to fail when = 0. (This is because
the absolute value, as a function, is not smooth at the origin.) We examine the situation when
X1;:::;Xn are iid standard normal.
A. Compute the distribution function of j Xnj j j=j Xnj in closed form. (no need to show your
work) and draw it.
B. Generate a sample of size n = 106 and estimate the bootstrap distribution of j X nj j Xnj
using B = 104 replicates. Add the resulting empirical distribution function to the plot.
C. O er some brief comments.
Problem 2. (Meta-analysis) In meta-analysis, the goal is to gather information, and perform
inference, based on several studies published by di erent researchers, over several years. For ex-
ample, consider 8 studies1 conducted between 1981 and 1984, comparing an experimental surgical
intervention (proximal gastric vagotomy) to an established intervention (truncal vagotomy plus
drainage). Here the event of interest is recurrence, the control group is truncal vagotomy plus
drainage, and the treatment group is the experimental intervention.
Study Treatment Control
It reads as follows. Take Study 1, corresponding to the rst row. There were 48 individuals in the
treatment group, 9 of which had a recurrence, and there were 50 individuals in the control group, 6
of which had a recurrence. The results of each study are often summarized in a 2-by-2 contingency
table. The goal is to assess whether the new procedure yields a smaller rate of recurrence than the
standard procedure.
A. As a preliminary, apply the (one-sided) Fisher exact test to each of these 8 studies, obtaining
8 p-values. Store these in a vector called pval.
B. Apply the (one-sided) Kolmogorov-Smirnov test to the p-values. What is the null distribution
in the present context? Explain.
C. Apply the Liptak-Stou er test to the p-values. This test rejects for large values of T =
1(1 Pj), where is the standard normal distribution function and Pj is the
p-value associated with the j-th study. Note that, when P1;:::;Pm are IID uniform. in [0;1],
T has the standard normal distribution. Implement the function yourself and name it ls.test.
D. Apply the Cochran-Mantel-Haenszel test to the p-values. You can read about the test here,
although the formula is more rigorously written here. No need to implement the test yourself.
1Buyse, M., P. Hewitt, and M. Koch. Data analysis for clinical medicine: the quantitative approach to patient
care in gastroenterology. International University Press, 1988.
Problem 3. (Selecting the degree of a polynomial model) Write a function poly. t(x, y, stop
= 0.05) that takes in the predictor and response variable vectors, and ts a polynomial model where
the degree is chosen sequentially, starting at degree = 0, increasing the degree by 1, and stopping
when the improvement in R-squared is less than speci ed by stop. The function should return the
least squares coe cient of the nal polynomial model. Apply your function to the dataset steam
in the MASS package.

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

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