# Hoàng Thị Minh Thư
# Lớp 24NH1 MSSV : 2454020017
# BÀI THỰC HÀNH BUỔI 8
#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
#cau 14
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
#nhan xet
#phuong trinh hoi quy: Ftb=0.76022 + 0.20139*Atb + 0.13162*Btb + 0.47633*ei
#ket qua hoi quy cho thay mo hinh co y nghia thong ke tông the voi gia tri F-statistic bang 45,47 va muc y nghia (p<0,001)
# he so R2=0,4128: cho thay cac bien Atb, Btb va Ctb giai thich khoang 41,28%su bien thien cua Ftb trong khi R2 hieu chinh dat 0,4038
#cau15
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
#nhan xet
#kiem dinh da cong tuyen cho thay cac gia tri VIF cac bien doc lap deu ngo hon
#=> mo hinh khong co hien tuong da cong tuyen.
#kiem dinh tu tuong quan cho thay gia trị Dw=1.7709 nam ong khoang chap nhan (1.5<Dw<2,5)
#=> Mo hinh khong co hien tuong tu tuong quan
#cau16
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)

#nhan xet
#do thi ben trai dong 1 ve phan du ei va gia tri du bao F^tbi, do thi nay cho thay cac gia tri phan du tap trung quanh duong y=0 cho nen gia dinh ve gia tri trung binh cua ei=0 la co the chap nhan duoc
#do thi ben phai dong 1 ve gia tri phan du ei va gia tri ky vong dua vao phan phoi chuan
#ket qua cho thay cac gia tri phan du tap trung rat gan cac gia tri tren duong chuan do do, phan du ei tuan thu theo quy luat phan phoi chuan