# PHẠM QUỲNH NGA
# 24NH MSV:2452020054
# BÀI 14, 15, 16
# NHẬP LIỆU
likert=file.choose()
datalikert=read.csv(likert,header=TRUE)
save(datalikert,file="datalikert.rda")
attach(datalikert)
is.data.frame(datalikert)
## [1] TRUE
# Câu 14:
#Xây dựng mô hình hồi quy tuyến tính bội
mreg=lm(Ftb~Atb+Btb+Ctb)
summary(mreg)
##
## Call:
## lm(formula = Ftb ~ Atb + Btb + Ctb)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.73037 -0.44846 0.09795 0.39376 1.34503
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.76022 0.32504 2.339 0.020361 *
## Atb 0.20139 0.05691 3.539 0.000504 ***
## Btb 0.13162 0.04943 2.663 0.008399 **
## Ctb 0.47633 0.04730 10.070 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5705 on 194 degrees of freedom
## Multiple R-squared: 0.4128, Adjusted R-squared: 0.4038
## F-statistic: 45.47 on 3 and 194 DF, p-value: < 2.2e-16
## Nhận xét:
# Kết quả hồi quy cho thấy mô hình có ý nghĩa thống kê tổng thể
# Câu 15
# Xây dựng mô hình hồi quy tuyến tính bội
mreg=lm(Ftb~Atb+Btb+Ctb)
summary(mreg)
##
## Call:
## lm(formula = Ftb ~ Atb + Btb + Ctb)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.73037 -0.44846 0.09795 0.39376 1.34503
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.76022 0.32504 2.339 0.020361 *
## Atb 0.20139 0.05691 3.539 0.000504 ***
## Btb 0.13162 0.04943 2.663 0.008399 **
## Ctb 0.47633 0.04730 10.070 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5705 on 194 degrees of freedom
## Multiple R-squared: 0.4128, Adjusted R-squared: 0.4038
## F-statistic: 45.47 on 3 and 194 DF, p-value: < 2.2e-16
library(car)
## Loading required package: carData
vif(mreg)
## Atb Btb Ctb
## 1.004380 1.030053 1.027108
require(lmtest)
## Loading required package: lmtest
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
dwtest(mreg)
##
## Durbin-Watson test
##
## data: mreg
## DW = 1.7709, p-value = 0.04459
## alternative hypothesis: true autocorrelation is greater than 0
# Nhận xét:
# # Kiểm định đa cộng tuyến cho thấy các giá trị VIF các biến độc lập đều nhỏ hơn
# => Mô hình không có hiện tượng đa cộng tuyến.
# Câu 16
# Xây dựng mô hình hồi quy tuyến tính bội
mreg=lm(Ftb~Atb+Btb+Ctb)
summary(mreg)
##
## Call:
## lm(formula = Ftb ~ Atb + Btb + Ctb)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.73037 -0.44846 0.09795 0.39376 1.34503
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.76022 0.32504 2.339 0.020361 *
## Atb 0.20139 0.05691 3.539 0.000504 ***
## Btb 0.13162 0.04943 2.663 0.008399 **
## Ctb 0.47633 0.04730 10.070 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5705 on 194 degrees of freedom
## Multiple R-squared: 0.4128, Adjusted R-squared: 0.4038
## F-statistic: 45.47 on 3 and 194 DF, p-value: < 2.2e-16
op=par(mfrow=c(2,2))
plot(mreg)

# Nhận xét:
# # - Đồ thị bên trái dòng 1 vẻ phần dư ei và giá trị dự báo của F^tbi,
# đồ thị này cho thấy các giá trị phần dư tập trung quanh đường y = 0
# cho nên giả định về giá trị trung bình của ei = 0 là có thể chấp nhận được.