Bài giảng Mô hình hồi quy tuyến tính đơn giản

37 69 0
Bài giảng Mô hình hồi quy tuyến tính đơn giản

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Bài giảng trình bày phân tích tương quan; mô hình hồi quy tuyến tính đơn giản; kiểm tra giả định mô hình hồi quy tuyến tính. Mời các bạn cùng tham khảo bài giảng để nắm chắc kiến thức.

Tuan V Nguyen Senior Principal Research Fellow, Garvan Institute of Medical Research Professor, UNSW School of Public Health and Community Medicine Professor of Predictive Medicine, University of Technology Sydney Adj Professor of Epidemiology and Biostatistics, School of Medicine Sydney, University of Notre Dame Australia Phân tích liệu ứng dụng | Đại học Dược Hà Nội | 12/6 to 17/6/2019 © Tuan V Nguyen Mơ hình hồi qui tuyến tính • Phân tích tương quan • Mơ hình hồi qui tuyến tính đơn giản • Kiểm tra giả định mơ hình hồi qui tuyến tính Khái niệm tương quan (correlation) • Khi hai biến số (x y) có liên quan với • Mối liên quan chiều hay nghịch đảo • Ví dụ: mối liên quan tiêu thụ chocolate giải Nobel (?) Tương quan biến liên tục Làm định lượng mối liên quan? Sir Francis Galton (16/2/1822 – 17/1/1911) Research interest: “Those qualifications of intellect and disposition which … lead to reputation” Didn’t have data on “intelligence” so instead studied HEIGHT Galton’s conclusions: • Nature dominates: “families of reputation were much more likely than ordinary families to produce offspring of ability” • Recommended “judicious marriages during several generations” to “produce a highly gifted race of men” • His “genetic utopia”: “Bright, healthy individuals were treated and paid well, and encouraged to have plenty of children Social undesirables were treated with reasonable kindness so long as they worked hard and stayed celibate.” J Singer's slide • Although a self-proclaimed genius, who wrote that he could read @2½, write/do arithmetic @4, and was comfortable with Latin texts @8, he couldn’t figure out how to model these data(!) • He went to JD Dickson, a mathematician at Cambridge, who formalized the relationship by developing what we now know as linear regression Làm để mơ tả mối tương quan tuyến tính? • Gọi X Y biến ngẫu nhiên từ n quan sát • Đo lường độ biến thiên: phương sai (variance) n ( xi - x )2 i =1 n -1 var( x ) = å n ( yi - y )2 i =1 n -1 var( y ) = å • Chúng ta cần thước đo độ "hiệp biến" X Y • Covariance trung bình tích số X Y n å ( xi - x )( yi - y ) cov( x, y ) = n - i =1 Ước tính hệ số tương quan • Covariance có đơn vị đo lường (X * Y) • Coefficient of correlation (r) X Y standardized covariance – đơn vị đo lường • r định nghĩa sau: r= cov( x, y ) cov( x, y ) = var( x ) ´ var( y ) SDx ´ SDy Obesity data (Vietnam) • Nghiên cứu cắt ngang >1100 nam nữ (Việt Nam) • Mục tiêu: ước tính hệ số tương quan tỉ trọng thể (bmi) tỉ trọng mỡ (pcfat) ob = read.csv("~/Dropbox/_Conferences and Workshops/Dai hoc Duoc 62019/Datasets/obesity data.csv") dim(ob) [1] 1217 11 > head(ob) id gender height weight bmi age bmc bmd fat lean pcfat 1 F 150 49 21.8 53 1312 0.88 17802 28600 37.3 2 M 165 52 19.1 65 1309 0.84 8381 40229 16.8 3 F 157 57 23.1 64 1230 0.84 19221 36057 34.0 4 F 156 53 21.8 56 1171 0.80 17472 33094 33.8 5 M 160 51 19.9 54 1681 0.98 7336 40621 14.8 6 F 153 47 20.1 52 1358 0.91 14904 30068 32.2 Hàm cor.test > cor.test(ob$bmi, ob$pcfat) data: ob$bmi and ob$pcfat t = 17.123, df = 1215, p-value < 2.2e-16 alternative hypothesis: true correlation is not equal to 95 percent confidence interval: 0.3944998 0.4850923 sample estimates: cor 0.4409183 Phương pháp "Least square" yˆ i = a + bxi d i = yi - yˆ i yi Y X Tìm cơng thức (estimator) để tính a b cho tổng d2 nhỏ Least square method = Bình phương nhỏ Ước tính tham số mơ hình HQTT R • Mơ hình hồi qui tuyến tính: y = α + β*X + ε • Triển khai R: hàm "lm" lm(y~ x) Ví dụ: nghiên cứu tỉ trọng mỡ (pcfat) • Nghiên cứu cắt ngang, 1217 nam nữ (Việt Nam) • Câu hỏi 1: Ảnh hưởng tuổi đến tỉ trọng mỡ ? • Câu hỏi 2: Tỉ trọng mỡ khác nam nữ ob = read.csv("~/Dropbox/_Conferences and Workshops/Dai hoc Duoc 62019/Datasets/obesity data.csv") > head(ob) id gender height weight bmi age bmc bmd fat lean pcfat 1 F 150 49 21.8 53 1312 0.88 17802 28600 37.3 2 M 165 52 19.1 65 1309 0.84 8381 40229 16.8 3 F 157 57 23.1 64 1230 0.84 19221 36057 34.0 4 F 156 53 21.8 56 1171 0.80 17472 33094 33.8 5 M 160 51 19.9 54 1681 0.98 7336 40621 14.8 6 F 153 47 20.1 52 1358 0.91 14904 30068 32.2 40 30 10 20 30 10 20 ob$pcfat 40 Biểu đồ 20 40 60 80 F M ob$age plot(ob$pcfat ~ ob$age, pch=16, col="blue") boxplot(ob$pcfat ~ ob$gender, col="blue", border="green") Triển khai câu hỏi nghiên cứu R • Ảnh hưởng tuổi đến tỉ trọng mỡ ? m1 = lm(pcfat ~ age, data=ob) summary(m1) • Khác biệt tỉ trọng mỡ nam nữ ? m2 = lm(pcfat ~ gender, data=ob) summary(m2) Câu hỏi 1: tuổi tỉ trọng mỡ > m1 = lm(pcfat ~ age, data=ob) > summary(m1) Coefficients: Estimate Std Error t value Pr(>|t|) (Intercept) 25.58408 0.57003 44.88

Ngày đăng: 24/10/2020, 00:16

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan