#install.packages("wooldridge")
require(wooldridge)
## Loading required package: wooldridge
require(tidyverse)
## Loading required package: tidyverse
## -- Attaching packages --------------------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.3 v dplyr 1.0.2
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## -- Conflicts ------------------------------------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
#Dados de fertilidade - página 324 Modelo 1: ajuste do modelo estático
data(fertil3)
dados = fertil3 %>%
mutate(ww2 = factor(ww2),pill = factor(pill))
model1 = lm(gfr ~ pe + ww2 + pill,data=dados)
model1
##
## Call:
## lm(formula = gfr ~ pe + ww2 + pill, data = dados)
##
## Coefficients:
## (Intercept) pe ww21 pill1
## 98.68176 0.08254 -24.23840 -31.59403
summary(model1)
##
## Call:
## lm(formula = gfr ~ pe + ww2 + pill, data = dados)
##
## Residuals:
## Min 1Q Median 3Q Max
## -27.0187 -9.6195 0.3393 9.4746 28.0730
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 98.68176 3.20813 30.760 < 2e-16 ***
## pe 0.08254 0.02965 2.784 0.00694 **
## ww21 -24.23840 7.45825 -3.250 0.00180 **
## pill1 -31.59403 4.08107 -7.742 6.46e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.69 on 68 degrees of freedom
## Multiple R-squared: 0.4734, Adjusted R-squared: 0.4502
## F-statistic: 20.38 on 3 and 68 DF, p-value: 1.575e-09
car::S(model1)
## Call: lm(formula = gfr ~ pe + ww2 + pill, data = dados)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 98.68176 3.20813 30.760 < 2e-16 ***
## pe 0.08254 0.02965 2.784 0.00694 **
## ww21 -24.23840 7.45825 -3.250 0.00180 **
## pill1 -31.59403 4.08107 -7.742 6.46e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard deviation: 14.69 on 68 degrees of freedom
## Multiple R-squared: 0.4734
## F-statistic: 20.38 on 3 and 68 DF, p-value: 1.575e-09
## AIC BIC
## 597.12 608.50
car::residualPlots(model1)
## Test stat Pr(>|Test stat|)
## pe 1.7964 0.07693 .
## ww2
## pill
## Tukey test -0.6590 0.50987
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::qqPlot(model1)
## [1] 2 51
car::marginalModelPlots(model1)
car::vif(model1)
## pe ww2 pill
## 1.255727 1.200148 1.179930
dados = dados %>%
select(pe,ww2,pill,gfr,year)
dados = dados %>%
mutate(pe_1=lag(pe,1),pe_2=lag(pe,2))
dados
## pe ww2 pill gfr year pe_1 pe_2
## 1 0.00 0 0 124.7 1913 NA NA
## 2 0.00 0 0 126.6 1914 0.00 NA
## 3 0.00 0 0 125.0 1915 0.00 0.00
## 4 0.00 0 0 123.4 1916 0.00 0.00
## 5 19.27 0 0 121.0 1917 0.00 0.00
## 6 23.94 0 0 119.8 1918 19.27 0.00
## 7 20.07 0 0 111.2 1919 23.94 19.27
## 8 15.33 0 0 117.9 1920 20.07 23.94
## 9 34.32 0 0 119.8 1921 15.33 20.07
## 10 36.65 0 0 111.2 1922 34.32 15.33
## 11 25.83 0 0 110.5 1923 36.65 34.32
## 12 27.34 0 0 110.9 1924 25.83 36.65
## 13 22.85 0 0 106.6 1925 27.34 25.83
## 14 21.13 0 0 102.6 1926 22.85 27.34
## 15 24.61 0 0 99.8 1927 21.13 22.85
## 16 31.96 0 0 93.8 1928 24.61 21.13
## 17 27.29 0 0 89.2 1929 31.96 24.61
## 18 18.40 0 0 89.2 1930 27.29 31.96
## 19 14.91 0 0 84.6 1931 18.40 27.29
## 20 28.36 0 0 81.7 1932 14.91 18.40
## 21 31.95 0 0 76.3 1933 28.36 14.91
## 22 33.91 0 0 78.5 1934 31.95 28.36
## 23 36.98 0 0 77.2 1935 33.91 31.95
## 24 50.12 0 0 75.8 1936 36.98 33.91
## 25 42.79 0 0 77.1 1937 50.12 36.98
## 26 32.22 0 0 79.1 1938 42.79 50.12
## 27 36.53 0 0 77.6 1939 32.22 42.79
## 28 53.33 0 0 79.9 1940 36.53 32.22
## 29 102.49 1 0 83.4 1941 53.33 36.53
## 30 137.70 1 0 91.5 1942 102.49 53.33
## 31 141.20 1 0 94.3 1943 137.70 102.49
## 32 243.83 1 0 88.4 1944 141.20 137.70
## 33 238.40 1 0 85.9 1945 243.83 141.20
## 34 193.16 0 0 101.9 1946 238.40 243.83
## 35 168.90 0 0 113.3 1947 193.16 238.40
## 36 149.79 0 0 107.3 1948 168.90 193.16
## 37 147.05 0 0 107.1 1949 149.79 168.90
## 38 163.10 0 0 106.2 1950 147.05 149.79
## 39 178.14 0 0 111.5 1951 163.10 147.05
## 40 189.43 0 0 113.9 1952 178.14 163.10
## 41 186.51 0 0 115.2 1953 189.43 178.14
## 42 165.46 0 0 118.1 1954 186.51 189.43
## 43 170.57 0 0 118.5 1955 165.46 186.51
## 44 171.00 0 0 121.2 1956 170.57 165.46
## 45 165.12 0 0 122.9 1957 171.00 170.57
## 46 158.66 0 0 120.2 1958 165.12 171.00
## 47 162.19 0 0 118.8 1959 158.66 165.12
## 48 158.28 0 0 118.0 1960 162.19 158.66
## 49 160.71 0 0 117.2 1961 158.28 162.19
## 50 161.58 0 0 112.2 1962 160.71 158.28
## 51 161.61 0 1 108.5 1963 161.58 160.71
## 52 142.73 0 1 105.0 1964 161.61 161.58
## 53 134.60 0 1 96.6 1965 142.73 161.61
## 54 133.94 0 1 91.3 1966 134.60 142.73
## 55 133.80 0 1 87.6 1967 133.94 134.60
## 56 145.10 0 1 85.7 1968 133.80 133.94
## 57 142.62 0 1 86.5 1969 145.10 133.80
## 58 130.58 0 1 87.9 1970 142.62 145.10
## 59 132.99 0 1 81.8 1971 130.58 142.62
## 60 144.85 0 1 73.4 1972 132.99 130.58
## 61 140.87 0 1 69.2 1973 144.85 132.99
## 62 130.49 0 1 68.4 1974 140.87 144.85
## 63 122.36 0 1 66.0 1975 130.49 140.87
## 64 120.08 0 1 65.8 1976 122.36 130.49
## 65 116.11 0 1 66.8 1977 120.08 122.36
## 66 118.98 0 1 65.5 1978 116.11 120.08
## 67 132.93 0 1 67.2 1979 118.98 116.11
## 68 123.17 0 1 68.4 1980 132.93 118.98
## 69 119.31 0 1 67.4 1981 123.17 132.93
## 70 102.04 0 1 67.3 1982 119.31 123.17
## 71 92.49 0 1 65.8 1983 102.04 119.31
## 72 83.90 0 1 65.4 1984 92.49 102.04
model2 = lm(gfr ~ pe + pe_1 + pe_2 + ww2 + pill,data=dados)
model2
##
## Call:
## lm(formula = gfr ~ pe + pe_1 + pe_2 + ww2 + pill, data = dados)
##
## Coefficients:
## (Intercept) pe pe_1 pe_2 ww21 pill1
## 95.87050 0.07267 -0.00578 0.03383 -22.12650 -31.30499
summary(model2)
##
## Call:
## lm(formula = gfr ~ pe + pe_1 + pe_2 + ww2 + pill, data = dados)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.6461 -9.5409 -0.0312 8.3378 29.1295
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 95.87050 3.28196 29.211 < 2e-16 ***
## pe 0.07267 0.12553 0.579 0.5647
## pe_1 -0.00578 0.15566 -0.037 0.9705
## pe_2 0.03383 0.12626 0.268 0.7896
## ww21 -22.12650 10.73197 -2.062 0.0433 *
## pill1 -31.30499 3.98156 -7.862 5.63e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.27 on 64 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.4986, Adjusted R-squared: 0.4594
## F-statistic: 12.73 on 5 and 64 DF, p-value: 1.353e-08
car::S(model2)
## Call: lm(formula = gfr ~ pe + pe_1 + pe_2 + ww2 + pill, data = dados)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 95.87050 3.28196 29.211 < 2e-16 ***
## pe 0.07267 0.12553 0.579 0.5647
## pe_1 -0.00578 0.15566 -0.037 0.9705
## pe_2 0.03383 0.12626 0.268 0.7896
## ww21 -22.12650 10.73197 -2.062 0.0433 *
## pill1 -31.30499 3.98156 -7.862 5.63e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard deviation: 14.27 on 64 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.4986
## F-statistic: 12.73 on 5 and 64 DF, p-value: 1.353e-08
## AIC BIC
## 578.52 594.26
car::residualPlots(model2)
## Test stat Pr(>|Test stat|)
## pe 1.1992 0.23493
## pe_1 1.4842 0.14273
## pe_2 2.1005 0.03969 *
## ww2
## pill
## Tukey test -0.9888 0.32276
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::qqPlot(model2)
## [1] 3 51
car::marginalModelPlots(model2)
car::vif(model2)
## pe pe_1 pe_2 ww2 pill
## 22.238847 35.407682 24.092658 2.625982 1.174410
dados = dados %>%
mutate(pe_3=lag(pe,3),pe_4=lag(pe,4))
dados
## pe ww2 pill gfr year pe_1 pe_2 pe_3 pe_4
## 1 0.00 0 0 124.7 1913 NA NA NA NA
## 2 0.00 0 0 126.6 1914 0.00 NA NA NA
## 3 0.00 0 0 125.0 1915 0.00 0.00 NA NA
## 4 0.00 0 0 123.4 1916 0.00 0.00 0.00 NA
## 5 19.27 0 0 121.0 1917 0.00 0.00 0.00 0.00
## 6 23.94 0 0 119.8 1918 19.27 0.00 0.00 0.00
## 7 20.07 0 0 111.2 1919 23.94 19.27 0.00 0.00
## 8 15.33 0 0 117.9 1920 20.07 23.94 19.27 0.00
## 9 34.32 0 0 119.8 1921 15.33 20.07 23.94 19.27
## 10 36.65 0 0 111.2 1922 34.32 15.33 20.07 23.94
## 11 25.83 0 0 110.5 1923 36.65 34.32 15.33 20.07
## 12 27.34 0 0 110.9 1924 25.83 36.65 34.32 15.33
## 13 22.85 0 0 106.6 1925 27.34 25.83 36.65 34.32
## 14 21.13 0 0 102.6 1926 22.85 27.34 25.83 36.65
## 15 24.61 0 0 99.8 1927 21.13 22.85 27.34 25.83
## 16 31.96 0 0 93.8 1928 24.61 21.13 22.85 27.34
## 17 27.29 0 0 89.2 1929 31.96 24.61 21.13 22.85
## 18 18.40 0 0 89.2 1930 27.29 31.96 24.61 21.13
## 19 14.91 0 0 84.6 1931 18.40 27.29 31.96 24.61
## 20 28.36 0 0 81.7 1932 14.91 18.40 27.29 31.96
## 21 31.95 0 0 76.3 1933 28.36 14.91 18.40 27.29
## 22 33.91 0 0 78.5 1934 31.95 28.36 14.91 18.40
## 23 36.98 0 0 77.2 1935 33.91 31.95 28.36 14.91
## 24 50.12 0 0 75.8 1936 36.98 33.91 31.95 28.36
## 25 42.79 0 0 77.1 1937 50.12 36.98 33.91 31.95
## 26 32.22 0 0 79.1 1938 42.79 50.12 36.98 33.91
## 27 36.53 0 0 77.6 1939 32.22 42.79 50.12 36.98
## 28 53.33 0 0 79.9 1940 36.53 32.22 42.79 50.12
## 29 102.49 1 0 83.4 1941 53.33 36.53 32.22 42.79
## 30 137.70 1 0 91.5 1942 102.49 53.33 36.53 32.22
## 31 141.20 1 0 94.3 1943 137.70 102.49 53.33 36.53
## 32 243.83 1 0 88.4 1944 141.20 137.70 102.49 53.33
## 33 238.40 1 0 85.9 1945 243.83 141.20 137.70 102.49
## 34 193.16 0 0 101.9 1946 238.40 243.83 141.20 137.70
## 35 168.90 0 0 113.3 1947 193.16 238.40 243.83 141.20
## 36 149.79 0 0 107.3 1948 168.90 193.16 238.40 243.83
## 37 147.05 0 0 107.1 1949 149.79 168.90 193.16 238.40
## 38 163.10 0 0 106.2 1950 147.05 149.79 168.90 193.16
## 39 178.14 0 0 111.5 1951 163.10 147.05 149.79 168.90
## 40 189.43 0 0 113.9 1952 178.14 163.10 147.05 149.79
## 41 186.51 0 0 115.2 1953 189.43 178.14 163.10 147.05
## 42 165.46 0 0 118.1 1954 186.51 189.43 178.14 163.10
## 43 170.57 0 0 118.5 1955 165.46 186.51 189.43 178.14
## 44 171.00 0 0 121.2 1956 170.57 165.46 186.51 189.43
## 45 165.12 0 0 122.9 1957 171.00 170.57 165.46 186.51
## 46 158.66 0 0 120.2 1958 165.12 171.00 170.57 165.46
## 47 162.19 0 0 118.8 1959 158.66 165.12 171.00 170.57
## 48 158.28 0 0 118.0 1960 162.19 158.66 165.12 171.00
## 49 160.71 0 0 117.2 1961 158.28 162.19 158.66 165.12
## 50 161.58 0 0 112.2 1962 160.71 158.28 162.19 158.66
## 51 161.61 0 1 108.5 1963 161.58 160.71 158.28 162.19
## 52 142.73 0 1 105.0 1964 161.61 161.58 160.71 158.28
## 53 134.60 0 1 96.6 1965 142.73 161.61 161.58 160.71
## 54 133.94 0 1 91.3 1966 134.60 142.73 161.61 161.58
## 55 133.80 0 1 87.6 1967 133.94 134.60 142.73 161.61
## 56 145.10 0 1 85.7 1968 133.80 133.94 134.60 142.73
## 57 142.62 0 1 86.5 1969 145.10 133.80 133.94 134.60
## 58 130.58 0 1 87.9 1970 142.62 145.10 133.80 133.94
## 59 132.99 0 1 81.8 1971 130.58 142.62 145.10 133.80
## 60 144.85 0 1 73.4 1972 132.99 130.58 142.62 145.10
## 61 140.87 0 1 69.2 1973 144.85 132.99 130.58 142.62
## 62 130.49 0 1 68.4 1974 140.87 144.85 132.99 130.58
## 63 122.36 0 1 66.0 1975 130.49 140.87 144.85 132.99
## 64 120.08 0 1 65.8 1976 122.36 130.49 140.87 144.85
## 65 116.11 0 1 66.8 1977 120.08 122.36 130.49 140.87
## 66 118.98 0 1 65.5 1978 116.11 120.08 122.36 130.49
## 67 132.93 0 1 67.2 1979 118.98 116.11 120.08 122.36
## 68 123.17 0 1 68.4 1980 132.93 118.98 116.11 120.08
## 69 119.31 0 1 67.4 1981 123.17 132.93 118.98 116.11
## 70 102.04 0 1 67.3 1982 119.31 123.17 132.93 118.98
## 71 92.49 0 1 65.8 1983 102.04 119.31 123.17 132.93
## 72 83.90 0 1 65.4 1984 92.49 102.04 119.31 123.17
model3 = lm(gfr ~ pe + pe_1 + pe_2 + pe_3 + pe_4 + ww2 + pill,data=dados)
model3
##
## Call:
## lm(formula = gfr ~ pe + pe_1 + pe_2 + pe_3 + pe_4 + ww2 + pill,
## data = dados)
##
## Coefficients:
## (Intercept) pe pe_1 pe_2 pe_3 pe_4
## 92.501551 0.088749 -0.003977 0.007395 0.018083 0.013940
## ww21 pill1
## -21.343483 -31.081643
summary(model3)
##
## Call:
## lm(formula = gfr ~ pe + pe_1 + pe_2 + pe_3 + pe_4 + ww2 + pill,
## data = dados)
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.226 -9.528 -1.111 8.016 27.068
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 92.501551 3.325483 27.816 < 2e-16 ***
## pe 0.088749 0.126185 0.703 0.4846
## pe_1 -0.003977 0.153111 -0.026 0.9794
## pe_2 0.007395 0.165102 0.045 0.9644
## pe_3 0.018083 0.153589 0.118 0.9067
## pe_4 0.013940 0.105024 0.133 0.8948
## ww21 -21.343483 11.540771 -1.849 0.0693 .
## pill1 -31.081643 3.896868 -7.976 5.38e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 13.67 on 60 degrees of freedom
## (4 observations deleted due to missingness)
## Multiple R-squared: 0.5368, Adjusted R-squared: 0.4828
## F-statistic: 9.934 on 7 and 60 DF, p-value: 3.633e-08
car::S(model3)
## Call: lm(formula = gfr ~ pe + pe_1 + pe_2 + pe_3 + pe_4 + ww2 + pill, data =
## dados)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 92.501551 3.325483 27.816 < 2e-16 ***
## pe 0.088749 0.126185 0.703 0.4846
## pe_1 -0.003977 0.153111 -0.026 0.9794
## pe_2 0.007395 0.165102 0.045 0.9644
## pe_3 0.018083 0.153589 0.118 0.9067
## pe_4 0.013940 0.105024 0.133 0.8948
## ww21 -21.343483 11.540771 -1.849 0.0693 .
## pill1 -31.081643 3.896868 -7.976 5.38e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard deviation: 13.67 on 60 degrees of freedom
## (4 observations deleted due to missingness)
## Multiple R-squared: 0.5368
## F-statistic: 9.934 on 7 and 60 DF, p-value: 3.633e-08
## AIC BIC
## 558.14 578.11
car::residualPlots(model3)
## Test stat Pr(>|Test stat|)
## pe 0.3639 0.717198
## pe_1 0.7943 0.430231
## pe_2 1.7128 0.092000 .
## pe_3 2.8742 0.005625 **
## pe_4 2.8643 0.005781 **
## ww2
## pill
## Tukey test -1.0861 0.277432
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::qqPlot(model3)
## [1] 5 51
car::marginalModelPlots(model3)
car::vif(model3)
## pe pe_1 pe_2 pe_3 pe_4 ww2 pill
## 22.613849 34.635695 41.842476 37.548372 18.143900 3.301391 1.209285
temp <-dados[5:nrow(dados),]
model5 <- lm( gfr ~ poly(pe,2) +
poly(pe_1,2)+
poly(pe_2,2)+
poly(pe_3,2)+
poly(pe_4,2)+
ww2+pill, data = temp)
car::S(model5)
## Call: lm(formula = gfr ~ poly(pe, 2) + poly(pe_1, 2) + poly(pe_2, 2) +
## poly(pe_3, 2) + poly(pe_4, 2) + ww2 + pill, data = temp)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 102.157 2.747 37.183 < 2e-16 ***
## poly(pe, 2)1 140.773 94.074 1.496 0.14027
## poly(pe, 2)2 -9.245 33.264 -0.278 0.78210
## poly(pe_1, 2)1 -9.851 127.305 -0.077 0.93860
## poly(pe_1, 2)2 13.973 43.752 0.319 0.75066
## poly(pe_2, 2)1 15.881 137.743 0.115 0.90863
## poly(pe_2, 2)2 -4.706 48.439 -0.097 0.92296
## poly(pe_3, 2)1 -63.773 142.449 -0.448 0.65614
## poly(pe_3, 2)2 36.482 46.596 0.783 0.43703
## poly(pe_4, 2)1 -22.742 105.030 -0.217 0.82938
## poly(pe_4, 2)2 37.440 32.765 1.143 0.25812
## ww21 -31.175 13.337 -2.337 0.02309 *
## pill1 -18.410 6.074 -3.031 0.00371 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard deviation: 13.17 on 55 degrees of freedom
## Multiple R-squared: 0.6061
## F-statistic: 7.052 on 12 and 55 DF, p-value: 1.503e-07
## AIC BIC
## 557.12 588.19
car::residualPlots(model5)
## Test stat Pr(>|Test stat|)
## poly(pe, 2)
## poly(pe_1, 2)
## poly(pe_2, 2)
## poly(pe_3, 2)
## poly(pe_4, 2)
## ww2
## pill
## Tukey test -3.1184 0.001819 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::qqPlot(model5)
## 34 36
## 30 32
car::marginalModelPlots(model5)
car::vif(model5)
## GVIF Df GVIF^(1/(2*Df))
## poly(pe, 2) 187.714865 2 3.701474
## poly(pe_1, 2) 406.742037 2 4.490863
## poly(pe_2, 2) 614.076560 2 4.978008
## poly(pe_3, 2) 499.564670 2 4.727678
## poly(pe_4, 2) 166.533197 2 3.592322
## ww2 4.752806 1 2.180093
## pill 3.166911 1 1.779582
https://cran.r-project.org/web/packages/matlib/vignettes/linear-equations.html
#install.packages("matlib")
#require(matlib)
temp= fertil3 %>%
select(pe,ww2,pill,gfr,year)
temp= temp %>%
mutate(x1 = pe + lag(pe,1) + lag(pe,2) + lag(pe,3) + lag(pe,4),
x2 = lag(pe,1) + 2*lag(pe,2) + 3*lag(pe,3) + 4*lag(pe,4),
x3 = lag(pe,1) + 4*lag(pe,2) + 9*lag(pe,3) + 16*lag(pe,4))
temp=temp[5:nrow(temp),]
model6 = lm(gfr ~ x1+x2+x3,data=temp)
car::S(model6)
## Call: lm(formula = gfr ~ x1 + x2 + x3, data = temp)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 89.83667 4.62449 19.426 <2e-16 ***
## x1 -0.02485 0.09195 -0.270 0.788
## x2 0.07714 0.15806 0.488 0.627
## x3 -0.02029 0.03909 -0.519 0.606
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard deviation: 19.22 on 64 degrees of freedom
## Multiple R-squared: 0.02317
## F-statistic: 0.506 on 3 and 64 DF, p-value: 0.6795
## AIC BIC
## 600.88 611.98
car::residualPlots(model6)
## Test stat Pr(>|Test stat|)
## x1 9.0858 4.602e-13 ***
## x2 8.2727 1.191e-11 ***
## x3 7.6338 1.560e-10 ***
## Tukey test 2.4291 0.01514 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::qqPlot(model6)
## 5 6
## 1 2
car::marginalModelPlots(model6)
car::vif(model6)
## x1 x2 x3
## 151.7728 1917.8454 1080.8485