In this paper we present several methods useful for diagnosing violations of the basic regression assumptions. These diagnostic methods are primarily based on study of the model residuals . Methods for dealing with model inadequacies, as well as additional, more sophisticated diagnostics
library(RcmdrMisc)
## Loading required package: car
## Loading required package: carData
## Loading required package: sandwich
library(Rcpp)
library(olsrr)
##
## Attaching package: 'olsrr'
## The following object is masked from 'package:datasets':
##
## rivers
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:car':
##
## recode
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(DataExplorer)
library(performance)
library(sjPlot)
## Registered S3 methods overwritten by 'parameters':
## method from
## as.double.parameters_kurtosis datawizard
## as.double.parameters_skewness datawizard
## as.double.parameters_smoothness datawizard
## as.numeric.parameters_kurtosis datawizard
## as.numeric.parameters_skewness datawizard
## as.numeric.parameters_smoothness datawizard
## print.parameters_distribution datawizard
## print.parameters_kurtosis datawizard
## print.parameters_skewness datawizard
## summary.parameters_kurtosis datawizard
## summary.parameters_skewness datawizard
## Registered S3 methods overwritten by 'lme4':
## method from
## cooks.distance.influence.merMod car
## influence.merMod car
## dfbeta.influence.merMod car
## dfbetas.influence.merMod car
## Learn more about sjPlot with 'browseVignettes("sjPlot")'.
library(fBasics)
## Loading required package: timeDate
## Loading required package: timeSeries
##
## Attaching package: 'fBasics'
## The following object is masked from 'package:car':
##
## densityPlot
library(qqplotr)
## Loading required package: ggplot2
##
## Attaching package: 'qqplotr'
## The following objects are masked from 'package:ggplot2':
##
## stat_qq_line, StatQqLine
library(ggstatsplot)
## You can cite this package as:
## Patil, I. (2021). Visualizations with statistical details: The 'ggstatsplot' approach.
## Journal of Open Source Software, 6(61), 3167, doi:10.21105/joss.03167
library(PerformanceAnalytics)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following object is masked from 'package:timeSeries':
##
## time<-
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
##
## first, last
##
## Attaching package: 'PerformanceAnalytics'
## The following objects are masked from 'package:timeDate':
##
## kurtosis, skewness
## The following object is masked from 'package:graphics':
##
## legend
library(see)
data(longley)
data1<-longley
str(data1)
## 'data.frame': 16 obs. of 7 variables:
## $ GNP.deflator: num 83 88.5 88.2 89.5 96.2 ...
## $ GNP : num 234 259 258 285 329 ...
## $ Unemployed : num 236 232 368 335 210 ...
## $ Armed.Forces: num 159 146 162 165 310 ...
## $ Population : num 108 109 110 111 112 ...
## $ Year : int 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 ...
## $ Employed : num 60.3 61.1 60.2 61.2 63.2 ...
head(data1)
## GNP.deflator GNP Unemployed Armed.Forces Population Year Employed
## 1947 83.0 234.289 235.6 159.0 107.608 1947 60.323
## 1948 88.5 259.426 232.5 145.6 108.632 1948 61.122
## 1949 88.2 258.054 368.2 161.6 109.773 1949 60.171
## 1950 89.5 284.599 335.1 165.0 110.929 1950 61.187
## 1951 96.2 328.975 209.9 309.9 112.075 1951 63.221
## 1952 98.1 346.999 193.2 359.4 113.270 1952 63.639
plot_scatterplot(data = data1[,-6], by="Employed",geom_point_args= list(color="steelblue"))
ggcorrmat(data = data1 %>% select(-6,-Employed))
#melihat matriks korelasi
chart.Correlation(data1[,-c(6,7)], histogram=FALSE, pch=19)
regresi=lm(Employed~.,data=data1[,-6]) #full model
regresi
##
## Call:
## lm(formula = Employed ~ ., data = data1[, -6])
##
## Coefficients:
## (Intercept) GNP.deflator GNP Unemployed Armed.Forces
## 92.461308 -0.048463 0.072004 -0.004039 -0.005605
## Population
## -0.403509
summary(regresi)
##
## Call:
## lm(formula = Employed ~ ., data = data1[, -6])
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.55324 -0.36478 0.06106 0.20550 0.93359
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 92.461308 35.169248 2.629 0.0252 *
## GNP.deflator -0.048463 0.132248 -0.366 0.7217
## GNP 0.072004 0.031734 2.269 0.0467 *
## Unemployed -0.004039 0.004385 -0.921 0.3788
## Armed.Forces -0.005605 0.002838 -1.975 0.0765 .
## Population -0.403509 0.330264 -1.222 0.2498
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4832 on 10 degrees of freedom
## Multiple R-squared: 0.9874, Adjusted R-squared: 0.9811
## F-statistic: 156.4 on 5 and 10 DF, p-value: 3.699e-09
yduga=predict(regresi)
sisa=residuals(regresi)
std_sisa=rstandard(regresi) #standardized residual
stud_sisa=rstudent(regresi) #studentized residual
hii<-hatvalues(regresi) # hii
tabel=data.frame(data1[,-c(6,7)],std_sisa,hii)
tabel
## GNP.deflator GNP Unemployed Armed.Forces Population std_sisa
## 1947 83.0 234.289 235.6 159.0 107.608 0.75794122
## 1948 88.5 259.426 232.5 145.6 108.632 -0.44157757
## 1949 88.2 258.054 368.2 161.6 109.773 0.23399140
## 1950 89.5 284.599 335.1 165.0 110.929 -1.01864180
## 1951 96.2 328.975 209.9 309.9 112.075 -1.07423034
## 1952 98.1 346.999 193.2 359.4 113.270 -1.37618542
## 1953 99.0 365.385 187.0 354.7 115.094 0.53847357
## 1954 100.0 363.112 357.8 335.0 116.219 0.62066911
## 1955 101.2 397.469 290.4 304.8 117.388 0.25505165
## 1956 104.6 419.180 282.2 285.7 118.734 2.13092045
## 1957 108.4 442.769 293.6 279.8 120.445 1.02074373
## 1958 110.8 444.546 468.1 263.7 121.950 -0.03227495
## 1959 112.6 482.704 381.3 255.2 123.366 -0.91281194
## 1960 114.2 502.601 393.1 251.4 125.368 0.07428342
## 1961 115.7 518.173 480.6 257.2 127.852 0.35388948
## 1962 116.9 554.894 400.7 282.7 130.081 -1.72338095
## hii
## 1947 0.4244630
## 1948 0.5635065
## 1949 0.3607761
## 1950 0.3719606
## 1951 0.2225697
## 1952 0.3079432
## 1953 0.4025571
## 1954 0.4688132
## 1955 0.4531780
## 1956 0.1780468
## 1957 0.2236347
## 1958 0.4826071
## 1959 0.3474087
## 1960 0.2191841
## 1961 0.3452269
## 1962 0.6281243
check_normality(regresi,effects="random")
## OK: residuals appear as normally distributed (p = 0.791).
plot(check_normality(regresi,effects="random"))
## OK: residuals appear as normally distributed (p = 0.791).
#check_model(regresi,panel=F)
#check_distribution(regresi)
#plot(check_distribution(regresi))
as.data.frame(hatvalues(regresi, infl = influence(regresi)))
## hatvalues(regresi, infl = influence(regresi))
## 1947 0.4244630
## 1948 0.5635065
## 1949 0.3607761
## 1950 0.3719606
## 1951 0.2225697
## 1952 0.3079432
## 1953 0.4025571
## 1954 0.4688132
## 1955 0.4531780
## 1956 0.1780468
## 1957 0.2236347
## 1958 0.4826071
## 1959 0.3474087
## 1960 0.2191841
## 1961 0.3452269
## 1962 0.6281243
p=6
n=16
batas_hat=2*(p/n)
batas_hat
## [1] 0.75
ols_plot_resid_lev(regresi)
# cook's distance
as.data.frame(cooks.distance(regresi, infl = influence(regresi)))
## cooks.distance(regresi, infl = influence(regresi))
## 1947 0.0706132785
## 1948 0.0419550199
## 1949 0.0051503090
## 1950 0.1024240224
## 1951 0.0550615298
## 1952 0.1404531598
## 1953 0.0325618145
## 1954 0.0566658657
## 1955 0.0089852023
## 1956 0.1639345021
## 1957 0.0500213292
## 1958 0.0001619397
## 1959 0.0739283229
## 1960 0.0002581623
## 1961 0.0110051954
## 1962 0.8361015775
Ftabel=qf(0.95,6,10) #db1=p, db2=n-p
Ftabel
## [1] 3.217175
ols_plot_cooksd_chart(regresi)
ols_plot_cooksd_bar(regresi)
# dfbetas
dfbetas(regresi, infl = lm.influence(regresi))
## (Intercept) GNP.deflator GNP Unemployed Armed.Forces
## 1947 -0.076044853 -0.151290868 -0.036044008 -0.122295705 -0.106310745
## 1948 0.202912490 -0.283119810 0.229983526 0.297985833 0.341998133
## 1949 -0.014013077 0.007122133 -0.021342769 0.035525956 0.009896758
## 1950 -0.463028332 0.489722493 -0.467902986 -0.490863841 0.042767889
## 1951 -0.126922997 -0.053800678 -0.080838022 -0.018414783 -0.071814249
## 1952 0.096791853 -0.187016359 0.136677078 0.173573140 -0.405349920
## 1953 -0.222542891 0.122298477 -0.208546078 -0.250802846 0.146750933
## 1954 -0.095536758 -0.001636120 -0.102136332 0.137441854 0.477768534
## 1955 0.176966919 -0.191190444 0.187368845 0.158850255 0.079500386
## 1956 0.783802966 -0.550322375 0.795301512 0.381028563 -0.198901123
## 1957 -0.084467319 0.269671379 -0.111370954 -0.245016873 -0.292812974
## 1958 0.004858942 -0.014573089 0.007912321 -0.004259813 -0.002127949
## 1959 -0.388292141 0.098825004 -0.355724004 -0.263768280 0.281947794
## 1960 0.003402199 0.004250879 0.003492294 -0.002427692 -0.020032704
## 1961 -0.105691268 0.046058189 -0.092580380 -0.035751025 0.020562633
## 1962 0.795718616 0.476862405 0.432515991 0.783663928 -0.097809891
## Population
## 1947 0.140061578
## 1948 -0.176589611
## 1949 0.015754603
## 1950 0.414444598
## 1951 0.160481336
## 1952 -0.066183552
## 1953 0.232351082
## 1954 0.106173660
## 1955 -0.160630899
## 1956 -0.779907323
## 1957 0.033763485
## 1958 -0.001702178
## 1959 0.433990038
## 1960 -0.005135299
## 1961 0.110472541
## 1962 -1.053100413
batas_dfbetas=2/sqrt(n)
batas_dfbetas
## [1] 0.5
ols_plot_dfbetas(regresi)
# dffits
as.data.frame(dffits(regresi, infl=influence(regresi)))
## dffits(regresi, infl = influence(regresi))
## 1947 0.63604419
## 1948 -0.48068973
## 1949 0.16722674
## 1950 -0.78557271
## 1951 -0.57975811
## 1952 -0.96728910
## 1953 0.42554014
## 1954 0.56414169
## 1955 0.22099274
## 1956 1.27341052
## 1957 0.54911963
## 1958 -0.02957305
## 1959 -0.65992417
## 1960 0.03734764
## 1961 0.24531971
## 1962 -2.53425337
batas_dffits=2*sqrt(p/n)
batas_dffits
## [1] 1.224745
ols_plot_dffits(regresi)
# mengeluarkan semua nilai
influence.measures(regresi, infl = influence(regresi))
## Influence measures of
## lm(formula = Employed ~ ., data = data1[, -6]) :
##
## dfb.1_ dfb.GNP. dfb.GNP dfb.Unmp dfb.Ar.F dfb.Pplt dffit cov.r
## 1947 -0.07604 -0.15129 -0.03604 -0.12230 -0.10631 0.14006 0.6360 2.2925
## 1948 0.20291 -0.28312 0.22998 0.29799 0.34200 -0.17659 -0.4807 3.8305
## 1949 -0.01401 0.00712 -0.02134 0.03553 0.00990 0.01575 0.1672 2.8483
## 1950 -0.46303 0.48972 -0.46790 -0.49086 0.04277 0.41444 -0.7856 1.5527
## 1951 -0.12692 -0.05380 -0.08084 -0.01841 -0.07181 0.16048 -0.5798 1.1598
## 1952 0.09679 -0.18702 0.13668 0.17357 -0.40535 -0.06618 -0.9673 0.7714
## 1953 -0.22254 0.12230 -0.20855 -0.25080 0.14675 0.23235 0.4255 2.6398
## 1954 -0.09554 -0.00164 -0.10214 0.13744 0.47777 0.10617 0.5641 2.7985
## 1955 0.17697 -0.19119 0.18737 0.15885 0.07950 -0.16063 0.2210 3.3090
## 1956 0.78380 -0.55032 0.79530 0.38103 -0.19890 -0.77991 1.2734 0.0606
## 1957 -0.08447 0.26967 -0.11137 -0.24502 -0.29281 0.03376 0.5491 1.2525
## 1958 0.00486 -0.01457 0.00791 -0.00426 -0.00213 -0.00170 -0.0296 3.6346
## 1959 -0.38829 0.09883 -0.35572 -0.26377 0.28195 0.43399 -0.6599 1.7108
## 1960 0.00340 0.00425 0.00349 -0.00243 -0.02003 -0.00514 0.0373 2.4019
## 1961 -0.10569 0.04606 -0.09258 -0.03575 0.02056 0.11047 0.2453 2.6645
## 1962 0.79572 0.47686 0.43252 0.78366 -0.09781 -1.05310 -2.5343 0.6108
## cook.d hat inf
## 1947 0.070613 0.424
## 1948 0.041955 0.564 *
## 1949 0.005150 0.361 *
## 1950 0.102424 0.372
## 1951 0.055062 0.223
## 1952 0.140453 0.308
## 1953 0.032562 0.403
## 1954 0.056666 0.469
## 1955 0.008985 0.453 *
## 1956 0.163935 0.178
## 1957 0.050021 0.224
## 1958 0.000162 0.483 *
## 1959 0.073928 0.347
## 1960 0.000258 0.219
## 1961 0.011005 0.345
## 1962 0.836102 0.628 *
#regresi tanpa amatan berpengaruh
#reg_tanpa9=lm(y~x1+x2,data=antar[-9,])
#reg_tanpa22=lm(y~x1+x2,data=antar[-22,])
#reg_tanpa9dan22=lm(y~x1+x2,data=antar[-c(9,22),])
#anova(reg_ganda)
#anova(reg_tanpa9)
#anova(reg_tanpa22)
#anova(reg_tanpa9dan22)
bkward=ols_step_backward_p(regresi, prem = 0.1,details = TRUE)
## Backward Elimination Method
## ---------------------------
##
## Candidate Terms:
##
## 1 . GNP.deflator
## 2 . GNP
## 3 . Unemployed
## 4 . Armed.Forces
## 5 . Population
##
## We are eliminating variables based on p value...
##
## - GNP.deflator
##
## Backward Elimination: Step 1
##
## Variable GNP.deflator Removed
##
## Model Summary
## -------------------------------------------------------------
## R 0.994 RMSE 0.464
## R-Squared 0.987 Coef. Var 0.710
## Adj. R-Squared 0.983 MSE 0.215
## Pred R-Squared 0.972 MAE 0.309
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.642 4 45.661 212.231 0.0000
## Residual 2.367 11 0.215
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## ------------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## ------------------------------------------------------------------------------------------
## (Intercept) 82.613 21.775 3.794 0.003 34.687 130.539
## GNP 0.062 0.016 1.758 3.888 0.003 0.027 0.097
## Unemployed -0.005 0.003 -0.138 -1.783 0.102 -0.012 0.001
## Armed.Forces -0.006 0.003 -0.117 -2.277 0.044 -0.012 0.000
## Population -0.325 0.241 -0.644 -1.347 0.205 -0.856 0.206
## ------------------------------------------------------------------------------------------
##
##
## - Population
##
## Backward Elimination: Step 2
##
## Variable Population Removed
##
## Model Summary
## -------------------------------------------------------------
## R 0.993 RMSE 0.479
## R-Squared 0.985 Coef. Var 0.734
## Adj. R-Squared 0.981 MSE 0.230
## Pred R-Squared 0.976 MAE 0.289
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.252 3 60.751 264.449 0.0000
## Residual 2.757 12 0.230
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## -----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## -----------------------------------------------------------------------------------------
## (Intercept) 53.306 0.716 74.415 0.000 51.746 54.867
## GNP 0.041 0.002 1.154 18.485 0.000 0.036 0.046
## Unemployed -0.008 0.002 -0.212 -3.734 0.003 -0.013 -0.003
## Armed.Forces -0.005 0.003 -0.096 -1.892 0.083 -0.010 0.001
## -----------------------------------------------------------------------------------------
##
##
##
## No more variables satisfy the condition of p value = 0.1
##
##
## Variables Removed:
##
## - GNP.deflator
## - Population
##
##
## Final Model Output
## ------------------
##
## Model Summary
## -------------------------------------------------------------
## R 0.993 RMSE 0.479
## R-Squared 0.985 Coef. Var 0.734
## Adj. R-Squared 0.981 MSE 0.230
## Pred R-Squared 0.976 MAE 0.289
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.252 3 60.751 264.449 0.0000
## Residual 2.757 12 0.230
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## -----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## -----------------------------------------------------------------------------------------
## (Intercept) 53.306 0.716 74.415 0.000 51.746 54.867
## GNP 0.041 0.002 1.154 18.485 0.000 0.036 0.046
## Unemployed -0.008 0.002 -0.212 -3.734 0.003 -0.013 -0.003
## Armed.Forces -0.005 0.003 -0.096 -1.892 0.083 -0.010 0.001
## -----------------------------------------------------------------------------------------
forward=ols_step_forward_p(regresi, penter = 0.1,details = TRUE)
## Forward Selection Method
## ---------------------------
##
## Candidate Terms:
##
## 1. GNP.deflator
## 2. GNP
## 3. Unemployed
## 4. Armed.Forces
## 5. Population
##
## We are selecting variables based on p value...
##
##
## Forward Selection: Step 1
##
## - GNP
##
## Model Summary
## -------------------------------------------------------------
## R 0.984 RMSE 0.657
## R-Squared 0.967 Coef. Var 1.005
## Adj. R-Squared 0.965 MSE 0.431
## Pred R-Squared 0.959 MAE 0.511
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 178.973 1 178.973 415.103 0.0000
## Residual 6.036 14 0.431
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## ----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## ----------------------------------------------------------------------------------------
## (Intercept) 51.844 0.681 76.087 0.000 50.382 53.305
## GNP 0.035 0.002 0.984 20.374 0.000 0.031 0.038
## ----------------------------------------------------------------------------------------
##
##
##
## Forward Selection: Step 2
##
## - Unemployed
##
## Model Summary
## -------------------------------------------------------------
## R 0.990 RMSE 0.525
## R-Squared 0.981 Coef. Var 0.803
## Adj. R-Squared 0.978 MSE 0.275
## Pred R-Squared 0.973 MAE 0.362
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 181.430 2 90.715 329.498 0.0000
## Residual 3.579 13 0.275
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## ----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## ----------------------------------------------------------------------------------------
## (Intercept) 52.382 0.574 91.330 0.000 51.143 53.621
## GNP 0.038 0.002 1.071 22.120 0.000 0.034 0.042
## Unemployed -0.005 0.002 -0.145 -2.987 0.010 -0.009 -0.002
## ----------------------------------------------------------------------------------------
##
##
##
## Forward Selection: Step 3
##
## - Armed.Forces
##
## Model Summary
## -------------------------------------------------------------
## R 0.993 RMSE 0.479
## R-Squared 0.985 Coef. Var 0.734
## Adj. R-Squared 0.981 MSE 0.230
## Pred R-Squared 0.976 MAE 0.289
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.252 3 60.751 264.449 0.0000
## Residual 2.757 12 0.230
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## -----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## -----------------------------------------------------------------------------------------
## (Intercept) 53.306 0.716 74.415 0.000 51.746 54.867
## GNP 0.041 0.002 1.154 18.485 0.000 0.036 0.046
## Unemployed -0.008 0.002 -0.212 -3.734 0.003 -0.013 -0.003
## Armed.Forces -0.005 0.003 -0.096 -1.892 0.083 -0.010 0.001
## -----------------------------------------------------------------------------------------
##
##
##
## No more variables to be added.
##
## Variables Entered:
##
## + GNP
## + Unemployed
## + Armed.Forces
##
##
## Final Model Output
## ------------------
##
## Model Summary
## -------------------------------------------------------------
## R 0.993 RMSE 0.479
## R-Squared 0.985 Coef. Var 0.734
## Adj. R-Squared 0.981 MSE 0.230
## Pred R-Squared 0.976 MAE 0.289
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.252 3 60.751 264.449 0.0000
## Residual 2.757 12 0.230
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## -----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## -----------------------------------------------------------------------------------------
## (Intercept) 53.306 0.716 74.415 0.000 51.746 54.867
## GNP 0.041 0.002 1.154 18.485 0.000 0.036 0.046
## Unemployed -0.008 0.002 -0.212 -3.734 0.003 -0.013 -0.003
## Armed.Forces -0.005 0.003 -0.096 -1.892 0.083 -0.010 0.001
## -----------------------------------------------------------------------------------------
stepw=ols_step_both_p(regresi, penter = 0.15, prem = 0.15,details = TRUE)
## Stepwise Selection Method
## ---------------------------
##
## Candidate Terms:
##
## 1. GNP.deflator
## 2. GNP
## 3. Unemployed
## 4. Armed.Forces
## 5. Population
##
## We are selecting variables based on p value...
##
##
## Stepwise Selection: Step 1
##
## - GNP added
##
## Model Summary
## -------------------------------------------------------------
## R 0.984 RMSE 0.657
## R-Squared 0.967 Coef. Var 1.005
## Adj. R-Squared 0.965 MSE 0.431
## Pred R-Squared 0.959 MAE 0.511
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 178.973 1 178.973 415.103 0.0000
## Residual 6.036 14 0.431
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## ----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## ----------------------------------------------------------------------------------------
## (Intercept) 51.844 0.681 76.087 0.000 50.382 53.305
## GNP 0.035 0.002 0.984 20.374 0.000 0.031 0.038
## ----------------------------------------------------------------------------------------
##
##
##
## Stepwise Selection: Step 2
##
## - Unemployed added
##
## Model Summary
## -------------------------------------------------------------
## R 0.990 RMSE 0.525
## R-Squared 0.981 Coef. Var 0.803
## Adj. R-Squared 0.978 MSE 0.275
## Pred R-Squared 0.973 MAE 0.362
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 181.430 2 90.715 329.498 0.0000
## Residual 3.579 13 0.275
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## ----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## ----------------------------------------------------------------------------------------
## (Intercept) 52.382 0.574 91.330 0.000 51.143 53.621
## GNP 0.038 0.002 1.071 22.120 0.000 0.034 0.042
## Unemployed -0.005 0.002 -0.145 -2.987 0.010 -0.009 -0.002
## ----------------------------------------------------------------------------------------
##
##
##
## Model Summary
## -------------------------------------------------------------
## R 0.990 RMSE 0.525
## R-Squared 0.981 Coef. Var 0.803
## Adj. R-Squared 0.978 MSE 0.275
## Pred R-Squared 0.973 MAE 0.362
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 181.430 2 90.715 329.498 0.0000
## Residual 3.579 13 0.275
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## ----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## ----------------------------------------------------------------------------------------
## (Intercept) 52.382 0.574 91.330 0.000 51.143 53.621
## GNP 0.038 0.002 1.071 22.120 0.000 0.034 0.042
## Unemployed -0.005 0.002 -0.145 -2.987 0.010 -0.009 -0.002
## ----------------------------------------------------------------------------------------
##
##
##
## Stepwise Selection: Step 3
##
## - Armed.Forces added
##
## Model Summary
## -------------------------------------------------------------
## R 0.993 RMSE 0.479
## R-Squared 0.985 Coef. Var 0.734
## Adj. R-Squared 0.981 MSE 0.230
## Pred R-Squared 0.976 MAE 0.289
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.252 3 60.751 264.449 0.0000
## Residual 2.757 12 0.230
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## -----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## -----------------------------------------------------------------------------------------
## (Intercept) 53.306 0.716 74.415 0.000 51.746 54.867
## GNP 0.041 0.002 1.154 18.485 0.000 0.036 0.046
## Unemployed -0.008 0.002 -0.212 -3.734 0.003 -0.013 -0.003
## Armed.Forces -0.005 0.003 -0.096 -1.892 0.083 -0.010 0.001
## -----------------------------------------------------------------------------------------
##
##
##
## Model Summary
## -------------------------------------------------------------
## R 0.993 RMSE 0.479
## R-Squared 0.985 Coef. Var 0.734
## Adj. R-Squared 0.981 MSE 0.230
## Pred R-Squared 0.976 MAE 0.289
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.252 3 60.751 264.449 0.0000
## Residual 2.757 12 0.230
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## -----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## -----------------------------------------------------------------------------------------
## (Intercept) 53.306 0.716 74.415 0.000 51.746 54.867
## GNP 0.041 0.002 1.154 18.485 0.000 0.036 0.046
## Unemployed -0.008 0.002 -0.212 -3.734 0.003 -0.013 -0.003
## Armed.Forces -0.005 0.003 -0.096 -1.892 0.083 -0.010 0.001
## -----------------------------------------------------------------------------------------
##
##
##
## No more variables to be added/removed.
##
##
## Final Model Output
## ------------------
##
## Model Summary
## -------------------------------------------------------------
## R 0.993 RMSE 0.479
## R-Squared 0.985 Coef. Var 0.734
## Adj. R-Squared 0.981 MSE 0.230
## Pred R-Squared 0.976 MAE 0.289
## -------------------------------------------------------------
## RMSE: Root Mean Square Error
## MSE: Mean Square Error
## MAE: Mean Absolute Error
##
## ANOVA
## --------------------------------------------------------------------
## Sum of
## Squares DF Mean Square F Sig.
## --------------------------------------------------------------------
## Regression 182.252 3 60.751 264.449 0.0000
## Residual 2.757 12 0.230
## Total 185.009 15
## --------------------------------------------------------------------
##
## Parameter Estimates
## -----------------------------------------------------------------------------------------
## model Beta Std. Error Std. Beta t Sig lower upper
## -----------------------------------------------------------------------------------------
## (Intercept) 53.306 0.716 74.415 0.000 51.746 54.867
## GNP 0.041 0.002 1.154 18.485 0.000 0.036 0.046
## Unemployed -0.008 0.002 -0.212 -3.734 0.003 -0.013 -0.003
## Armed.Forces -0.005 0.003 -0.096 -1.892 0.083 -0.010 0.001
## -----------------------------------------------------------------------------------------