setwd("D:/UEH/Kinh Te Luong/Huong dan BT NHOM KTL 2019 hk3")
source("functions.R")
import_library("gdata")
import_library("stringr")
import_library("dplyr")
import_library("foreign")
import_library("glue")
import_library("magrittr")
import_library("ggplot2")
import_library("ggfortify")
import_library("AER")
import_library("PerformanceAnalytics")
import_library("leaps")
import_library("olsrr")
import_library("car")
import_library("magick")
import_library("fBasics")
import_library("lmtest")
import_library("corrplot")
import_library("BMA")
import_library("haven")
khaosat <- read_sav("nguyenvantai26022000_baitap1.sav")
attach(khaosat)
dim(khaosat)
## [1] 474 21
## [1] "bdate" "hocvan" "thunhap" "luongkd" "thoigianlv"
## [6] "kinhnghiem" "gioi" "nam" "nu" "chucvu"
## [11] "nhanvien" "truongnhom" "quanly" "bangcap" "tuoi"
## [16] "luongthang" "filter_$" "gioitinh" "nhomtuoi" "lnluongthang"
tuyentinh_model <- lm(luongthang ~ hocvan + thoigianlv + gioitinh + truongnhom + quanly, data = khaosat)
print(summary(tuyentinh_model))
##
## Call:
## lm(formula = luongthang ~ hocvan + thoigianlv + gioitinh + truongnhom +
## quanly, data = khaosat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1879.4 -352.7 -66.5 290.8 5525.8
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -134.571 337.092 -0.399 0.6899
## hocvan 122.317 16.394 7.461 4.21e-13 ***
## thoigianlv 8.526 3.425 2.489 0.0131 *
## gioitinh 437.785 79.721 5.491 6.55e-08 ***
## truongnhom 333.874 165.634 2.016 0.0444 *
## quanly 2278.507 114.007 19.986 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 746.9 on 468 degrees of freedom
## Multiple R-squared: 0.7274, Adjusted R-squared: 0.7245
## F-statistic: 249.7 on 5 and 468 DF, p-value: < 2.2e-16
Chú ý rằng ngoài hệ số VIF như trên người ta còn lấy TOL = 1/VIF (nghịch đảo của VIF) là tiêu chí nhận định về hiện tượng đa cộng tuyến. Hiện tại, ngưỡng VIF (hay TOL, r23) bằng bao nhiêu để chỉ ra hiện tượng đa cộng tuyến vẫn là một vấn đề chưa có sự thống nhất giữa các nhà kinh tế lượng. Gujarati & Porter (2009) chỉ ra một số dấu hiệu của hiện tượng đa cộng tuyến trong mô hình khi: (1) hệ số VIF ≥ 10, hoặc (2) hệ số tương quan r của bất kì cặp biến nào trong mô hình lớn hơn 0.8. Trong khi đó Allison (1999) đưa ra tiêu chí chặt hơn khi chọn VIF > 2.5 (hay r > 0.775).
## hocvan thoigianlv gioitinh truongnhom quanly
## 1.896359 1.006830 1.339332 1.252109 1.610196
log_lin_model = lm(log(luongthang) ~ hocvan + thoigianlv + gioitinh + truongnhom + quanly, data = khaosat)
print(summary(log_lin_model))
##
## Call:
## lm(formula = log(luongthang) ~ hocvan + thoigianlv + gioitinh +
## truongnhom + quanly, data = khaosat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.47130 -0.12229 -0.01536 0.11043 0.89619
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.8841189 0.0885396 77.752 < 2e-16 ***
## hocvan 0.0439796 0.0043060 10.214 < 2e-16 ***
## thoigianlv 0.0024074 0.0008996 2.676 0.00771 **
## gioitinh 0.1674704 0.0209393 7.998 1e-14 ***
## truongnhom 0.1566795 0.0435050 3.601 0.00035 ***
## quanly 0.5590426 0.0299448 18.669 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1962 on 468 degrees of freedom
## Multiple R-squared: 0.7588, Adjusted R-squared: 0.7562
## F-statistic: 294.4 on 5 and 468 DF, p-value: < 2.2e-16