You are on page 1of 41

CHƯƠNG 4

PHÂN TÍCH HỒI QUI TUYẾN


TÍNH

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Phân tích hồi qui
Là nghiên cứu mối liên hệ tương quan và mức độ ảnh hưởng của một
hoặc nhiều biến độc lập tới một biến phụ thuộc.

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
MỘT SỐ KHÁI NIỆM CƠ BẢN
• Biến phụ thuộc (biến bị ảnh hưởng): Là biến được dự đoán, được
giải thích
• Biến độc lập (biến gây ảnh hưởng): Là biến được tác động tới biến
phụ thuộc hay còn gọi là biến giải thích.
• Hồi qui tuyến tính : Thể hiện mối liên hệ giữa biến độc lập và biến
phụ thuộc theo dạng đường thẳng.
• Trong thống kê, biến phụ thuộc và biến độc lập thường ký hiệu như
sau: y = Biến phụ thuộc
x = Biến độc lập

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
3
MỘT SỐ KHÁI NIỆM CƠ BẢN
• Hồi qui tuyến tính giản đơn: Là việc phân tích ảnh hưởng của 1 biến
độc lập tới 1 biến phụ thuộc được điều chỉnh về dạng đường thẳng.

• Hồi qui tuyến tính đa biến: Là việc phân tích ảnh hưởng của nhiều
biến độc lập tới 1 biến phụ thuộc được điều chỉnh về dạng đường
thẳng.

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
4
MÔ HÌNH HỒI QUI TUYẾN
TÍNH GIẢN ĐƠN

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Các bước xây dựng mô hình hồi qui
- Dựa trên phân tích lý luận, xác định giữa các biến nghiên cứu có mối
liên hệ tương quan, chỉ ra biến phụ thuộc và biến giải thích.
- Xác định tính chất, hình thức của mối liên hệ
- Lập phương trình hồi qui phản ánh mối liên hệ
- Tính toán các tham số trong phương trình và giải thích ý nghĩa của các
tham số
- Đánh giá sự phù hợp của phương trình hồi qui

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
VD 4.1: Thống kê quãng đường đã đi và thời gian đi tương ứng của 10 lái
xe công ty vận tải đường bộ Butler
STT Số dặm đã đi (dặm) Thời gian đi tương ứng
-x (giờ) - y
1 100 9.3
2 50 4.8
3 100 8.9
4 100 6.5
5 50 4.2
6 80 6.2
7 75 7.4
8 65 6.0
9 90 7.6

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
7
Hình 4.1: Đồ thị phân phối thể hiện số dặm đã đi và thời gian
di chuyển của 10 lái xe công ty vận tải đường bộ Butler

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
8
Mô hình hồi qui tuyến tính giản đơn
• Phương trình hồi qui tuyến tính đơn giản: (Phương trình của đường
hồi qui lý thuyết)
= b0 + b1 x
• = Giá trị lý thuyết của biến phụ thuộc y theo quan hệ phụ thuộc với x
• b0 = Hệ số chặn (còn gọi là Tham số tự do, hay hệ số tung độ gốc)
• b1 = Hệ số hồi qui (Thể hiện độ dốc của đường hồi qui), phản ánh ảnh
hưởng của x đối với y

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
9
Hình 4.2: Các dạng liên hệ trong Hồi qui
tuyến tính đơn giản

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
10
Phương pháp bình phương nhỏ nhất

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Nội dung phương pháp bình phương nhỏ nhất
• Tối thiểu hóa tổng bình phương chênh lệch giữa giá trị thực tế và giá
trị thực tế của biến phụ thuộc
• Phương trình bình phương nhỏ nhất:  i i  min
( y  ˆ
y ) 2

n
tương đương  (y  b
i 1
i 0  b1 x i )  min 2

• y = Giá trị thực tế của biến phụ thuộc thứ i


• = Giá trị ước tính của biến phụ thuộc thứ i
• n = Tổng số đơn vị quan sát

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
12
• Từ phương pháp bình phương nhỏ nhất, xác định các giá trị b0 và b1
dựa vào công thức sau:

b1 
 ( x  x ).( y  y) i i

 (x  x) i
2

b 0  y  b1x

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
13
• Với dữ liệu của Công ty Vận tải Đường bộ Butler trong VD 4.1:
• b1 = 0.0678
• b0 = 1.2739
• Mô hình hồi qui tuyến tính đơn giản :
= 1.2739 + 0.0678x1

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
14
• Phạm vi áp dụng: Khoảng biến thiên của giá trị các biến độc lập
trong dữ liệu được sử dụng để ước lượng mô hình.
• Mô hình hồi qui chỉ có ý nghĩa trong phạm vi này.
• Ngoại suy: Nếu dự đoán giá trị của biến phụ thuộc dựa vào giá trị
biến độc lập nằm ngoài phạm vi áp dụng thì độ chính xác thấp.

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
15
Sử dụng Excel để ước tính phương trình hồi qui
1. Dựa vào dữ liệu thu thập được, vẽ đồ thị phân phối
2. Bấm chuột phải và bất kỳ điểm nào trong đồ thị và chọn Add Trendline
3. Khi bảng hiện ra:
• Chọn Linear
• Chọn Display Equation on chart

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Hình 4.3: Đồ thị phân phối và phương trình hồi qui khi
sử dụng Excel

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
17
Đánh giá sự phù hợp của mô hình
hồi qui tuyến tính giản đơn

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Đánh giá sự phù hợp của mô hình hồi qui
tuyến tính giản đơn
Tổng bình phương
• Tổng bình phương do sai số (Sum of squares due to error – SSE): Giá
trị SSE là thước đo sai số khi sử dụng phương trình hồi qui ước lượng
để dự đoán giá trị của biến phụ thuộc trong mẫu.
n
SSE   ( y i  ŷ i ) 2

i 1

Tính SSE theo bảng 4.2

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
19
Bảng 4.2: Dự đoán thời gian di chuyển của 10 lái xe công
ty vận tải đường bộ Butler dựa vào mô hình đã ước lượng:

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
20
Hình 4.5: Giá trị trung bình mẫu được dùng để dự đoán thời
gian di chuyển của công ty vận tải đường bộ Butler

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
21
Đánh giá sự phù hợp của mô hình hồi qui
tuyến tính đơn giản
Tổng bình phương toàn bộ (Total sum of squares – SST)
• Trong VD công ty vận tải Butler : với lái xe thứ i trong mẫu, sự chêch
lệch (i đo mức độ sai số liên quan đến việc sử dụng y bình quân để
dự đoán thời gian di chuyển của người lái xe thứ i.
• Tổng bình phương các chênh lệch trên gọi là tổng bình phương toàn
bộ, ký hiệu SST
n
SST   ( y i  y) 2
i 1

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
22
Bảng 4.3: Tính toán SST đối với phương trình Hồi qui
tuyến tính đơn giản của công ty vận tải Butler

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
23
Hình 4.6: Những sai lệch giữa đường hồi qui tuyến tính ước lượng và
đường trung bình của y (TH công ty vận tải Butler).

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
24
Đánh giá sự phù hợp của mô hình hồi qui
tuyến tính đơn giản
• Tổng bình phương do hồi qui (Sum of squares due to regression –
SSR) n
SSR   ( ŷ i  y) 2
i 1

• Đo lường mức độ chênh lệch giữa giá trị và giá trị


• Mối liên hệ giữa SST, SSR, và SSE:
SST = SSR + SSE

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
25
Đánh giá sự phù hợp của mô hình hồi qui
tuyến tính đơn giản
Hệ số xác định
• Tỷ lệ SSR/SST được sử dụng để đánh giá mức độ phù hợp của
phương trình hồi qui ước lượng
• r2 =
• r2 có giá trị từ 0 đến 1
• r2 cho biết tỷ lệ % trong tổng bình toàn bộ có thể được giải thích
bằng phương trình hồi qui ước lượng
• Phản ánh bình phương mối tương quan giữa và .

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
26
Hình 4.7: Đồ thị phân phối, đường hồi qui ước lượng và r2
theo số liệu của Công ty vận tải Butler

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
27
Mô hình hồi qui đa biến

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Mô hình hồi qui đa biến
y = β0 + β1x1 + β2x2 + ∙ ∙ ∙ + βqxq

Biến phụ thuộc: y


Các biến độc lập: x1, x2, . . . , xq
Các tham số: β0, β1, β2, . . . , βq

Ý nghĩa của βj: Phản ánh sự thay đổi của giá trị trung bình biến phụ
thuộc y tương ứng với mức tăng 1 đơn vị của biến độc lập xj, với giả
thiết các biến độc lập khác trong mô hình không thay đổi.
© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
29
Mô hình hồi qui đa biến
Phương trình hồi qui đa biến ước lượng:
= b0 + b1x1 + b2x2 + ∙ ∙ ∙ + bqxq
• b0, b1, b2, . . . , bq = các ước lượng điểm của β0, β1, β2 , . . . , βq
• = giá trị ước lượng của biến phụ thuộc
• Phương pháp bình phương nhỏ nhất được sử dụng để xây dựng
Phương trình hồi qui đa biến ước lượng:
• Tìm b0, b1, b2, . . . , bq sao cho thỏa mãn
min = min
• Sử dụng dữ liệu mẫu để cung cấp các giá trị b0, b1, b2, . . . , bq .

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
30
Mô hình hồi qui đa biến
Thêm 1 biến độc lập là số lần giao hàng – VD4.2
Phương trình hồi qui tuyến tính đa biến với 2 biến độc lập như sau :
= b0 + b1x1 + b2x2
• = Thời gian dịch chuyển dự đoán
• x1 = Quãng đường dịch chuyển
• x2 = Số lần giao hàng

• SST, SSR, SSE và R2 được tính theo các công thức đã được trình bày

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
31
Sử dụng công cụ Hồi qui trong Excel’ tính Phương trình hồi qui đa biến
cho VD 4.2 (file dữ liệu)

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
32
• Copy dữ liệu vào bảng tính
Excel từ cột A đến cột D và
dòng 1 đến dòng 301.
• Bấm DATA, Data Analysis,
Regression

Khi hộp Regression hiện ra khai báo


các thông số

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
33
Hình 4.8: Kết quả sử dụng Excel ước lượng Phương trình hồi
qui đa biến

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
34
Biến độc lập là biến định tính
(biến phân loại)

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Biến độc lập phân loại
Công ty vận tải Butler và giờ cao điểm
• Biến phụ thuộc, y: Thời gian di chuyển
• Các biến độc lập: Quãng đường di chuyển (x1) và số lần giao hàng (x2)

0 nếu không di chuyển trên đoạn


đường bị tắc trong giờ cao điểm
• Biến phân loại: giờ cao điểm (x3) =
1 nếu có di chuyển trên đoạn đường
bị tắc trong giờ cao điểm

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
36
Mở VD 4.3 trong File dữ liệu và thực hiện

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Hình 4.12: Bảng đầu ra chạy Excel cho phân tích hồi qui với công ty
vận tải Butler với Số dặm di chuyển (x1), Số lần giao hàng (x2), và giờ
cao điểm (x3) là các biến độc lập

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
38
Phương trình hồi qui đa biến

= –0.3302 + 0.0672x1 + 0.6735x2 + 0.9980x3.

Ý nghĩa các tham số


• Khi quãng đường tăng thêm 1 dặm, các yếu tố khác giữ nguyên thì thời gian
di chuyển tăng 0.0672 giờ
• Khi số lần giao hàng tăng lên 1, các yếu tố khác không đổi thì thời gian di
chuyển tăng 0.6735 giờ
• Nếu phải di chuyển trên đường trong giờ cao điểm, các yếu tố khác không
đổi thì thời gian di chuyển tăng 0.9980 giờ.
R2 = 0.8838 cho thấy mô hình hồi qui giải thích được 88,4% sự thay đổi về thời
gian di chuyển của các lái xe.

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
39
Biến độc lập phân loại
TH các biến nhiều biểu hiện
• Nếu 1 biến phân loại có k biểu hiện, sẽ cần k – 1 biến giả

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
40
Biến độc lập phân loại
• VD (tiếp):
• Khu vực bán: Chia thành 3 khu vực (A, B, and C)
• Số biến giả = 3 – 1 = 2
• Mỗi biến sẽ được mã hóa thành 0 hoặc 1 với:
1 nếu KV bán C
x1 = 1 nếu KV bán là B x2 =
0 nếu KV bán không phải là C
0 nếu KV bán không phải là B

• Giá trị x1 và x2 là:

© 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
41

You might also like