Homework Project 1
- Due Jan 19, 2018 by 11:59pm
- Points 100
- Submitting a file upload
Homework Project 1
- Due Fri, Jan 19, 2018 (Submit hard copies to Dr. James Yang)
- Homeworks, projects and assignments Links to an external site.
- Homework Submission Rules Links to an external site.
- Homework Headers Links to an external site.
Note: For all homework, use R for calculations. Do not give raw computer output as your main answer to any question; do include R code in an appendix. Do not report numbers to more significant digits than is warranted. It is recommended to use the options:
options(digits=4, show.signif.stars=FALSE)
Remember that providing a clear and reasonable justification of your answers is at least as important as getting the answer right.
Problem 1.1
- Enter the following R commands:
set.seed(201801)
U <- matrix(runif(1000 * 200), nrow=1000, ncol=200) z <- apply (U, 2, mean)
- These commands create a 1000x200 (a thousand rows and two hundred columns) matrix of random draws, called U and a vector z of length 200 which contains the means of each column of U. Now enter the command hist(U[,1]). This command takes the first column of U (a column vector of length 1000) and makes a Print out this histogram and describe what it looks like. What distribution is the runif command drawing from?
- Now enter the command hist(z). This command makes a histogram from the vector z. Print out this Describe what it looks like and how it differs from the one above. Based on the histogram, what distribution do you think z follows?
- You generated U and z with the same random draws, so how can they have different distributions? What’s going on here?
Problem 1.2
An investigator does not know the formula for the area of a rectangle. Taking an empirical approach, she creates 20 typical rectangles using the following R code set.seed(201801)
length <- rnorm(20, mean=4, sd=0.5) width <- rnorm(20, mean=3, sd=0.5)
- For each rectangle, calculate area and perimeter, and construct a scatterplot for the area (y-axis) versus perimeter (x-axis)
- Fit a simple linear regression using the area as the response, and add the fitted line to the
- What is the correlation coefficient? Is this a good fit?
- For a new rectangle with length = 1 and width = 1, predict the value of area using the fitted regression.
- Does the regression make sense to build the relationship between area and perimeter?
Problem 1.3
The ratdrink data from the faraway package consist of 5 weekly measurements of body weight for 27 rats. The first 10 rats are on a control treatment while 7 rats have thyroxine added to their drinking 10 Rats have thiouracil added to their water.
- Construct three scatterplots (treat = control, thiouracil, or thyroxine) using lattice to show the relationship between wt and weeks for each subject.
- Fit a random intercept model to show the effect of the treatment
- Fit a random intercept, random slope model to show the effect of the treatment
- Compare the two models in b) and c) and comment on which model fit the data.
Rubric
Criteria | Ratings | Pts | ||
---|---|---|---|---|
Correctness and scientific validity
threshold:
pts
|
|
pts
--
|
||
Result reproducibility
threshold:
pts
|
|
pts
--
|
||
Content focus, presentaiton style, and clarity
threshold:
pts
|
|
pts
--
|
||
Total Points:
100
out of 100
|