# Untitled

Apr 15th, 2021
536
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. ########## 7) ##########
2. u_lags_D <- u_lags
3. y_lags_D <- y_lags
4.
5. for (i in 1:4) {
6.    u_lags_D[[i]] <- u_lags[[i]]*df\$D[index]
7.    y_lags_D[[i]] <- y_lags[[i]]*df\$D[index]
8. }
9.
10. #### k = 2
11. m7_2 <- lm(Uc_lag ~ u_lags[[1]] + u_lags[[2]] + y_lags[[1]] + y_lags[[2]] + y_lags_D[[1]] + y_lags_D[[2]] - 1)
12. print(summary(m7_2))
13. delta_m7_2 <- coefficients(m7_2)
14. sigma_m7_2 <- vcov(m7_2)
15.
16. # a_LR pred zlomem (k = 2)
17. a_LR_m7_2_before = sum(delta_m7_2[3:4])/(1-sum(delta_m7_2[1:2]))
18. print(a_LR_m7_2_before)
19.
20. # a_LR po zlomu (k = 2)
21. a_LR_m7_2_after = sum(delta_m7_2[3:4] + delta_m7_2[5:6])/(1-sum(delta_m7_2[1:2]))
22. print(a_LR_m7_2_after)
23.
24.
25.
26. #### k = 4
27. m7_4 <- lm(Uc_lag ~ u_lags[[1]] + u_lags[[2]] + u_lags[[3]] + u_lags[[4]] +
28.                  y_lags[[1]] + y_lags[[2]] + y_lags[[3]] + y_lags[[4]] +
29.                  y_lags_D[[1]] + y_lags_D[[2]] + y_lags_D[[3]] + y_lags_D[[4]] - 1)
30. print(summary(m7_4))
31. delta_m7_4 <- coefficients(m7_4)
32. sigma_m7_4 <- vcov(m7_4)
33.
34. # a_LR pred zlomem (k = 4)
35. a_LR_m7_4_before = sum(delta_m7_4[5:8])/(1-sum(delta_m7_4[1:4]))
36. print(a_LR_m7_4_before)
37.
38. # a_LR po zlomu (k = 4)
39. a_LR_m7_4_after = sum(delta_m7_4[5:8] + delta_m7_4[9:12])/(1-sum(delta_m7_4[1:4]))
40. print(a_LR_m7_4_after)
41.
42. # 8.
43.
44. m8_2 = lm(Uc_lag ~ u_lags[[1]] + u_lags[[2]] + y_lags[[1]] + y_lags[[2]] + u_lags_D[[1]] +
45.             u_lags_D[[2]] + y_lags_D[[1]] + y_lags_D[[2]] - 1)
46.
47. print(summary(m8_2))
48. delta_m8_2 <- coefficients(m8_2)
49. sigma_m8_2 <- vcov(m8_2)
50.
51. # a_LR pre k=2 pred zlomom
52. a_LR_m8_2_before = sum(delta_m8_2[3:4])/(1-sum(delta_m8_2[1:2]))
53. print(a_LR_m8_2_before)
54.
55. #a_LR pre k=2 po zlome
56. a_LR_m8_2_after = sum(delta_m8_2[5:8] + delta_m8_2[9:12])/(1-sum(delta_m8_2[1:4]))
57. print(a_LR_m8_2_after)
58.
59.
60. # m_8 pre k = 4
61. m8_4 <- lm(Uc_lag ~ u_lags[[1]] + u_lags[[2]] + u_lags[[3]] + u_lags[[4]] +
62.                         y_lags[[1]] + y_lags[[2]] + y_lags[[3]] + y_lags[[4]] +
63.                         u_lags_D[[1]] + u_lags_D[[2]] + u_lags_D[[3]] + u_lags_D[[3]] + u_lags_D[[4]] +
64.                         y_lags_D[[1]] + y_lags_D[[2]] + y_lags_D[[3]] + y_lags_D[[4]] - 1)
65.
66. summary(m8_4)
67. delta_m8_4 <- coefficients(m8_4)
68. sigma_m8_4 <- vcov(m8_4)
69.
70. # a_LR pred zlomem (k = 4)
71. a_LR_m8_4_before = sum(delta_m8_4[5:8])/(1-sum(delta_m8_4[1:4]))
72. print(a_LR_m8_4_before)
73.
74. # a_LR po zlomu (k = 4)
75. a_LR_m8_4_after = sum(delta_m8_4[5:8] + delta_m8_4[9:12])/(1-sum(delta_m8_4[1:4]))
76. print(a_LR_m8_4_after)
RAW Paste Data