##### Exam 2 - Answers (Code) ###### ######## QUESTION 3 ######## RE_da <- read.csv("http://www.bauer.uh.edu/rsusmel/4397/Real_Estate_2023.csv", head=TRUE, sep=",") summary(RE_da) x_date <- RE_da$DATE x_sf <- RE_da$SF_c x_sd <- RE_da$SD_c x_usa <- RE_da$USA_c u_sf <- RE_da$SF_u u_sd <- RE_da$SD_u x_tech <- RE_da$Tech_c Cind <- RE_da$Cind_c Nind <- RE_da$Nind_c x_Mkt <- RE_da$Mkt_RF x_SMB <- RE_da$SMB x_HML <- RE_da$HML x_RMW <- RE_da$RMW x_CMA <- RE_da$CMA x_RF <- RE_da$RF Mkt_RF <- x_Mkt/100 SMB <- x_SMB/100 HML <- x_HML/100 RMW <- x_RMW/100 CMA <- x_CMA/100 RF <- x_RF/100 oil <- RE_da$Oil gold <- RE_da$Gold zz <- x_sf T <- length(x_sd) T_sb <- 224 T_end_reg2 <- T - T_sb Fin_c0 <- rep(0,T_sb) Fin_c1 <- rep(1,T_end_reg2) Fin_c <- c(Fin_c0,Fin_c1) # Create 2008 Financial crisis dummy Feb1 <- rep(c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (length(zz)/12+1)) # Create January dummy Mar1 <- rep(c(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (length(zz)/12+1)) # Create March dummy Apr1 <- rep(c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), (length(zz)/12+1)) # Create April dummy May1 <- rep(c(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0), (length(zz)/12+1)) # Create May dummy Jun1 <- rep(c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0), (length(zz)/12+1)) # Create June dummy Jul1 <- rep(c(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), (length(zz)/12+1)) # Create Jul dummy Aug1 <- rep(c(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), (length(zz)/12+1)) # Create Aug dummy Sep1 <- rep(c(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0), (length(zz)/12+1)) # Create Sep dummy Oct1 <- rep(c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0), (length(zz)/12+1)) # Create Oct dummy Nov1 <- rep(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0), (length(zz)/12+1)) # Create Oct dummy Dec1 <- rep(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0), (length(zz)/12+1)) # Create Oct dummy Feb <- Feb1[1:T] Mar <- Mar1[1:T] Apr <- Apr1[1:T] May <- May1[1:T] Jun <- Jun1[1:T] Jul <- Jul1[1:T] Aug <- Aug1[1:T] Sep <- Sep1[1:T] Oct <- Oct1[1:T] Nov <- Nov1[1:T] Dec <- Dec1[1:T] Spring <- Mar + Apr + May Summ <- Jun + Jul + Aug Fall <- Sep + Oct + Nov u_sf2 <- u_sf^2 x_usa2 <- x_usa^2 x_tech2 <- x_tech^2 Cind2 <- Cind^2 u_sf_Cind <- u_sf*Cind u_sf_tech <- u_sf*x_tech u_sf_Spring <- u_sf*Spring u_sf_Summ <- u_sf*Summ u_sf_Fall <- u_sf*Fall Cind_Spring <- Cind*Spring Cind_Summ <- Cind*Summ Cind_Fall <- Cind*Fall tech_Spring <- x_tech*Spring tech_Summ <- x_tech*Summ tech_Fall <- x_tech*Fall u_sf_Finc <- u_sf*Fin_c Cind_Finc <- Cind*Fin_c tech_Finc <- x_tech*Fin_c Finc_Spring <- Fin_c*Spring Finc_Summ <- Fin_c*Summ Finc_Fall <- Fin_c*Fall ## 1.a - Report GUM fit_sf_gum <- lm(formula = x_sf ~ x_usa + u_sf + x_tech + Cind + + Mkt_RF + SMB + HML + RMW + CMA + gold + oil + x_usa2 + u_sf2 + Cind2 + x_tech2 + Spring + Summ + Fall + Fin_c + u_sf_Cind + u_sf_tech + u_sf_Spring + u_sf_Summ + u_sf_Fall + Cind_Spring + Cind_Summ + Cind_Fall + tech_Spring + tech_Summ + tech_Fall + u_sf_Finc + Cind_Finc + tech_Finc + Finc_Spring + Finc_Summ + Finc_Fall) summary(fit_sf_gum) ## 1.b Use p-value = 0.05. Report reduced model fit_sf_red <- lm(x_sf ~ x_usa + u_sf + x_usa2 + Fin_c + Cind_Spring + u_sf_Finc + Cind_Fall) summary(fit_sf_red) ## 1,c Report R2 # R2 = 70.67% (70.67% of variability of sf changes in prices explained by factors in reduced model) ## 1.d - Drivers (variables with significant t-stats a) # Drivers: x_usa, u_sf, x_usa2, Financial crisis, interactions terms with Financial crisis and Economic Conditions with Spring & Falll ## 1.e - Evidence of Seasonality? # None of the seasonal dummies shows up as significant directly, but the indirect effect of Spring with Economic Conditions is very significant in the Reduced Model. ## 1.f - LM Tests for autocorrelation (DW & BG) and Heteroscedasticity (GQ & BP) dwtest(fit_sf_red) bgtest(fit_sf_red, order=4) ## 1.g - LM Tests for autocorrelation (DW & BG) and Heteroscedasticity (GQ & BP) gqtest(fit_sf_red) bptest(fit_sf_red) ## 1.h - White and NW SE # At 5% level, we have evidence of both heteroscedasticiy & autocorrelation. Then, use NW SE. Var_NW <- NeweyWest(fit_sf_red, lag = 12) SE_NW <- sqrt(diag(Var_NW)) b_sf_red <- fit_sf_red$coefficients t_b_NW <- b_sf_red/SE_NW t_b_NW # Once, we take into account autocorrelation and heteroscedasticity the signficance at 5% level not affected ######## QUESTION 2 ######## ## 2.a Model For Dependent Variable (y = x_sf) y <- x_sf T1 <- 396 xx <- cbind(x_usa, u_sf) # Independent Variables y1 <- y[1:T1] # Estimation period data xx1 <- xx[1:T1,] # Estimation period data fit_y <- lm(y ~ xx) # Estimation Period Regression for SF_c b_y <- fit_y$coefficients summary(fit_y) ## 2.b Model Forecast p_t+1 = (SF_c_t+1) k_for <- T-T1 xx_cons <- rep(1,T_for) T_val <- T1 + 1 y_f0 <- cbind(xx_cons,xx[T1:(T-1)])%*% b_y1 # b_est coefficients from estimation period regresssion e_f0 <- y_f0 - y[T_val:T] # Forecasat error mse_e_f0 <- sum(e_f0^2)/k_for # MSE mse_e_f0 # MSE(2) => et(2) ## 2.c RW Forecast p_t+1 = (SF_c_t+1) e_rw_f0 <- y[T_val:T] - y[T1:(T-1)] # Error for RW model => et (1) mse_e_rw_f0 <- sum(e_rw_f0^2)/k_for mse_e_rw_f0 ## 2.d Testing Equality of MSE: Model vs RW z_mgn <- e_rw_f0 + e_f0 x_mgn <- e_rw_f0 - e_f0 fit_mgn <- lm(z_mgn ~ x_mgn) summary(fit_mgn) ######## QUESTION 3 ######## SFX_da <- read.csv("http://www.bauer.uh.edu/rsusmel/4397/Stocks_FX_1973.csv",head=TRUE,sep=",") names(SFX_da) x_dat <- SFX_da$Date x_unp <- SFX_da$UNP x_xom <- SFX_da$XOM x_Mkt_RF<- SFX_da$Mkt_RF x_SMB <- SFX_da$SMB x_HML <- SFX_da$HML x_CMA <- SFX_da$CMA x_RMW <- SFX_da$RMW x_RF <- SFX_da$RF T <- length(x_SMB) lr_unp <- log(x_unp[-1]/x_unp[-T]) Mkt_RF <- x_Mkt_RF[-1]/100 SMB <- x_SMB[-1]/100 HML <- x_HML[-1]/100 CMA <- x_CMA[-1]/100 RMW <- x_RMW[-1]/100 RF <- x_RF[-1]/100 unp_x <- lr_unp - RF # UNP excess returns ## 3.a fit1 <- lm(unp_x ~ Mkt_RF + SMB + HML) # Model 1 summary(fit1) fit2 <- lm(unp_x ~ Mkt_RF + CMA + RMW) # Model 2 summary(fit2) ## 3.b library(lmtest) jtest(fit1,fit2) ## 3.c fit_enc <- lm( unp_x ~ Mkt_RF + SMB + HML + lr_cs + CMA + RMW) summary(fit_enc) encomptest(fit1,fit2) ######## QUESTION 4 - THEORY REVIEW ###### # 4.a. False. IF there is endogeneity -i.e., X is related to error term-, OLS is inconsistent. # 4.b. True. NWSE are not efficient. Estimators that incorporate the true model for (A3) will be efficient. # 4.c. False. The reverse is true. # 4.d. True. The asymptotic distribution gives an approximation to the small sample distribution (hopefully, a good one) # 4.e. False. Type I and Type II errors make this task impossible for GETS.