Vi du ve doc du lieu
data=read.csv("C:/Users/binht/Dropbox/PhD/Data/Tu/Academic stress/dulieu.csv")
names(data)
## [1] "lop" "msp" "a1" "a2" "a3" "a3x4" "a4" "a5" "a5x5"
## [10] "a6" "a6x5" "a7" "a14" "a151" "a152" "a153" "a154" "a155"
## [19] "a16" "a20" "a21" "a21x4" "a22" "a23x1" "a23x2" "dl1" "dl2"
## [28] "dl3" "dl4" "dl5" "mt1" "mt2" "mt3" "mt4" "mt5" "mt6"
## [37] "mt7" "mt8" "dk1" "dk2" "dk3" "dk4" "dk5" "dk6" "dk7"
## [46] "clgv1" "clgv2" "clgv3" "clgv4" "clgv5" "clgv6" "clgv7" "clgv8" "clgv9"
## [55] "ctdt1" "ctdt2" "ctdt3" "ctdt4" "ctdt5" "ctdt6" "ctdt7" "clql1" "clql2"
## [64] "clql3" "clql4" "clql5" "clql6" "ctsv1" "ctsv2" "ctsv3" "ctsv4" "ctsv5"
## [73] "hdpt1" "hdpt2" "hdpt3" "hdpt4" "hdpt5" "hdpt6" "c1" "c2" "c3"
## [82] "c4" "c5" "c6" "c7" "c8" "c9" "c10" "c11" "c12"
## [91] "c13" "c14" "c15" "c16" "year" "essa" "dlht" "mtht" "dkht"
## [100] "clgv" "ctdt" "ctql" "ctsv" "hdpt"
dinh nghia bien so
data$year=as.factor(data$year)
data$a2=as.factor(data$a2)
data$a3=as.factor(data$a3)
data$a4=as.factor(data$a4)
data$a5=as.factor(data$a5)
data$a6=as.factor(data$a6)
data$a7=as.factor(data$a7)
data$a151=as.factor(data$a151)
data$a153=as.factor(data$a153)
data$a155=as.factor(data$a155)
data$a16=as.factor(data$a16)
data$a20=as.factor(data$a20)
data$a21=as.factor(data$a21)
data$a23x1=as.factor(data$a23x1)
data$a23x2=as.factor(data$a23x2)
Chay cac bang mo ta
chay cac packages (table1, comparegroups)
library(table1)
## Warning: package 'table1' was built under R version 4.0.4
##
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
##
## units, units<-
library(compareGroups)
## Warning: package 'compareGroups' was built under R version 4.0.3
test thu 1 bang
t1=compareGroups(year~a2+a2+a3+a4+a5+a6+a7+a151+a152+a153+a154+a155+a16+a21+a22+a23x1 + a23x2, data=data)
## Warning in compareGroups.fit(X = X, y = y, include.label = include.label, :
## Variables 'a155' have been removed since some errors occurred
t1
##
##
## -------- Summary of results by groups of 'year'---------
##
##
## var N p.value method selection
## 1 a2 878 0.246 categorical ALL
## 2 a2 878 0.246 categorical ALL
## 3 a3 878 0.009** categorical ALL
## 4 a4 878 . categorical ALL
## 5 a5 878 . categorical ALL
## 6 a6 878 . categorical ALL
## 7 a7 878 . categorical ALL
## 8 a151 878 0.211 categorical ALL
## 9 a152 20 0.187 continuous normal ALL
## 10 a153 878 0.051* categorical ALL
## 11 a154 189 0.076* continuous normal ALL
## 12 a16 878 <0.001** categorical ALL
## 13 a21 878 0.162 categorical ALL
## 14 a22 878 0.119 continuous normal ALL
## 15 a23x1 878 . categorical ALL
## 16 a23x2 878 . categorical ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
createTable(t1)
##
## --------Summary descriptives table by 'year'---------
##
## ____________________________________________________
## 1 2 3 p.overall
## N=233 N=297 N=348
## ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
## a2: 0.246
## 1 110 (47.2%) 119 (40.1%) 147 (42.2%)
## 2 123 (52.8%) 178 (59.9%) 201 (57.8%)
## a2: 0.246
## 1 110 (47.2%) 119 (40.1%) 147 (42.2%)
## 2 123 (52.8%) 178 (59.9%) 201 (57.8%)
## a3: 0.009
## 1 195 (83.7%) 265 (89.2%) 309 (88.8%)
## 2 28 (12.0%) 12 (4.04%) 23 (6.61%)
## 3 9 (3.86%) 19 (6.40%) 16 (4.60%)
## 4 1 (0.43%) 1 (0.34%) 0 (0.00%)
## a4: .
## 1 179 (76.8%) 0 (0.00%) 75 (21.6%)
## 2 1 (0.43%) 0 (0.00%) 0 (0.00%)
## 3 0 (0.00%) 297 (100%) 0 (0.00%)
## 5 53 (22.7%) 0 (0.00%) 273 (78.4%)
## a5: .
## 1 28 (12.0%) 31 (10.4%) 38 (10.9%)
## 2 132 (56.7%) 202 (68.0%) 234 (67.2%)
## 3 65 (27.9%) 60 (20.2%) 69 (19.8%)
## 4 8 (3.43%) 3 (1.01%) 2 (0.57%)
## 5 0 (0.00%) 1 (0.34%) 5 (1.44%)
## a6: .
## 1 23 (9.87%) 22 (7.41%) 39 (11.2%)
## 2 87 (37.3%) 102 (34.3%) 117 (33.6%)
## 3 85 (36.5%) 131 (44.1%) 118 (33.9%)
## 4 38 (16.3%) 42 (14.1%) 71 (20.4%)
## 5 0 (0.00%) 0 (0.00%) 3 (0.86%)
## a7: .
## 1 11 (4.72%) 25 (8.42%) 12 (3.45%)
## 2 63 (27.0%) 127 (42.8%) 81 (23.3%)
## 3 117 (50.2%) 120 (40.4%) 190 (54.6%)
## 4 34 (14.6%) 21 (7.07%) 53 (15.2%)
## 5 8 (3.43%) 4 (1.35%) 10 (2.87%)
## 6 0 (0.00%) 0 (0.00%) 2 (0.57%)
## a151: 0.211
## 1 5 (2.15%) 4 (1.35%) 12 (3.45%)
## 2 228 (97.9%) 293 (98.7%) 336 (96.6%)
## a152 16.5 (17.7) 3.75 (2.75) 9.33 (7.04) 0.187
## a153: 0.051
## 1 38 (16.3%) 71 (23.9%) 84 (24.1%)
## 2 195 (83.7%) 226 (76.1%) 264 (75.9%)
## a154 0.97 (0.32) 0.94 (0.43) 1.30 (1.54) 0.076
## a16: <0.001
## 1 12 (5.15%) 31 (10.4%) 19 (5.46%)
## 2 42 (18.0%) 87 (29.3%) 91 (26.1%)
## 3 78 (33.5%) 88 (29.6%) 80 (23.0%)
## 4 57 (24.5%) 59 (19.9%) 80 (23.0%)
## 5 44 (18.9%) 32 (10.8%) 78 (22.4%)
## a21: 0.162
## 1 35 (15.0%) 40 (13.5%) 42 (12.1%)
## 2 62 (26.6%) 103 (34.7%) 109 (31.3%)
## 3 127 (54.5%) 132 (44.4%) 176 (50.6%)
## 4 9 (3.86%) 22 (7.41%) 21 (6.03%)
## a22 3.35 (0.68) 3.23 (0.68) 3.28 (0.63) 0.119
## a23x1: .
## 1 2 (0.86%) 3 (1.01%) 7 (2.01%)
## 2 16 (6.87%) 18 (6.06%) 15 (4.31%)
## 3 104 (44.6%) 153 (51.5%) 134 (38.5%)
## 4 104 (44.6%) 109 (36.7%) 177 (50.9%)
## 5 7 (3.00%) 14 (4.71%) 15 (4.31%)
## a23x2: .
## 1 4 (1.72%) 2 (0.67%) 2 (0.57%)
## 2 30 (12.9%) 51 (17.2%) 34 (9.77%)
## 3 101 (43.3%) 160 (53.9%) 159 (45.7%)
## 4 90 (38.6%) 74 (24.9%) 138 (39.7%)
## 5 8 (3.43%) 10 (3.37%) 15 (4.31%)
## ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯