GVHD: ThS. Trần Mạnh Tường
Nhóm sinh viên thực hiện:
1. Mai Thị Hoài Thương - 2121001546
2. Nguyễn Thị Ngọc Hà - 2121012474
Bộ dữ liệu “Student Alcohol Consumption EDA” từ Kaggle cung cấp thông tin chi tiết về việc sinh viên tiêu thụ rượu tại các trường trung học ở Bồ Đào Nha. Bộ dữ liệu này không chỉ tập trung vào hành vi tiêu thụ rượu mà còn bao gồm các thông tin về môi trường, gia đình và xã hội của sinh viên. Mục đích của nghiên cứu là để hiểu rõ hơn về mối liên hệ giữa các yếu tố này và thói quen tiêu thụ rượu của sinh viên trong 1 ngày. Dữ liệu được thu thập từ các cuộc khảo sát trong cộng đồng học đường, mang lại cơ hội để nghiên cứu tác động của môi trường và gia đình đối với hành vi tiêu thụ rượu ở độ tuổi sinh viên.
Lời đầu tiên, chúng em xin gửi lời cảm ơn chân thành đến Giảng viên - ThS. Trần Mạnh Tường. Trong quá trình học tập và tìm hiểu môn “Phân tích dữ liệu định tính”, chúng em đã nhận được sự quan tâm giúp đỡ, hướng dẫn tận tình và cống hiến tâm huyết của thầy. Thầy đã giúp chúng em tích lũy thêm nhiều kiến thức để có cái nhìn hoàn thiện và tổng quan về bộ môn này. Từ những kiến thức được thầy truyền tải, chúng em dần hiểu được tầm quan trọng của môn học mà bấy lâu nay còn nhiều thắc mắc. Thông qua bài tiểu luận này, chúng em xin trình bày những gì chúng em đã tìm hiểu về môn học, và cụ thể là chúng em lựa chọn đề tài “Phân tích những yếu tố ảnh hưởng đến mức độ tiêu thụ rượu của sinh viên”
Kiến thức là vô hạn nhưng sự tiếp nhận kiến thức của bản thân mỗi chúng em luôn hạn chế một cách nhất định. Do đó, trong quá trình hoàn thành bài tiểu luận, chắc chắn chúng em không tránh khỏi những thiếu sót, vậy nên chúng em rất mong nhận được những đóng góp đến từ thầy để bài tiểu luận của nhóm được hoàn thiện hơn.
Chúng em kính chúc thầy sức khỏe, hạnh phúc và thành công trên con đường sự nghiệp của mình.
Hiện nay, hành vi tiêu thụ rượu là một hiện tượng phổ biến trong đời sống sinh viên. Nhiều sinh viên tham gia các hoạt động xã hội như tiệc tùng, dã ngoại và các sự kiến của trường, nơi rượu thường được phục vụ và tiêu thụ. Nhiều sinh viên không chỉ uống rượu mà còn lạm dụng nó, uống đến mức say xỉn thường xuyên. Tình trạng này đặc biệt phổ biến trong các dịp lễ, kỳ nghỉ và các buổi tiệc lớn. Việc uống rượu say xỉn có thể dẫn đến mất kiểm soát hành vi và gây ra nhiều hậu quả tiêu cực như tai nạn, bạo lực và các vấn đề về sức khỏe. Rượu không chỉ là dùng cho những cuộc vui chơi, tiệc tùng, giao lưu bạn bè mà sinh viên hiện nay còn dùng rượu để giải tỏa nỗi buồn, những áp lực trong học tập, bạn bè, gia đình, tình cảm nên việc tiêu thụ rượu của sinh viên hiện nay rất đáng báo động. Rượu rất dễ dàng được tiếp cận và những chỗ lưu thông rượu không được giám sát chặt chẽ nên ngày càng làm gia tăng mức độ tiêu thụ rượu.Thực trạng tiêu thụ rượu của sinh viên hiện nay là một vấn đề nghiêm trọng cần được quan tâm. Việc nghiên cứu và hiểu rõ hơn về hành vi tiêu thụ rượu của sinh viên trong một ngôi trường ở Bồ Đào Nha sẽ giúp đưa ra được một vài biện pháp giáo dục, phòng ngừa và hỗ trợ thích hợp, nhằm giảm thiểu những hậu quả tiêu cực và bảo vệ sức khỏe và tương lai của sinh viên.
Mục tiêu của chúng tôi là phân tích các yếu tố ảnh hưởng đến mức độ tiêu thụ rượu của sinh viên là thấp hay cao. Nghiên cứu nhằm tìm ra các thông tin và đưa ra một biện pháp giúp gia đình và nhà trường quản lý con cái, sinh viên của mình được tốt hơn.
Tập dữ liệu chứa thông tin từ cuộc khảo sát về sinh viên khóa học Toán ở 2 trường trung học ở Bồ Đào Nha. Bộ dữ liệu chưa các thông tin liên quan đến các sinh viên bao gồm 395 quan sát trên tổng 9 biến.
Bài nghiên cứu sử dụng phương pháp thống kê và các mô hình hồi quy để phân tích dữ liệu cho thấy tác động của các yếu tố ảnh hưởng đến mức độ tiêu thụ rượu của sinh viên.
Chương 1: Tổng quan nghiên cứu.
Chương 2: Dữ liệu nghiên cứu.
Chương 3: Phân tích dữ liệu.
Chương 4: Kết quả mô hình nghiên cứu.
Chương 5: Kết luận và khuyến nghị.
Bộ dữ liệu bao gồm 395 quan sát trên tổng 9 biến của sinh viên khóa học Toán của 2 trường trung học ở Bồ Đào Nha. Dưới đây là bảng chi tiết từng biến trên từng quan sát khác nhau.
std <- read.csv("student-math.csv", header = T)
library(data.table)
## Warning: package 'data.table' was built under R version 4.3.1
data.table(std)
school: ngôi trường sinh viên đang theo học (GP: Gabriel Pereira; MS: Mousinho da Silveria)
sex: giới tính của sinh viên (F: nữ; M: nam)
address: nơi ở của sinh viên (U: thành thị; R: nông thôn)
schoolsup: hỗ trợ giáo dục bổ sung (yes: có; no: không)
famsup: hỗ trợ giáo dục gia đình (yes: có; no: không)
activities: hoạt động ngoại khóa (yes: có; no: không)
internet: truy cập mạng tại nhà (yes: có; no: không)
romantic: mối quan hệ tình cảm (yes: có; no: không)
Dalc: mức tiêu thụ rượu trong 1 ngày (1: rất thấp; 2: thấp; 3: trung bình; 4: cao; 5: rất cao)
Trong bài luận này, biến phụ thuộc được chọn là biến Dalc (mức độ tiêu thụ rượu của sinh viên trong 1 ngày), do biến Dalc là dữ liệu định lượng với các mức độ 1, 2, 3, 4, 5 nên nhóm biến nó thành dữ liệu định tính là Dalc_2 với 2 biểu hiện cụ thể là thấp và cao. Ở các mức độ 1, 2 và 3 sẽ biến đổi thành biểu hiện tiêu thụ rượu thấp, còn mức độ 4 và 5 sẽ biến đổi thành biểu hiện tiêu thụ rượu cao như bảng dưới đây:
std <- read.csv("student-math.csv", header = T)
std$Dalc_2 <- ifelse(std$Dalc <= 2, "thấp", "cao")
print(std)
## school sex address schoolsup famsup activities internet romantic Dalc
## 1 GP F U yes no no no no 1
## 2 GP F U no yes no yes no 1
## 3 GP F U yes no no yes no 2
## 4 GP F U no yes yes yes yes 1
## 5 GP F U no yes no no no 1
## 6 GP M U no yes yes yes no 1
## 7 GP M U no no no yes no 1
## 8 GP F U yes yes no no no 1
## 9 GP M U no yes no yes no 1
## 10 GP M U no yes yes yes no 1
## 11 GP F U no yes no yes no 1
## 12 GP F U no yes yes yes no 1
## 13 GP M U no yes yes yes no 1
## 14 GP M U no yes no yes no 1
## 15 GP M U no yes no yes yes 1
## 16 GP F U no yes no yes no 1
## 17 GP F U no yes yes yes no 1
## 18 GP F U yes yes yes no no 1
## 19 GP M U no yes yes yes no 2
## 20 GP M U no no yes yes no 1
## 21 GP M U no no no yes no 1
## 22 GP M U no yes no yes no 1
## 23 GP M U no no yes yes no 1
## 24 GP M U no yes yes yes no 2
## 25 GP F R yes yes yes yes no 1
## 26 GP F U no yes no yes no 1
## 27 GP M U no yes no yes no 1
## 28 GP M U no no no yes no 2
## 29 GP M U yes yes yes yes no 1
## 30 GP M U no yes yes yes yes 5
## 31 GP M U no yes no yes no 3
## 32 GP M U no yes yes yes no 1
## 33 GP M R no yes yes yes yes 1
## 34 GP M U no no yes yes no 1
## 35 GP M U no yes no yes no 1
## 36 GP F U no yes yes no no 1
## 37 GP M U no yes yes yes no 1
## 38 GP M R no yes yes yes yes 1
## 39 GP F R yes yes yes yes no 1
## 40 GP F R yes yes yes no no 1
## 41 GP F U no yes yes yes yes 1
## 42 GP M U no yes no yes yes 2
## 43 GP M U no yes yes yes no 1
## 44 GP M U yes yes no yes no 1
## 45 GP F U yes no yes yes no 2
## 46 GP F U yes yes yes yes yes 1
## 47 GP F U no yes no yes no 1
## 48 GP M U no no yes yes no 1
## 49 GP M U no yes no no no 2
## 50 GP F U yes yes yes yes no 1
## 51 GP F U no yes no yes no 2
## 52 GP F U no yes no yes no 1
## 53 GP M U no no no no no 3
## 54 GP F U yes yes no yes no 2
## 55 GP F U no no no yes no 4
## 56 GP F U no no yes yes yes 1
## 57 GP F U no yes yes yes no 1
## 58 GP M U no yes yes no no 1
## 59 GP M U yes yes yes yes no 1
## 60 GP F U no yes no yes no 1
## 61 GP F R no yes yes no no 2
## 62 GP F U yes yes yes yes yes 5
## 63 GP F U yes no yes yes no 1
## 64 GP F U yes yes yes yes no 2
## 65 GP F U yes no yes yes yes 2
## 66 GP F U no yes yes yes no 1
## 67 GP M U no yes yes yes yes 5
## 68 GP F U yes yes no yes no 1
## 69 GP F R yes yes no yes no 1
## 70 GP F R no yes no yes no 2
## 71 GP M U no yes no yes no 1
## 72 GP M U no no no yes no 1
## 73 GP F R yes yes no yes yes 2
## 74 GP M U no no yes no no 2
## 75 GP F U yes yes yes yes no 2
## 76 GP M U no yes yes yes no 2
## 77 GP M U no no yes yes no 1
## 78 GP F U no no no yes yes 1
## 79 GP M U yes yes yes yes no 1
## 80 GP F U no yes no yes no 1
## 81 GP M U yes yes yes yes yes 1
## 82 GP M U yes no no yes no 1
## 83 GP F U no yes no yes no 1
## 84 GP M U no no yes yes no 1
## 85 GP F U no yes yes yes no 2
## 86 GP F U no no no yes yes 2
## 87 GP F U no yes no no no 1
## 88 GP F U no yes yes yes no 1
## 89 GP M U no no yes yes no 1
## 90 GP M U no yes no no no 3
## 91 GP F U no yes no yes yes 1
## 92 GP F U no no yes yes no 1
## 93 GP F U yes yes no no no 2
## 94 GP F U no yes yes yes no 1
## 95 GP M U no yes yes yes no 1
## 96 GP F R yes yes yes yes no 1
## 97 GP M R yes yes yes yes no 1
## 98 GP F U no yes no no yes 1
## 99 GP F U no no yes yes no 1
## 100 GP F U yes yes no yes no 1
## 101 GP M U yes yes yes yes no 5
## 102 GP M U no yes yes yes yes 1
## 103 GP M U no yes yes yes no 1
## 104 GP F U yes yes no yes no 1
## 105 GP M U no yes yes yes no 1
## 106 GP F U yes no no no no 1
## 107 GP F U yes yes no yes no 1
## 108 GP M U no yes yes yes no 1
## 109 GP M R no yes yes yes yes 3
## 110 GP F U no yes yes yes yes 1
## 111 GP M U no no yes yes no 1
## 112 GP F R yes yes yes yes no 1
## 113 GP F U yes no yes yes no 1
## 114 GP M U no no no yes no 1
## 115 GP M R no no yes yes yes 1
## 116 GP M U no yes yes yes no 1
## 117 GP M U no yes yes no no 1
## 118 GP M U no no yes yes no 1
## 119 GP M R no yes yes yes no 1
## 120 GP M U no no no yes no 1
## 121 GP F U no no no yes no 1
## 122 GP M U no yes yes yes no 1
## 123 GP F U no yes yes yes yes 1
## 124 GP M U no yes yes yes no 1
## 125 GP F U no no no yes yes 1
## 126 GP M U yes no no yes no 3
## 127 GP F U yes no yes yes yes 1
## 128 GP F U no yes no no no 1
## 129 GP M R no yes yes yes no 1
## 130 GP M R no no yes yes no 2
## 131 GP F R no yes no yes yes 2
## 132 GP F U no yes yes yes yes 1
## 133 GP F U no yes no yes yes 1
## 134 GP F U no no no yes no 1
## 135 GP M R no yes no no yes 1
## 136 GP F U no yes yes yes yes 1
## 137 GP M R no no no no no 2
## 138 GP F U no yes yes yes yes 1
## 139 GP M U no no no no yes 1
## 140 GP F U no no yes yes no 1
## 141 GP M U yes yes no yes no 1
## 142 GP M U no yes yes yes no 2
## 143 GP F U no yes yes yes no 1
## 144 GP F U no no no yes no 3
## 145 GP M U no yes no yes no 1
## 146 GP F U no yes no yes no 1
## 147 GP F U no yes no yes no 1
## 148 GP F U no yes no yes no 1
## 149 GP M U no yes no yes yes 2
## 150 GP M U no no no yes no 2
## 151 GP M U no no no yes yes 2
## 152 GP M U no no yes no yes 3
## 153 GP F R no yes yes yes yes 2
## 154 GP M U no yes no yes yes 1
## 155 GP F U yes yes no no yes 1
## 156 GP M R yes no yes no no 1
## 157 GP M R no no no no no 3
## 158 GP F R no yes yes no no 1
## 159 GP M R no no no no no 1
## 160 GP M U no yes no yes yes 4
## 161 GP M R no no yes yes yes 2
## 162 GP M R yes yes no yes yes 1
## 163 GP M U no no yes no no 2
## 164 GP M U no no no yes no 1
## 165 GP M R no no yes no yes 1
## 166 GP M U no yes yes no no 1
## 167 GP M U no no no yes no 2
## 168 GP F U no no no yes yes 1
## 169 GP F U no yes no yes no 1
## 170 GP F U no yes no yes yes 1
## 171 GP M U no yes yes yes no 2
## 172 GP M U no yes yes yes yes 1
## 173 GP M U no yes yes yes no 1
## 174 GP F U no no yes yes yes 1
## 175 GP F U no yes yes yes no 1
## 176 GP M U no no yes yes no 4
## 177 GP F U no no yes yes no 1
## 178 GP M U no no yes yes no 1
## 179 GP M R no yes yes yes yes 3
## 180 GP M U no yes yes yes yes 1
## 181 GP M U no yes yes yes no 2
## 182 GP M U no no yes yes yes 1
## 183 GP F U no yes yes no no 2
## 184 GP F U no yes yes yes yes 2
## 185 GP F U no yes no yes no 1
## 186 GP M U no yes yes yes yes 2
## 187 GP M U no yes yes yes yes 1
## 188 GP M U no no yes yes yes 1
## 189 GP F U no yes no yes yes 1
## 190 GP M R no no no no no 1
## 191 GP F U no no no yes no 1
## 192 GP F U no no yes yes no 1
## 193 GP M U no no yes yes no 4
## 194 GP M R no yes yes yes no 3
## 195 GP M U no no no yes no 1
## 196 GP F U no no yes yes yes 1
## 197 GP M U no no no yes no 1
## 198 GP M R no yes yes yes no 3
## 199 GP F U no yes no yes no 2
## 200 GP F U no yes no yes no 1
## 201 GP F U no yes yes yes no 1
## 202 GP F U yes yes yes no no 1
## 203 GP F U no yes no no no 1
## 204 GP F R no yes no yes no 1
## 205 GP F R no yes yes yes no 1
## 206 GP F U no yes no yes yes 3
## 207 GP F U no yes no yes no 2
## 208 GP F U no no yes yes yes 1
## 209 GP F U no yes no no no 1
## 210 GP F R no yes yes yes yes 1
## 211 GP F U no yes yes yes no 1
## 212 GP M U no yes no yes yes 4
## 213 GP F U yes yes no yes no 1
## 214 GP M U no yes yes yes no 2
## 215 GP F R no yes no no no 1
## 216 GP F U no no no yes no 1
## 217 GP F U no no no yes yes 2
## 218 GP M U no yes no yes no 2
## 219 GP F U no yes no no no 1
## 220 GP F U no yes yes yes no 1
## 221 GP F R no yes yes yes no 1
## 222 GP F U no yes yes no yes 1
## 223 GP F U yes no no yes no 1
## 224 GP M U no yes no yes no 5
## 225 GP F U no yes yes yes no 1
## 226 GP F R no no yes yes yes 1
## 227 GP F U no no yes yes no 1
## 228 GP M U no yes no yes no 1
## 229 GP M U yes yes yes yes yes 4
## 230 GP F U no no yes yes yes 1
## 231 GP F U no no yes yes yes 1
## 232 GP M R no yes yes yes no 1
## 233 GP M U yes yes yes yes yes 1
## 234 GP M U no yes yes yes no 2
## 235 GP M U no yes no yes no 1
## 236 GP M U no no yes yes yes 1
## 237 GP M U no no yes yes yes 5
## 238 GP F U no no no yes yes 1
## 239 GP F R no no yes no no 1
## 240 GP M U no no no yes no 3
## 241 GP M U no no yes yes yes 1
## 242 GP M R no yes no yes no 2
## 243 GP M U no no yes yes no 1
## 244 GP M U no no yes yes no 1
## 245 GP F U no yes no yes yes 1
## 246 GP M U no no no yes no 1
## 247 GP M U no no no yes no 1
## 248 GP M U no no no yes yes 5
## 249 GP M R no yes no yes yes 1
## 250 GP M U no no no yes no 2
## 251 GP M U no no no yes no 2
## 252 GP M U yes yes no yes no 1
## 253 GP M U no no no yes no 2
## 254 GP M R no no yes no no 1
## 255 GP M R no no no yes no 2
## 256 GP M U no yes yes yes no 1
## 257 GP F U no yes yes yes no 1
## 258 GP M U no yes no yes no 1
## 259 GP M U no no yes yes no 1
## 260 GP F U no no yes yes yes 1
## 261 GP F U no yes no yes yes 1
## 262 GP M U no yes no yes no 1
## 263 GP M R no no yes no no 1
## 264 GP F U no no yes no no 1
## 265 GP F U no yes yes yes yes 1
## 266 GP M R no yes yes yes no 3
## 267 GP M U no no yes yes yes 3
## 268 GP F R no no yes yes no 2
## 269 GP M U no yes yes yes yes 1
## 270 GP F R no yes no yes yes 1
## 271 GP F U no yes yes yes no 3
## 272 GP F U no yes yes yes yes 1
## 273 GP F U no yes no no no 1
## 274 GP M R no yes yes no yes 2
## 275 GP F U no yes no yes yes 1
## 276 GP F U yes yes no yes yes 2
## 277 GP F R no no no yes yes 1
## 278 GP M U no no yes yes no 1
## 279 GP F U yes yes yes yes yes 1
## 280 GP M U no no yes yes no 1
## 281 GP M U no no yes yes yes 2
## 282 GP M U no no no yes no 3
## 283 GP F R no yes yes no no 1
## 284 GP F U yes no yes yes no 1
## 285 GP F U no yes no yes no 1
## 286 GP M U no no no yes no 1
## 287 GP F U no yes no yes no 1
## 288 GP F U no yes no yes no 1
## 289 GP M U no no yes yes no 1
## 290 GP M U no yes yes yes no 1
## 291 GP M U no yes yes yes yes 1
## 292 GP F U no yes no yes no 1
## 293 GP F U no no no yes yes 1
## 294 GP F R no yes no no no 1
## 295 GP M R no yes yes yes no 1
## 296 GP M U no yes no yes no 1
## 297 GP F U no yes yes yes no 2
## 298 GP F U no yes no yes yes 1
## 299 GP F U no yes no yes no 1
## 300 GP M U no yes no yes yes 2
## 301 GP F U no yes no yes yes 1
## 302 GP M U no no no yes no 2
## 303 GP F U no yes no yes no 1
## 304 GP F U no yes yes yes no 1
## 305 GP M U no yes yes yes yes 1
## 306 GP F U no yes yes yes no 1
## 307 GP M U no no yes no no 1
## 308 GP M U no yes no yes yes 1
## 309 GP M R no no yes no yes 1
## 310 GP F U yes yes yes yes no 1
## 311 GP F U no no yes no yes 2
## 312 GP F U no yes no yes yes 1
## 313 GP M U no no no yes no 2
## 314 GP F U no yes no yes yes 1
## 315 GP F U no no no yes yes 1
## 316 GP F R no no no yes yes 1
## 317 GP F U no yes yes yes no 1
## 318 GP F U no yes yes yes yes 1
## 319 GP F R no yes yes yes no 2
## 320 GP F U no yes no yes no 3
## 321 GP F U no yes no yes yes 1
## 322 GP F U no yes no no yes 1
## 323 GP F R no yes yes yes no 2
## 324 GP F U no yes no yes no 2
## 325 GP F U no no no yes no 2
## 326 GP M U no no yes yes no 2
## 327 GP M U no no yes yes no 3
## 328 GP M R no yes no yes no 5
## 329 GP F U no yes yes yes no 1
## 330 GP F U no yes no yes yes 1
## 331 GP M U no yes yes yes no 2
## 332 GP F R no yes no yes yes 1
## 333 GP F U no no yes yes no 1
## 334 GP F U no no yes yes yes 1
## 335 GP F R no no yes no no 1
## 336 GP F U no no no yes no 1
## 337 GP F R no no no no no 1
## 338 GP F U no yes no yes yes 2
## 339 GP F U no yes no yes no 1
## 340 GP F R no yes no yes no 2
## 341 GP F U no no yes yes yes 1
## 342 GP M U no yes yes yes no 2
## 343 GP M U no no yes yes yes 1
## 344 GP F U no yes no yes yes 1
## 345 GP F U no yes no yes no 1
## 346 GP F U no no no yes yes 2
## 347 GP M R no no no yes yes 1
## 348 GP M U no yes no yes yes 2
## 349 GP F U no yes yes yes yes 1
## 350 MS M R no yes no yes no 5
## 351 MS M R no no no yes no 3
## 352 MS M U no yes no yes no 2
## 353 MS M U no no no yes yes 2
## 354 MS M R no yes no yes no 3
## 355 MS M R no yes yes yes yes 1
## 356 MS F U no yes no no yes 1
## 357 MS F R no yes yes yes no 1
## 358 MS F U no no no no yes 1
## 359 MS M U no no no yes yes 1
## 360 MS F U no no no yes no 1
## 361 MS F R no no no no yes 1
## 362 MS M R no no yes no no 2
## 363 MS F U no yes no yes yes 1
## 364 MS F U no yes yes yes yes 1
## 365 MS F R no no no no no 1
## 366 MS M R no yes no no no 2
## 367 MS M U no no no yes yes 2
## 368 MS F R no yes no yes yes 1
## 369 MS F U no yes no yes yes 1
## 370 MS F R no yes no yes yes 4
## 371 MS F U no no yes no yes 1
## 372 MS M R no yes yes yes yes 2
## 373 MS F U no no yes no yes 1
## 374 MS F R no no yes yes no 1
## 375 MS F R no no no yes no 1
## 376 MS F R no no no yes no 1
## 377 MS F U no yes no yes yes 1
## 378 MS F R no no yes yes no 3
## 379 MS F U no no no yes yes 1
## 380 MS F R no yes yes yes no 2
## 381 MS M U no no yes yes no 1
## 382 MS M R no no yes yes yes 1
## 383 MS M U no no yes yes no 1
## 384 MS M R no no no no no 1
## 385 MS M R no no no no no 4
## 386 MS F R no no no no no 1
## 387 MS F R no yes yes yes yes 2
## 388 MS F R no no yes yes no 1
## 389 MS F U no yes no yes no 1
## 390 MS F U no no yes no no 1
## 391 MS M U no yes no no no 4
## 392 MS M U no no no yes no 3
## 393 MS M R no no no no no 3
## 394 MS M R no no no yes no 3
## 395 MS M U no no no yes no 3
## Dalc_2
## 1 thấp
## 2 thấp
## 3 thấp
## 4 thấp
## 5 thấp
## 6 thấp
## 7 thấp
## 8 thấp
## 9 thấp
## 10 thấp
## 11 thấp
## 12 thấp
## 13 thấp
## 14 thấp
## 15 thấp
## 16 thấp
## 17 thấp
## 18 thấp
## 19 thấp
## 20 thấp
## 21 thấp
## 22 thấp
## 23 thấp
## 24 thấp
## 25 thấp
## 26 thấp
## 27 thấp
## 28 thấp
## 29 thấp
## 30 cao
## 31 cao
## 32 thấp
## 33 thấp
## 34 thấp
## 35 thấp
## 36 thấp
## 37 thấp
## 38 thấp
## 39 thấp
## 40 thấp
## 41 thấp
## 42 thấp
## 43 thấp
## 44 thấp
## 45 thấp
## 46 thấp
## 47 thấp
## 48 thấp
## 49 thấp
## 50 thấp
## 51 thấp
## 52 thấp
## 53 cao
## 54 thấp
## 55 cao
## 56 thấp
## 57 thấp
## 58 thấp
## 59 thấp
## 60 thấp
## 61 thấp
## 62 cao
## 63 thấp
## 64 thấp
## 65 thấp
## 66 thấp
## 67 cao
## 68 thấp
## 69 thấp
## 70 thấp
## 71 thấp
## 72 thấp
## 73 thấp
## 74 thấp
## 75 thấp
## 76 thấp
## 77 thấp
## 78 thấp
## 79 thấp
## 80 thấp
## 81 thấp
## 82 thấp
## 83 thấp
## 84 thấp
## 85 thấp
## 86 thấp
## 87 thấp
## 88 thấp
## 89 thấp
## 90 cao
## 91 thấp
## 92 thấp
## 93 thấp
## 94 thấp
## 95 thấp
## 96 thấp
## 97 thấp
## 98 thấp
## 99 thấp
## 100 thấp
## 101 cao
## 102 thấp
## 103 thấp
## 104 thấp
## 105 thấp
## 106 thấp
## 107 thấp
## 108 thấp
## 109 cao
## 110 thấp
## 111 thấp
## 112 thấp
## 113 thấp
## 114 thấp
## 115 thấp
## 116 thấp
## 117 thấp
## 118 thấp
## 119 thấp
## 120 thấp
## 121 thấp
## 122 thấp
## 123 thấp
## 124 thấp
## 125 thấp
## 126 cao
## 127 thấp
## 128 thấp
## 129 thấp
## 130 thấp
## 131 thấp
## 132 thấp
## 133 thấp
## 134 thấp
## 135 thấp
## 136 thấp
## 137 thấp
## 138 thấp
## 139 thấp
## 140 thấp
## 141 thấp
## 142 thấp
## 143 thấp
## 144 cao
## 145 thấp
## 146 thấp
## 147 thấp
## 148 thấp
## 149 thấp
## 150 thấp
## 151 thấp
## 152 cao
## 153 thấp
## 154 thấp
## 155 thấp
## 156 thấp
## 157 cao
## 158 thấp
## 159 thấp
## 160 cao
## 161 thấp
## 162 thấp
## 163 thấp
## 164 thấp
## 165 thấp
## 166 thấp
## 167 thấp
## 168 thấp
## 169 thấp
## 170 thấp
## 171 thấp
## 172 thấp
## 173 thấp
## 174 thấp
## 175 thấp
## 176 cao
## 177 thấp
## 178 thấp
## 179 cao
## 180 thấp
## 181 thấp
## 182 thấp
## 183 thấp
## 184 thấp
## 185 thấp
## 186 thấp
## 187 thấp
## 188 thấp
## 189 thấp
## 190 thấp
## 191 thấp
## 192 thấp
## 193 cao
## 194 cao
## 195 thấp
## 196 thấp
## 197 thấp
## 198 cao
## 199 thấp
## 200 thấp
## 201 thấp
## 202 thấp
## 203 thấp
## 204 thấp
## 205 thấp
## 206 cao
## 207 thấp
## 208 thấp
## 209 thấp
## 210 thấp
## 211 thấp
## 212 cao
## 213 thấp
## 214 thấp
## 215 thấp
## 216 thấp
## 217 thấp
## 218 thấp
## 219 thấp
## 220 thấp
## 221 thấp
## 222 thấp
## 223 thấp
## 224 cao
## 225 thấp
## 226 thấp
## 227 thấp
## 228 thấp
## 229 cao
## 230 thấp
## 231 thấp
## 232 thấp
## 233 thấp
## 234 thấp
## 235 thấp
## 236 thấp
## 237 cao
## 238 thấp
## 239 thấp
## 240 cao
## 241 thấp
## 242 thấp
## 243 thấp
## 244 thấp
## 245 thấp
## 246 thấp
## 247 thấp
## 248 cao
## 249 thấp
## 250 thấp
## 251 thấp
## 252 thấp
## 253 thấp
## 254 thấp
## 255 thấp
## 256 thấp
## 257 thấp
## 258 thấp
## 259 thấp
## 260 thấp
## 261 thấp
## 262 thấp
## 263 thấp
## 264 thấp
## 265 thấp
## 266 cao
## 267 cao
## 268 thấp
## 269 thấp
## 270 thấp
## 271 cao
## 272 thấp
## 273 thấp
## 274 thấp
## 275 thấp
## 276 thấp
## 277 thấp
## 278 thấp
## 279 thấp
## 280 thấp
## 281 thấp
## 282 cao
## 283 thấp
## 284 thấp
## 285 thấp
## 286 thấp
## 287 thấp
## 288 thấp
## 289 thấp
## 290 thấp
## 291 thấp
## 292 thấp
## 293 thấp
## 294 thấp
## 295 thấp
## 296 thấp
## 297 thấp
## 298 thấp
## 299 thấp
## 300 thấp
## 301 thấp
## 302 thấp
## 303 thấp
## 304 thấp
## 305 thấp
## 306 thấp
## 307 thấp
## 308 thấp
## 309 thấp
## 310 thấp
## 311 thấp
## 312 thấp
## 313 thấp
## 314 thấp
## 315 thấp
## 316 thấp
## 317 thấp
## 318 thấp
## 319 thấp
## 320 cao
## 321 thấp
## 322 thấp
## 323 thấp
## 324 thấp
## 325 thấp
## 326 thấp
## 327 cao
## 328 cao
## 329 thấp
## 330 thấp
## 331 thấp
## 332 thấp
## 333 thấp
## 334 thấp
## 335 thấp
## 336 thấp
## 337 thấp
## 338 thấp
## 339 thấp
## 340 thấp
## 341 thấp
## 342 thấp
## 343 thấp
## 344 thấp
## 345 thấp
## 346 thấp
## 347 thấp
## 348 thấp
## 349 thấp
## 350 cao
## 351 cao
## 352 thấp
## 353 thấp
## 354 cao
## 355 thấp
## 356 thấp
## 357 thấp
## 358 thấp
## 359 thấp
## 360 thấp
## 361 thấp
## 362 thấp
## 363 thấp
## 364 thấp
## 365 thấp
## 366 thấp
## 367 thấp
## 368 thấp
## 369 thấp
## 370 cao
## 371 thấp
## 372 thấp
## 373 thấp
## 374 thấp
## 375 thấp
## 376 thấp
## 377 thấp
## 378 cao
## 379 thấp
## 380 thấp
## 381 thấp
## 382 thấp
## 383 thấp
## 384 thấp
## 385 cao
## 386 thấp
## 387 thấp
## 388 thấp
## 389 thấp
## 390 thấp
## 391 cao
## 392 cao
## 393 cao
## 394 cao
## 395 cao
table(std$Dalc_2)
##
## cao thấp
## 44 351
table(std$Dalc_2)/length(std$Dalc_2)
##
## cao thấp
## 0.1113924 0.8886076
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.3.1
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.1
## Warning: package 'ggplot2' was built under R version 4.3.3
## Warning: package 'tibble' was built under R version 4.3.1
## Warning: package 'tidyr' was built under R version 4.3.1
## Warning: package 'readr' was built under R version 4.3.1
## Warning: package 'purrr' was built under R version 4.3.1
## Warning: package 'forcats' was built under R version 4.3.1
## Warning: package 'lubridate' was built under R version 4.3.1
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ readr 2.1.4
## ✔ ggplot2 3.5.1 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ✔ purrr 1.0.1 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::between() masks data.table::between()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::first() masks data.table::first()
## ✖ lubridate::hour() masks data.table::hour()
## ✖ lubridate::isoweek() masks data.table::isoweek()
## ✖ dplyr::lag() masks stats::lag()
## ✖ dplyr::last() masks data.table::last()
## ✖ lubridate::mday() masks data.table::mday()
## ✖ lubridate::minute() masks data.table::minute()
## ✖ lubridate::month() masks data.table::month()
## ✖ lubridate::quarter() masks data.table::quarter()
## ✖ lubridate::second() masks data.table::second()
## ✖ purrr::transpose() masks data.table::transpose()
## ✖ lubridate::wday() masks data.table::wday()
## ✖ lubridate::week() masks data.table::week()
## ✖ lubridate::yday() masks data.table::yday()
## ✖ lubridate::year() masks data.table::year()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
std %>% group_by(Dalc_2) %>% summarise(n = n()) %>%
ggplot(aes(x=Dalc_2,y=n)) +
geom_col(fill = "#89CFF0")+
geom_text(aes(label =n),vjust = 1, color = "white")+
theme_bw()
Nhận xét: Biểu đồ cột và bảng ở trên thể hiện mức độ tiêu thụ rượu của sinh viên trong 1 ngày. Theo khảo sát thì mức tiêu thụ rượu của sinh viên trong 1 ngày với mức độ tiêu thụ rượu cao chỉ có 44 sinh viên chiếm tỷ lệ 11.14%, còn lại 351 sinh viên với mức độ tiêu thụ rượu thấp chiếm tỷ lệ 88.86%. Như kết quả cho thấy, tại 2 ngôi trường này thì sinh viên tiêu thụ rượu trong 1 ngày rất là ít.
Biểu đồ tròn dưới đây cho thấy rõ hơn về mức độ tiêu thụ rượu của sinh viên trong 1 ngày.
ap <- prop.table(table(std$Dalc_2)) * 100
ggplot(mapping = aes(x = "", y = ap, fill = factor(names(ap)))) +
geom_bar(width = 1, stat = "identity") +
coord_polar("y") +
labs(title = "Phân bố mức độ tiêu thụ rượu trong 1 ngày",
fill = "Mức tiêu thụ") +
theme_void() +
geom_text(aes(label = paste0(round(ap, 1), "%")),
position = position_stack(vjust = 0.5))
## Don't know how to automatically pick scale for object of type <table>.
## Defaulting to continuous.
Phương pháp Chi bình phương
\[\chi^2 = \sum_{i,j} \frac{(n_{ij} -\hat{\mu}_{ij})^2}{\hat{\mu}_{ij}}\]
Với \(n_{i,j}\) là giá trị của ô \(i,j,\hat{\mu}_{ij}=\frac{n_{i+} \cdot n_{+j}}{n}\)
Giả thuyết:
\(H_0\): Dalc_2 và school độc lập
\(H_1\): Dalc_2 và school không độc lập
mtht <- table(std$Dalc_2, std$school)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 7.1839, df = 1, p-value = 0.007356
Nhận xét: Qua kết quả kiểm định cho ta p−value = 0.007356 < 0.05, bác bỏ \(H_0\), nghĩa là giữa việc sinh viên học ở trường nào và mức độ tiêu thụ rượu là có liên quan với nhau.
Giả thuyết:
\(H_0\): Dalc_2 và sex độc lập
\(H_1\): Dalc_2 và sex không độc lập
mtht <- table(std$Dalc_2, std$sex)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 22.078, df = 1, p-value = 2.618e-06
Nhận xét: Qua kết quả kiểm định cho ta p−value = 2.618e-06 < 0.05, bác bỏ \(H_0\), nghĩa là giữa giới tính của sinh viên và mức độ tiêu thụ rượu là có liên quan với nhau.
Giả thuyết:
\(H_0\): Dalc_2 và address độc lập
\(H_1\): Dalc_2 và address không độc lập
mtht <- table(std$Dalc_2, std$address)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 3.2594, df = 1, p-value = 0.07101
Nhận xét: Qua kết quả kiểm định cho ta p−value = 0.07101 > 0.05, chưa có cơ sở bác bỏ \(H_0\), nghĩa là giữa nơi ở của sinh viên và mức độ tiêu thụ rượu không có liên quan với nhau.
Giả thuyết:
\(H_0\): Dalc_2 và schoolsup độc lập
\(H_1\): Dalc_2 và schoolsup không độc lập
mtht <- table(std$Dalc_2, std$schoolsup)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 0.31726, df = 1, p-value = 0.5733
Nhận xét: Qua kết quả kiểm định cho ta p−value = 0.5733 > 0.05, chưa có cơ sở bác bỏ \(H_0\), nghĩa là giữa việc hỗ trợ giáo dục bổ sung cho sinh viên và mức độ tiêu thụ rượu không có liên quan với nhau.
Giả thuyết:
\(H_0\): Dalc_2 và famsup độc lập
\(H_1\): Dalc_2 và famsup không độc lập
mtht <- table(std$Dalc_2, std$famsup)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 1.288, df = 1, p-value = 0.2564
Nhận xét: Qua kết quả kiểm định cho ta p−value = 0.2564 > 0.05, chưa có cơ sở bác bỏ \(H_0\), nghĩa là giữa việc hỗ trợ giáo dục gia đình và mức độ tiêu thụ rượu không có liên quan với nhau.
Giả thuyết:
\(H_0\): Dalc_2 và activities độc lập
\(H_1\): Dalc_2 và activities không độc lập
mtht <- table(std$Dalc_2, std$activities)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 1.5485, df = 1, p-value = 0.2134
Nhận xét: Qua kết quả kiểm định cho ta p−value = 0.2134 > 0.05, chưa đủ cơ sở bác bỏ \(H_0\), nghĩa là giữa việc hoạt động ngoại khóa của sinh viên và mức độ tiêu thụ rượu không có liên quan với nhau.
Giả thuyết:
\(H_0\): Dalc_2 và internet độc lập
\(H_1\): Dalc_2 và internet không độc lập
mtht <- table(std$Dalc_2, std$internet)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 1.7168e-30, df = 1, p-value = 1
Nhận xét: Qua kết quả kiểm định cho ta p−value = 1 > 0.05, chưa đủ cơ sở bác bỏ \(H_0\), nghĩa là giữa việc sử dụng mạng tại nhà của sinh viên và mức độ tiêu thụ rượu không có liên quan với nhau.
Giả thuyết:
\(H_0\): Dalc_2 và romantic độc lập
\(H_1\): Dalc_2 và sex romantic độc lập
mtht <- table(std$Dalc_2, std$romantic)
chisq.test(mtht)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mtht
## X-squared = 0.0047742, df = 1, p-value = 0.9449
Nhận xét: Qua kết quả kiểm định cho ta p−value = 0.9449 > 0.05, chưa đủ cơ sở bác bỏ \(H_0\), nghĩa là giữa mối quan hệ tình cảm của sinh viên và mức độ tiêu thụ rượu không có liên quan với nhau.
Kết luận: Chỉ có biến school (trường học) và sex (giới tính) là có ảnh hưởng tới biến Dalc_2. Tiếp theo, nhóm tiến hành mô tả 2 biến, từ đó đưa ra cái nhìn khái quát hơn về mức độ ảnh hưởng lên biến Dalc_2.
htnh <- table(std$Dalc_2,std$school)
addmargins(htnh)
##
## GP MS Sum
## cao 33 11 44
## thấp 316 35 351
## Sum 349 46 395
htnh <- prop.table(htnh)
addmargins(htnh)
##
## GP MS Sum
## cao 0.08354430 0.02784810 0.11139241
## thấp 0.80000000 0.08860759 0.88860759
## Sum 0.88354430 0.11645570 1.00000000
std %>% group_by(Dalc_2,school) %>% summarise(n = n()) %>%
ggplot(aes(x=Dalc_2,y=n, fill = school)) +
geom_col(position = 'dodge')+
theme_bw()
## `summarise()` has grouped output by 'Dalc_2'. You can override using the
## `.groups` argument.
Nhận xét: Bảng và biểu đồ trên cho thấy ở trường GP có 33 sinh viên có mức tiêu thụ rượu cao chiếm tỷ lệ 8.35%, còn lại 316 sinh viên có mức tiêu thụ rượu thấp chiếm tỷ lệ 80%; ở trường MS có 11 sinh viên có mức tiêu thụ rượu cao chiếm tỷ lệ 2.78%, còn lại 35 sinh viên có mức tiêu thụ rượu thấp chiếm 8.86%. Tóm lại thì cả hai trường đều có số lượng ít sinh viên có mức tiêu thụ rượu cao, đa số đều tiêu thụ rượu thấp hoặc hầu như là không tiêu thụ.
htnh <- table(std$Dalc_2,std$sex)
addmargins(htnh)
##
## F M Sum
## cao 8 36 44
## thấp 200 151 351
## Sum 208 187 395
htnh <- prop.table(htnh)
addmargins(htnh)
##
## F M Sum
## cao 0.02025316 0.09113924 0.11139241
## thấp 0.50632911 0.38227848 0.88860759
## Sum 0.52658228 0.47341772 1.00000000
std %>% group_by(Dalc_2,sex) %>% summarise(n = n()) %>%
ggplot(aes(x=Dalc_2,y=n, fill = sex)) +
geom_col(position = 'dodge')+
theme_bw()
## `summarise()` has grouped output by 'Dalc_2'. You can override using the
## `.groups` argument.
Nhận xét: Bảng và biểu đồ trên cho thấy ở giới tính nữ có 8 sinh viên có mức tiêu thụ rượu cao chiếm tỷ lệ 2.03%, còn lại 200 sinh viên nữ có mức tiêu thụ rượu thấp chiếm tỷ lệ 50.63%%; ở giới tính nam có 36 sinh viên có mức tiêu thụ rượu cao chiếm tỷ lệ 9.11%, còn lại 151 sinh viên nam có mức tiêu thụ rượu thấp chiếm 38.23%. Tóm lại thì cả hai giới tính đều có số lượng ít sinh viên có mức tiêu thụ rượu cao, đa số đều tiêu thụ rượu thấp hoặc hầu như là không tiêu thụ.
library(DescTools)
## Warning: package 'DescTools' was built under R version 4.3.3
##
## Attaching package: 'DescTools'
## The following object is masked from 'package:data.table':
##
## %like%
table(std$Dalc_2,std$school)
##
## GP MS
## cao 33 11
## thấp 316 35
mtht <- table(std$Dalc_2,std$school)
RelRisk(mtht, conf.level = .95)
## rel. risk lwr.ci upr.ci
## 0.8330696 0.6711519 0.9549721
Nhận xét:
Relative Risk của Dalc_2 và school là 0.8330696 nhỏ hơn 1. Điều này có nghĩa là sinh viên trường GP có mức độ tiêu thụ rượu cao nhiều hơn so với trường MS (mức độ tiêu thụ rượu cao ở trường GP bằng 0.833 lần so với trường MS).
Khoảng tin cậy này cho thấy rằng, với mức độ tin cậy (thường là 95%), mức độ tiêu thụ rượu thực sự nằm trong khoảng từ 0.6711519 đến 0.9549721. Vì khoảng tin cậy này không bao gồm giá trị 1, kết quả này cho thấy có ý nghĩa thống kê giữa mức độ tiêu thụ rượu cao ở hai trường.
library(DescTools)
table(std$Dalc_2,std$sex)
##
## F M
## cao 8 36
## thấp 200 151
mtht <- table(std$Dalc_2,std$sex)
RelRisk(mtht, conf.level = .95)
## rel. risk lwr.ci upr.ci
## 0.3190909 0.1659926 0.5656633
Nhận xét:
Relative Risk của Dalc_2 và sex là 0.3190909 nhỏ hơn 1. Điều này có nghĩa là sinh viên nữ có mức độ tiêu thụ rượu cao ít hơn so với sinh viên nam (mức độ tiêu thụ rượu cao ở sinh viên nữ bằng 0.319 lần so với sinh viên nam).
Khoảng tin cậy này cho thấy rằng, với mức độ tin cậy (thường là 95%), mức độ tiêu thụ rượu thực sự nằm trong khoảng từ 0.1659926 đến 0.5656633. Vì khoảng tin cậy này không bao gồm giá trị 1, kết quả này cho thấy có ý nghĩa thống kê giữa mức độ tiêu thụ rượu cao ở giới tính nữ và nam.
table(std$Dalc_2,std$school)
##
## GP MS
## cao 33 11
## thấp 316 35
ntnh <- table(std$Dalc_2,std$school)
OddsRatio(ntnh,conf.level = .95)
## odds ratio lwr.ci upr.ci
## 0.3322785 0.1543865 0.7151466
Nhận xét:
Odds ratio của Dalc_2 và school là 0.3322785 nhỏ hơn 1. Điều này có nghĩa là tỷ lệ chênh của sinh viên tiêu thụ rượu cao tại trường GP so với trường MS là 0.332, tức là sinh viên tại trường GP có tỷ lệ tiêu thụ rượu cao thấp hơn so với sinh viên tại trường MS.
Khoảng tin cậy này cho thấy rằng, với mức độ tin cậy (thường là 95%), odds ratio thực sự nằm trong khoảng từ 0.1543865 đến 0.7151466. Vì khoảng tin cậy này không bao gồm giá trị 1, kết quả này có ý nghĩa thống kê.
table(std$Dalc_2,std$sex)
##
## F M
## cao 8 36
## thấp 200 151
ntnh <- table(std$Dalc_2,std$sex)
OddsRatio(ntnh,conf.level = .95)
## odds ratio lwr.ci upr.ci
## 0.16777778 0.07578856 0.37141995
Nhận xét:
Odds ratio của Dalc_2 và sex là 0.16777778 nhỏ hơn 1. Điều này có nghĩa là tỷ lệ chênh của sinh viên tiêu thụ rượu cao là nữ so với nam là 0.167, tức là sinh viên nữ có tỷ lệ tiêu thụ rượu cao thấp hơn so với sinh viên nam.
Khoảng tin cậy này cho thấy rằng, với mức độ tin cậy (thường là 95%), odds ratio thực sự nằm trong khoảng từ 0.07578856 đến 0.37141995. Vì khoảng tin cậy này không bao gồm giá trị 1, kết quả này có ý nghĩa thống kê.
library(tidyverse)
tn <- std %>% select(Dalc_2, school, sex)
tn <- tn %>% mutate(Dalc_2 = if_else(Dalc_2 == "thấp", 0, 1))
tn <- tn %>% mutate(school = case_when(
school == "GP" ~ 0,
school == "MS" ~ 1
))
tn <- tn %>% mutate(sex = case_when(
sex == "F" ~ 0,
sex == "M" ~ 1
))
head(tn)
lpm_school <- lm(Dalc_2 ~ school, data = tn)
summary(lpm_school)
##
## Call:
## lm(formula = Dalc_2 ~ school, data = tn)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.23913 -0.09456 -0.09456 -0.09456 0.90544
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.09456 0.01670 5.662 2.89e-08 ***
## school 0.14457 0.04894 2.954 0.00332 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.312 on 393 degrees of freedom
## Multiple R-squared: 0.02173, Adjusted R-squared: 0.01924
## F-statistic: 8.729 on 1 and 393 DF, p-value: 0.003321
lpm_sex <- lm(Dalc_2 ~ sex, data = tn)
summary(lpm_sex)
##
## Call:
## lm(formula = Dalc_2 ~ sex, data = tn)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.19251 -0.19251 -0.03846 -0.03846 0.96154
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.03846 0.02121 1.814 0.0705 .
## sex 0.15405 0.03082 4.998 8.73e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3058 on 393 degrees of freedom
## Multiple R-squared: 0.05977, Adjusted R-squared: 0.05738
## F-statistic: 24.98 on 1 and 393 DF, p-value: 8.728e-07
lpm_school <- glm(Dalc_2 ~ school, data = tn, family = binomial)
summary(lpm_school)
##
## Call:
## glm(formula = Dalc_2 ~ school, family = binomial, data = tn)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.2592 0.1829 -12.349 < 2e-16 ***
## school 1.1018 0.3911 2.817 0.00484 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 276.04 on 394 degrees of freedom
## Residual deviance: 269.05 on 393 degrees of freedom
## AIC: 273.05
##
## Number of Fisher Scoring iterations: 5
lpm_sex <- glm(Dalc_2 ~ sex, data = tn, family = binomial)
summary(lpm_sex)
##
## Call:
## glm(formula = Dalc_2 ~ sex, family = binomial, data = tn)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.2189 0.3606 -8.928 < 2e-16 ***
## sex 1.7851 0.4055 4.403 1.07e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 276.04 on 394 degrees of freedom
## Residual deviance: 251.02 on 393 degrees of freedom
## AIC: 255.02
##
## Number of Fisher Scoring iterations: 6
reglogit <- glm (Dalc_2 ~ school, data = tn, family = binomial(link = 'logit'))
print(reglogit)
##
## Call: glm(formula = Dalc_2 ~ school, family = binomial(link = "logit"),
## data = tn)
##
## Coefficients:
## (Intercept) school
## -2.259 1.102
##
## Degrees of Freedom: 394 Total (i.e. Null); 393 Residual
## Null Deviance: 276
## Residual Deviance: 269 AIC: 273
regprobit <- glm (Dalc_2 ~ sex, data = tn, family = binomial(link = 'probit'))
print(regprobit)
##
## Call: glm(formula = Dalc_2 ~ sex, family = binomial(link = "probit"),
## data = tn)
##
## Coefficients:
## (Intercept) sex
## -1.7688 0.9002
##
## Degrees of Freedom: 394 Total (i.e. Null); 393 Residual
## Null Deviance: 276
## Residual Deviance: 251 AIC: 255
(mục lớn nha) Đánh giá mô hình Chỉ số AIC