Download presentation
Presentation is loading. Please wait.
Published byRoss Jennings Modified over 6 years ago
1
Phân tích hồi quy tuyến tính đa biến sử dụng phần mềm R
Tuan V. Nguyen Garvan Institute of Medical Research, Sydney, Australia
2
Số liệu Tác động của nhiệt độ (x1), thời gian (x2) lên CO2 (y)
Id y X1 X2 X3 X4 X5 X6 X7 1 36.98 5.1 400 51.37 4.24 2.06 2 13.74 26.4 72.33 30.87 289.94 434.90 1.33 3 10.08 23.8 71.44 33.01 320.79 481.19 0.97 4 8.53 46.4 79.15 44.61 164.76 247.14 0.62 5 36.42 7.0 450 80.47 33.84 0.22 6 26.59 12.6 89.90 41.26 605.06 907.59 0.76 7 19.07 18.9 91.48 41.88 405.37 608.05 1.71 8 5.96 30.2 98.60 70.79 253.70 380.55 3.93 9 15.52 53.8 98.05 66.82 142.27 213.40 1.97 … 25 11.19 11.5 77.88 25.20 663.09 994.63 1.61 26 75.62 5.2 470 75.50 8.66 4.78 27 36.03 10.6 83.15 22.39 720.07 5.88 Chú thích: y = sản lượng CO2; X1 = thời gian (phút); X2 = nhiệt độ (C); X3 = phần trăm hòa tan; X4 = lượng dầu (g/100g); X5 = lượng than đá; X6 = tổng số lượng hòa tan; X7 = số hydrogen tiêu thụ.
3
Nhập số liệu vào R y <- c(36.98,13.74,10.08, 8.53,36.42,26.59,19.07, 5.96,15.52,56.61, 26.72,20.80, 6.99,45.93,43.09,15.79,21.60,35.19,26.14, 8.60, 11.63, 9.59, 4.42,38.89,11.19,75.62,36.03) x1 <- c(5.1,26.4,23.8,46.4, 7.0,12.6,18.9,30.2,53.8,5.6,15.1,20.3,48.4, 5.8,11.2,27.9,5.1,11.7,16.7,24.8,24.9,39.5,29.0, 5.5, 11.5, 5.2,10.6) x2 <- c(400,400, 400, 400, 450, 450, 450, 450, 450, 400, 400, 400, 400, 425, 425, 425, 450, 450, 450, 450, 450, 450, 450, 460, 450, 470, 470) x3 <- c(51.37,72.33,71.44,79.15,80.47,89.90,91.48,98.60,98.05,55.69, 66.29,58.94,74.74,63.71,67.14,77.65,67.22,81.48,83.88,89.38, 79.77,87.93,79.50,72.73,77.88,75.50,83.15) x4 <- c(4.24,30.87,33.01,44.61,33.84,41.26,41.88,70.79,66.82, 8.92,17.98,17.79,33.94,11.95,14.73,34.49,14.48,29.69,26.33, 37.98,25.66,22.36,31.52,17.86,25.20, 8.66,22.39) x5 <- c( , , , , , , , 253.70, , , , , , , 682.59, , , , , , , 193.61, , , , , ) x6 <- c( , , , , , , , 380.55, , , , , , , , 411.30, , , , , , , 233.95, , , , ) x7 <- c(2.06,1.33,0.97,0.62,0.22,0.76,1.71,3.93,1.97,5.08,0.60,0.90, 0.63,2.04,1.57,2.38,0.32,0.44,8.82,0.02,1.72,1.88,1.43, 1.35,1.61,4.78,5.88) REGdata <- data.frame(y, x1,x2,x3,x4,x5,x6,x7) Muốn lưu giữ file, cần phải dùng lệnh Write.table(REGdata,”địa chỉ cần lưu giữ file/data.csv”)
4
Hoặc gọi file từ R Nhập số liệu từ bảng biểu trình bày trên vào file xcel. Sau đó save as dưới dạng file csv. Cách này có thể lưu giữ số liệu gốc. Rồi gọi file số liệu trưc tiếp vào R: REGdata <- read.csv(“c:/đường dẫn đến nơi lưu file/ data.csv, header=T)
5
Kết quả phân tích reg <- lm(y ~ x1+x2+x3+x4+x5+x6+x7, data=REGdata)
summary(reg) Residuals: Min Q Median Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) x x x x x x * x --- Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: on 19 degrees of freedom Multiple R-Squared: 0.728, Adjusted R-squared: F-statistic: on 7 and 19 DF, p-value:
6
Tương quan chéo
7
Hồi quy loại từng bước (stepwise)
reg <- lm(y ~ ., data=REGdata) step(reg, direction=”both”)
8
Hồi quy loại từng bước Start: AIC= 134.07
y ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 Df Sum of Sq RSS AIC - x - x - x - x <none> - x - x - x Step 1: AIC= y ~ x1 + x2 + x3 + x4 + x6 + x7 Df Sum of Sq RSS AIC - x - x - x <none> - x + x - x - x Step 2: AIC= y ~ x2 + x3 + x4 + x6 + x7 - x - x <none> - x + x + x - x - x Step 3: AIC= y ~ x3 + x4 + x6 + x7 - x - x <none> + x + x + x - x - x
9
Hồi quy loại từng bước Step 4: AIC= 127.9 y ~ x4 + x6 + x7
Df Sum of Sq RSS AIC - x <none> + x + x + x + x - x - x Step 5: AIC= y ~ x6 + x7 <none> + x + x + x + x + x - x - x Call: lm(formula = y ~ x6 + x7, data = REGdata) Coefficients: (Intercept) x x7
10
Phương pháp lựa chọn mô hình tối ưu bằng Bayesian Model Average (BMA)
library(BMA) xvars <- REGdata[,-1] co2 <- REGdata[,1] bma <- bicreg(xvars, co2, strict=FALSE, OR=20) summary(bma)
11
Bayesian Model Average (BMA) analysis
16 models were selected Best 5 models (cumulative posterior probability = ): p!=0 EV SD model 1 model 2 model 3 model 4 model 5 Intercept x x x x x x x nVar r BIC post prob
12
Bayesian Model Average (BMA) analysis
imageplot.bma(bma)
13
Lời Cảm tạ Chúng tôi xin chân thành cám ơn Công ty Dược phẩm Bridge Healthcare, Australia đã tài trợ cho chuyến đi.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.