Q1.1:Find the OLS estimate for βˆ. You can use R to find the inverse of a matrix with a variation of the following code
y=matrix(c(4,7,9,11))
X1=c(2,2,4,5)
X2=c(3,4,5,1)
X=matrix(c(rep(1, 4),X1,X2),nrow=4)
solve(t(X) %*% X) %*% t(X) %*% y
## [,1]
## [1,] 1.0824742
## [2,] 1.8917526
## [3,] 0.1597938
Q1.2: Find yˆ and εˆ. yˆ=Xβˆ, εˆ=y-yˆ
Q1.3: Show X′εˆ ≈ 0 and explain why that is. The first OLS assumption E (ui|Xi) = 0 states that: All other factors that affect the dependent variable Yi (contained in ui ) are unrelated to Xi in the sense that, given a value of Xi , the mean of these other factors equals zero.
Q1.4: Run a regression of X on Y in R to confirm your answer is (i).
lm(y~X1+X2)
##
## Call:
## lm(formula = y ~ X1 + X2)
##
## Coefficients:
## (Intercept) X1 X2
## 1.0825 1.8918 0.1598
Q2: What happened and why?
set.seed(123)
# Create a dataset with perfect multicollinearity
x1 <- c(1, 2, 3, 4)
x2 <- 2 * x1
y <- 3 * x1 + 4 * x2 + rnorm(4)
# Create a data frame
data_perfect <- data.frame(x1, x2, y)
# Fit a linear regression model
model_perfect <- lm(y ~ x1 + x2, data = data_perfect)
# Display the summary of the regression
summary(model_perfect)
##
## Call:
## lm(formula = y ~ x1 + x2, data = data_perfect)
##
## Residuals:
## 1 2 3 4
## -0.2178 -0.2557 1.1650 -0.6914
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.7108 1.2087 -0.588 0.6160
## x1 11.3682 0.4414 25.757 0.0015 **
## x2 NA NA NA NA
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9869 on 2 degrees of freedom
## Multiple R-squared: 0.997, Adjusted R-squared: 0.9955
## F-statistic: 663.4 on 1 and 2 DF, p-value: 0.001504
This indicates that there are predictor variables in the model that have a perfect linear relationship and thus not every regression coefficient in the model can be estimated. In this case, no coefficient estimate can be made for the x2 predictor variable.
Q3.1: Does there seem to be omitted variable bias in m1? Explain.
A low R-squared value indicates that the independent variable is not explaining much in the variation of the dependent variable, since we have low R-squared for m1, there could be omitted variable bias in m1.
Q3.2: Interpret the coefficient on female in m4.
let’s say if this one person is female, according to m4, there would be 30% of decrease on her wage.
Q3.3: With df = n−k-1 = 521, we obtain the 5% critical value -1.6478. The test statistic for β0 < -0.2 is about (-0.3-(-0.2))/0.04 = -2.5 , which is less than -1.6478. Therefore, we reject β0.
Q3.4: Construct a 95% confidence interval for for β1 in model m4.
The left-sided critical value is approximately 1.64. Therefore, the confidence interval will be equal to -0.3 ± 1.64(0.04), about (-0.3656, -0.2344).
Q3.5: F=((96.04-90.04)/90.04) x (524/2) = 17.4589, which is strong rejection
Q4.1: The potential outcomes framework provides a way to quantify causal effects. For a hypothetical intervention, it defines the causal effect for an individual as the difference between the outcomes that would be observed for that individual with versus without the exposure or intervention under consideration.
Q4.2: The Average Treatment Effect (ATE) is the expected effect on the outcome if everyone in the population were treated (or among individuals from the population who were randomly assigned to treatment)
Q4.3: adding pictures as submission
Q4.5: If you have a randomized trial, then ATE = ATT, and we see that under random assignment, the estimated coefficients of D are roughly equal to each other. Without random assignment, the estimated coefficients of D changed quite a lot between models.