วันพฤหัสบดีที่ 2 กุมภาพันธ์ พ.ศ. 2560

PH525.2xWeek1Introduction to Linear Models

Introduction Exercises

Introduction Exercises #1

1 point possible (graded)
If you haven't done so already, install the library UsingR
install.packages("UsingR")
Then once you load it you have access to Galton's father and son heights:
library(UsingR)
data("father.son",package="UsingR")


Explanation
mean(father.son$sheight)
 

Introduction Exercises #2

1 point possible (graded)
One of the defining features of regression is that we stratify one variable based on others. In Statistics we use the verb "condition". For example, the linear model for son and father heights answers the question how tall do I expect a son to be if I condition on his father being x inches. The regression line answers this question for any x.
Using the father.son dataset described above, we want to know the expected height of sons if we condition on the father being 71 inches. Create a list of son heights for sons that have fathers with heights of 71 inches (round to the nearest inch).
What is the mean of the son heights for fathers that have a height of 71 inches (don't round off your answer)? (Hint: use the function round() on the fathers' heights)

 

Explanation
mean(father.son$sheight[round(father.son$fheight)==71])
or using dplyr:
library(dplyr)
filter(father.son,round(fheight)==71) %>% summarize(mean(sheight))

Introduction Exercises #3

1/1 point (graded)
We say a statistical model is a linear model when we can write it as a linear combination of parameters and known covariates plus random error terms. In the choices below, Y represents our observations, time t is our only covariate, unknown parameters are represented with letters a,b,c,d and measurment error is represented by the letter e. Note that if t is known, then any transformation of t is also known. So, for example, both Y=a+bt +e and Y=a+b f(t) +e are linear models. Which of the following can't be written as a linear model?

Introduction Exercises #4

0/1 point (graded)
Supposed you model the relationship between weight and height across individuals with a linear model. You assume that the height of individuals for a fixed weight x follows a liner model Y = a + b x + e. Which of the following do you feel best describes what e represents?

Explanation
Remember the model is across individuals and we fix x. People of the same height can vary greatly in other aspects of their physiology: for example different bone density or differing amounts of muscle and fat.

2 ความคิดเห็น: