Primary Activities

Library

library(dplyr)
## Warning: package 'dplyr' was built under R version 4.6.1
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(gtsummary)

Data

data(trial)
head(trial)
library(readxl)
df <- read_excel("C:/Users/user/Downloads/HBV Data_All (1).xlsx")
head(df)

Analysis

Descriptive Analysis

Univariate

df %>% 
  tbl_summary()
Characteristic N = 5351
Gender
    Female 230 (43%)
    Male 305 (57%)
Age
    19 1 (0.2%)
    20 5 (0.9%)
    21 11 (2.1%)
    22 42 (7.9%)
    23 58 (11%)
    24 87 (16%)
    25 97 (18%)
    26 52 (9.7%)
    27 33 (6.2%)
    28 36 (6.7%)
    29 24 (4.5%)
    30 38 (7.1%)
    31 14 (2.6%)
    32 18 (3.4%)
    33 3 (0.6%)
    34 5 (0.9%)
    35 2 (0.4%)
    36 3 (0.6%)
    37 1 (0.2%)
    38 1 (0.2%)
    39 1 (0.2%)
    43 1 (0.2%)
    45 1 (0.2%)
    es 1 (0.2%)
Academic Year
    1st Year 6 (1.1%)
    2nd Year 4 (0.7%)
    3rd Year 34 (6.4%)
    4th Year 64 (12%)
    5th Year 169 (32%)
    Trainee doctor 258 (48%)
Have you been vaccinated against Hepatitis B? 359 (67%)
How many doses of Hepatitis B vaccine did you receive?
    Can't Remember 84 (23%)
    More than three doses 82 (23%)
    One dose 16 (4.5%)
    Three doses 121 (34%)
    Two doses 56 (16%)
    Unknown 176
What are the reasons for you not being vaccinated?
    Efficacy doubted 10 (5.7%)
    High vaccination fees 26 (15%)
    Lack of knowledge 37 (21%)
    Low risk of Hepatitis B 4 (2.3%)
    No vaccination program offered 52 (30%)
    Not sure about vaccination status 47 (27%)
    Unknown 359
1. Hepatitis B is caused by a virus
    Agree 101 (19%)
    Disagree 4 (0.7%)
    Neutral 9 (1.7%)
    Strongly Agree 411 (77%)
    Strongly Disagree 10 (1.9%)
2. Hepatitis B can be transmitted by [a. Infected mother to fetus]
    Agree 124 (23%)
    Disagree 15 (2.8%)
    Neutral 45 (8.4%)
    Strongly Agree 310 (58%)
    Strongly Disagree 41 (7.7%)
2. Hepatitis B can be transmitted by [b. Contaminated blood & body fluids]
    Agree 127 (24%)
    Disagree 14 (2.6%)
    Neutral 22 (4.1%)
    Strongly Agree 331 (62%)
    Strongly Disagree 41 (7.7%)
2. Hepatitis B can be transmitted by [c. Unprotected sex with infected ones]
    Agree 131 (24%)
    Disagree 23 (4.3%)
    Neutral 31 (5.8%)
    Strongly Agree 306 (57%)
    Strongly Disagree 44 (8.2%)
2. Hepatitis B can be transmitted by [d. Casual contact (shaking hands)]
    Agree 25 (4.7%)
    Disagree 149 (28%)
    Neutral 41 (7.7%)
    Strongly Agree 28 (5.2%)
    Strongly Disagree 292 (55%)
2. Hepatitis B can be transmitted by [e. Unsterilized syringes/needles]
    Agree 124 (23%)
    Disagree 22 (4.1%)
    Neutral 32 (6.0%)
    Strongly Agree 304 (57%)
    Strongly Disagree 53 (9.9%)
2. Hepatitis B can be transmitted by [f. Coughing/sneezing]
    Agree 35 (6.5%)
    Disagree 192 (36%)
    Neutral 52 (9.7%)
    Strongly Agree 33 (6.2%)
    Strongly Disagree 223 (42%)
2. Hepatitis B can be transmitted by [g. Contaminated food/water]
    Agree 59 (11%)
    Disagree 146 (27%)
    Neutral 48 (9.0%)
    Strongly Agree 73 (14%)
    Strongly Disagree 209 (39%)
3. Hepatitis B can cause liver cancer.
    Agree 199 (37%)
    Disagree 12 (2.2%)
    Neutral 38 (7.1%)
    Strongly Agree 274 (51%)
    Strongly Disagree 12 (2.2%)
4. Health care workers are at increased risk of getting Hepatitis B than general population.
    Agree 157 (29%)
    Disagree 12 (2.2%)
    Neutral 39 (7.3%)
    Strongly Agree 313 (59%)
    Strongly Disagree 14 (2.6%)
5. Hepatitis B can be prevented by [a. Vaccination]
    Agree 122 (23%)
    Disagree 6 (1.1%)
    Neutral 21 (3.9%)
    Strongly Agree 363 (68%)
    Strongly Disagree 23 (4.3%)
5. Hepatitis B can be prevented by [b. Antivirals]
    Agree 140 (26%)
    Disagree 103 (19%)
    Neutral 136 (25%)
    Strongly Agree 89 (17%)
    Strongly Disagree 67 (13%)
5. Hepatitis B can be prevented by [c. Avoiding sharp needle/syringe injury]
    Agree 170 (32%)
    Disagree 34 (6.4%)
    Neutral 55 (10%)
    Strongly Agree 252 (47%)
    Strongly Disagree 24 (4.5%)
5. Hepatitis B can be prevented by [d. Avoiding contaminated water/food]
    Agree 96 (18%)
    Disagree 135 (25%)
    Neutral 96 (18%)
    Strongly Agree 87 (16%)
    Strongly Disagree 121 (23%)
5. Hepatitis B can be prevented by [e. Using gloves when handling body fluid]
    Agree 196 (37%)
    Disagree 29 (5.4%)
    Neutral 38 (7.1%)
    Strongly Agree 237 (44%)
    Strongly Disagree 35 (6.5%)
6. I feel uncomfortable sitting with Hepatitis B infected person.
    Agree 84 (16%)
    Disagree 164 (31%)
    Neutral 107 (20%)
    Strongly agree 57 (11%)
    Strongly disagree 123 (23%)
7. I don’t mind shaking hands/ hugging with Hepatitis B infected person
    Agree 222 (41%)
    Disagree 56 (10%)
    Neutral 91 (17%)
    Strongly Agree 135 (25%)
    Strongly disagree 31 (5.8%)
8. I believe Hepatitis B vaccine is safe and effective.
    Agree 226 (42%)
    Disagree 8 (1.5%)
    Neutral 48 (9.0%)
    Strongly agree 250 (47%)
    Strongly disagree 3 (0.6%)
9. I believe health care workers should receive Hepatitis B vaccination.
    Agree 128 (24%)
    Disagree 8 (1.5%)
    Neutral 26 (4.9%)
    Strongly agree 366 (68%)
    Strongly disagree 7 (1.3%)
10. I don’t need Hepatitis B vaccination because I am not at risk.
    Agree 43 (8.0%)
    Disagree 181 (34%)
    Neutral 40 (7.5%)
    Strongly Agree 18 (3.4%)
    Strongly disagree 253 (47%)
11. I’m afraid attending surgical procedure during clinical observation placement if there is a Hepatitis B positive person
    Agree 183 (34%)
    Disagree 80 (15%)
    Neutral 96 (18%)
    Strongly agree 128 (24%)
    Strongly disagree 48 (9.0%)
12. I ask/use a new blade for shaving/hair cutting.
    Agree 163 (30%)
    Disagree 6 (1.1%)
    Neutral 29 (5.4%)
    Strongly Agree 329 (61%)
    Strongly disagree 8 (1.5%)
13. I ask for a new syringe before injection.
    Agree 128 (24%)
    Disagree 6 (1.1%)
    Neutral 18 (3.4%)
    Strongly Agree 379 (71%)
    Strongly disagree 4 (0.7%)
14. I ask for sterilized equipment for ear/nose piercings.
    Agree 142 (27%)
    Disagree 3 (0.6%)
    Neutral 37 (6.9%)
    Strongly Agree 350 (65%)
    Strongly disagree 3 (0.6%)
15. I always report for needle pricks / sharp injuries.
    Agree 219 (41%)
    Disagree 17 (3.2%)
    Neutral 75 (14%)
    Strongly Agree 217 (41%)
    Strongly Disagree 7 (1.3%)
16. I attend hepatitis B related awareness program
    Agree 201 (38%)
    Disagree 39 (7.3%)
    Neutral 114 (21%)
    Strongly Agree 175 (33%)
    Strongly disagree 6 (1.1%)
17. I always take extra precautions before attending any surgical procedures
    Agree 176 (33%)
    Disagree 7 (1.3%)
    Neutral 53 (9.9%)
    Strongly agree 297 (56%)
    Strongly disagree 2 (0.4%)
1 n (%)

bivariate

df %>% 
  tbl_summary(
    by=Gender
  ) %>% 
  add_p() %>% 
  add_n()
## The following errors were returned during `add_p()`:
## ✖ For variable `Age` (`Gender`) and "estimate", "p.value", "conf.low", and
##   "conf.high" statistics: FEXACT error 7(location). LDSTP=18510 is too small
##   for this problem, (pastp=42.8269, ipn_0:=ipoin[itp=562]=29,
##   stp[ipn_0]=42.9823). Increase workspace or consider using
##   'simulate.p.value=TRUE'
Characteristic N Female
N = 230
1
Male
N = 305
1
p-value2
Age 535


    19
1 (0.4%) 0 (0%)
    20
2 (0.9%) 3 (1.0%)
    21
8 (3.5%) 3 (1.0%)
    22
18 (7.8%) 24 (7.9%)
    23
26 (11%) 32 (10%)
    24
36 (16%) 51 (17%)
    25
43 (19%) 54 (18%)
    26
23 (10%) 29 (9.5%)
    27
10 (4.3%) 23 (7.5%)
    28
16 (7.0%) 20 (6.6%)
    29
9 (3.9%) 15 (4.9%)
    30
16 (7.0%) 22 (7.2%)
    31
5 (2.2%) 9 (3.0%)
    32
8 (3.5%) 10 (3.3%)
    33
1 (0.4%) 2 (0.7%)
    34
2 (0.9%) 3 (1.0%)
    35
1 (0.4%) 1 (0.3%)
    36
1 (0.4%) 2 (0.7%)
    37
0 (0%) 1 (0.3%)
    38
1 (0.4%) 0 (0%)
    39
1 (0.4%) 0 (0%)
    43
1 (0.4%) 0 (0%)
    45
1 (0.4%) 0 (0%)
    es
0 (0%) 1 (0.3%)
Academic Year 535

0.10
    1st Year
0 (0%) 6 (2.0%)
    2nd Year
3 (1.3%) 1 (0.3%)
    3rd Year
14 (6.1%) 20 (6.6%)
    4th Year
25 (11%) 39 (13%)
    5th Year
67 (29%) 102 (33%)
    Trainee doctor
121 (53%) 137 (45%)
Have you been vaccinated against Hepatitis B? 535 153 (67%) 206 (68%) 0.8
How many doses of Hepatitis B vaccine did you receive? 359

0.3
    Can't Remember
31 (20%) 53 (26%)
    More than three doses
43 (28%) 39 (19%)
    One dose
5 (3.3%) 11 (5.3%)
    Three doses
51 (33%) 70 (34%)
    Two doses
23 (15%) 33 (16%)
    Unknown
77 99
What are the reasons for you not being vaccinated? 176

0.3
    Efficacy doubted
6 (7.8%) 4 (4.0%)
    High vaccination fees
13 (17%) 13 (13%)
    Lack of knowledge
10 (13%) 27 (27%)
    Low risk of Hepatitis B
2 (2.6%) 2 (2.0%)
    No vaccination program offered
24 (31%) 28 (28%)
    Not sure about vaccination status
22 (29%) 25 (25%)
    Unknown
153 206
1. Hepatitis B is caused by a virus 535

<0.001
    Agree
56 (24%) 45 (15%)
    Disagree
2 (0.9%) 2 (0.7%)
    Neutral
0 (0%) 9 (3.0%)
    Strongly Agree
165 (72%) 246 (81%)
    Strongly Disagree
7 (3.0%) 3 (1.0%)
2. Hepatitis B can be transmitted by [a. Infected mother to fetus] 535

0.6
    Agree
59 (26%) 65 (21%)
    Disagree
8 (3.5%) 7 (2.3%)
    Neutral
20 (8.7%) 25 (8.2%)
    Strongly Agree
125 (54%) 185 (61%)
    Strongly Disagree
18 (7.8%) 23 (7.5%)
2. Hepatitis B can be transmitted by [b. Contaminated blood & body fluids] 535

0.010
    Agree
68 (30%) 59 (19%)
    Disagree
5 (2.2%) 9 (3.0%)
    Neutral
4 (1.7%) 18 (5.9%)
    Strongly Agree
133 (58%) 198 (65%)
    Strongly Disagree
20 (8.7%) 21 (6.9%)
2. Hepatitis B can be transmitted by [c. Unprotected sex with infected ones] 535

0.12
    Agree
56 (24%) 75 (25%)
    Disagree
13 (5.7%) 10 (3.3%)
    Neutral
7 (3.0%) 24 (7.9%)
    Strongly Agree
133 (58%) 173 (57%)
    Strongly Disagree
21 (9.1%) 23 (7.5%)
2. Hepatitis B can be transmitted by [d. Casual contact (shaking hands)] 535

<0.001
    Agree
16 (7.0%) 9 (3.0%)
    Disagree
82 (36%) 67 (22%)
    Neutral
10 (4.3%) 31 (10%)
    Strongly Agree
11 (4.8%) 17 (5.6%)
    Strongly Disagree
111 (48%) 181 (59%)
2. Hepatitis B can be transmitted by [e. Unsterilized syringes/needles] 535

0.4
    Agree
59 (26%) 65 (21%)
    Disagree
10 (4.3%) 12 (3.9%)
    Neutral
14 (6.1%) 18 (5.9%)
    Strongly Agree
120 (52%) 184 (60%)
    Strongly Disagree
27 (12%) 26 (8.5%)
2. Hepatitis B can be transmitted by [f. Coughing/sneezing] 535

<0.001
    Agree
22 (9.6%) 13 (4.3%)
    Disagree
99 (43%) 93 (30%)
    Neutral
14 (6.1%) 38 (12%)
    Strongly Agree
12 (5.2%) 21 (6.9%)
    Strongly Disagree
83 (36%) 140 (46%)
2. Hepatitis B can be transmitted by [g. Contaminated food/water] 535

0.009
    Agree
28 (12%) 31 (10%)
    Disagree
77 (33%) 69 (23%)
    Neutral
16 (7.0%) 32 (10%)
    Strongly Agree
35 (15%) 38 (12%)
    Strongly Disagree
74 (32%) 135 (44%)
3. Hepatitis B can cause liver cancer. 535

0.016
    Agree
104 (45%) 95 (31%)
    Disagree
5 (2.2%) 7 (2.3%)
    Neutral
13 (5.7%) 25 (8.2%)
    Strongly Agree
102 (44%) 172 (56%)
    Strongly Disagree
6 (2.6%) 6 (2.0%)
4. Health care workers are at increased risk of getting Hepatitis B than general population. 535

0.024
    Agree
82 (36%) 75 (25%)
    Disagree
3 (1.3%) 9 (3.0%)
    Neutral
11 (4.8%) 28 (9.2%)
    Strongly Agree
129 (56%) 184 (60%)
    Strongly Disagree
5 (2.2%) 9 (3.0%)
5. Hepatitis B can be prevented by [a. Vaccination] 535

0.2
    Agree
62 (27%) 60 (20%)
    Disagree
2 (0.9%) 4 (1.3%)
    Neutral
7 (3.0%) 14 (4.6%)
    Strongly Agree
147 (64%) 216 (71%)
    Strongly Disagree
12 (5.2%) 11 (3.6%)
5. Hepatitis B can be prevented by [b. Antivirals] 535

0.088
    Agree
58 (25%) 82 (27%)
    Disagree
49 (21%) 54 (18%)
    Neutral
61 (27%) 75 (25%)
    Strongly Agree
43 (19%) 46 (15%)
    Strongly Disagree
19 (8.3%) 48 (16%)
5. Hepatitis B can be prevented by [c. Avoiding sharp needle/syringe injury] 535

0.009
    Agree
84 (37%) 86 (28%)
    Disagree
16 (7.0%) 18 (5.9%)
    Neutral
23 (10%) 32 (10%)
    Strongly Agree
91 (40%) 161 (53%)
    Strongly Disagree
16 (7.0%) 8 (2.6%)
5. Hepatitis B can be prevented by [d. Avoiding contaminated water/food] 535

0.021
    Agree
45 (20%) 51 (17%)
    Disagree
68 (30%) 67 (22%)
    Neutral
44 (19%) 52 (17%)
    Strongly Agree
36 (16%) 51 (17%)
    Strongly Disagree
37 (16%) 84 (28%)
5. Hepatitis B can be prevented by [e. Using gloves when handling body fluid] 535

0.4
    Agree
89 (39%) 107 (35%)
    Disagree
11 (4.8%) 18 (5.9%)
    Neutral
11 (4.8%) 27 (8.9%)
    Strongly Agree
102 (44%) 135 (44%)
    Strongly Disagree
17 (7.4%) 18 (5.9%)
6. I feel uncomfortable sitting with Hepatitis B infected person. 535

0.071
    Agree
43 (19%) 41 (13%)
    Disagree
79 (34%) 85 (28%)
    Neutral
36 (16%) 71 (23%)
    Strongly agree
22 (9.6%) 35 (11%)
    Strongly disagree
50 (22%) 73 (24%)
7. I don’t mind shaking hands/ hugging with Hepatitis B infected person 535

0.074
    Agree
102 (44%) 120 (39%)
    Disagree
30 (13%) 26 (8.5%)
    Neutral
40 (17%) 51 (17%)
    Strongly Agree
45 (20%) 90 (30%)
    Strongly disagree
13 (5.7%) 18 (5.9%)
8. I believe Hepatitis B vaccine is safe and effective. 535

0.004
    Agree
113 (49%) 113 (37%)
    Disagree
0 (0%) 8 (2.6%)
    Neutral
19 (8.3%) 29 (9.5%)
    Strongly agree
96 (42%) 154 (50%)
    Strongly disagree
2 (0.9%) 1 (0.3%)
9. I believe health care workers should receive Hepatitis B vaccination. 535

0.029
    Agree
66 (29%) 62 (20%)
    Disagree
1 (0.4%) 7 (2.3%)
    Neutral
9 (3.9%) 17 (5.6%)
    Strongly agree
149 (65%) 217 (71%)
    Strongly disagree
5 (2.2%) 2 (0.7%)
10. I don’t need Hepatitis B vaccination because I am not at risk. 535

0.066
    Agree
19 (8.3%) 24 (7.9%)
    Disagree
80 (35%) 101 (33%)
    Neutral
12 (5.2%) 28 (9.2%)
    Strongly Agree
3 (1.3%) 15 (4.9%)
    Strongly disagree
116 (50%) 137 (45%)
11. I’m afraid attending surgical procedure during clinical observation placement if there is a Hepatitis B positive person 535

0.002
    Agree
100 (43%) 83 (27%)
    Disagree
27 (12%) 53 (17%)
    Neutral
39 (17%) 57 (19%)
    Strongly agree
44 (19%) 84 (28%)
    Strongly disagree
20 (8.7%) 28 (9.2%)
12. I ask/use a new blade for shaving/hair cutting. 535

<0.001
    Agree
96 (42%) 67 (22%)
    Disagree
4 (1.7%) 2 (0.7%)
    Neutral
15 (6.5%) 14 (4.6%)
    Strongly Agree
113 (49%) 216 (71%)
    Strongly disagree
2 (0.9%) 6 (2.0%)
13. I ask for a new syringe before injection. 535

0.013
    Agree
68 (30%) 60 (20%)
    Disagree
0 (0%) 6 (2.0%)
    Neutral
6 (2.6%) 12 (3.9%)
    Strongly Agree
155 (67%) 224 (73%)
    Strongly disagree
1 (0.4%) 3 (1.0%)
14. I ask for sterilized equipment for ear/nose piercings. 535

0.031
    Agree
71 (31%) 71 (23%)
    Disagree
2 (0.9%) 1 (0.3%)
    Neutral
10 (4.3%) 27 (8.9%)
    Strongly Agree
147 (64%) 203 (67%)
    Strongly disagree
0 (0%) 3 (1.0%)
15. I always report for needle pricks / sharp injuries. 535

0.15
    Agree
105 (46%) 114 (37%)
    Disagree
8 (3.5%) 9 (3.0%)
    Neutral
35 (15%) 40 (13%)
    Strongly Agree
79 (34%) 138 (45%)
    Strongly Disagree
3 (1.3%) 4 (1.3%)
16. I attend hepatitis B related awareness program 535

0.4
    Agree
86 (37%) 115 (38%)
    Disagree
22 (9.6%) 17 (5.6%)
    Neutral
51 (22%) 63 (21%)
    Strongly Agree
69 (30%) 106 (35%)
    Strongly disagree
2 (0.9%) 4 (1.3%)
17. I always take extra precautions before attending any surgical procedures 535

0.11
    Agree
84 (37%) 92 (30%)
    Disagree
4 (1.7%) 3 (1.0%)
    Neutral
27 (12%) 26 (8.5%)
    Strongly agree
115 (50%) 182 (60%)
    Strongly disagree
0 (0%) 2 (0.7%)
1 n (%)
2 NA; Fisher’s exact test; Pearson’s Chi-squared test

Multivariate Analysis

SLR

m1 <- lm(ttdeath ~ marker, trial)
tbl_regression(m1)
Characteristic Beta 95% CI p-value
Marker Level (ng/mL) 0.51 -0.38, 1.4 0.3
Abbreviation: CI = Confidence Interval

MLR

m2 <- lm(ttdeath ~ age + marker, trial)
tbl_regression(m2)
Characteristic Beta 95% CI p-value
Age -0.02 -0.07, 0.03 0.5
Marker Level (ng/mL) 0.25 -0.64, 1.1 0.6
Abbreviation: CI = Confidence Interval

Logistic Regression

m3 <- glm(death ~ trt +age, trial, family= "binomial")
tbl_regression(m3, exponentiate = TRUE)
Characteristic OR 95% CI p-value
Chemotherapy Treatment


    Drug A — —
    Drug B 1.36 0.76, 2.42 0.3
Age 1.01 0.99, 1.03 0.3
Abbreviations: CI = Confidence Interval, OR = Odds Ratio

Poission Regression

m4 <- glm(death ~ trt +age, trial, family= "poisson")
tbl_regression(m4, exponentiate = TRUE)
Characteristic IRR 95% CI p-value
Chemotherapy Treatment


    Drug A — —
    Drug B 1.15 0.78, 1.70 0.5
Age 1.00 0.99, 1.02 0.5
Abbreviations: CI = Confidence Interval, IRR = Incidence Rate Ratio

Ordinal Regression

library(ordinal)
## 
## Attaching package: 'ordinal'
## The following object is masked from 'package:dplyr':
## 
##     slice
m5 <- clm(grade ~trt +age, data = trial )
tbl_regression(m5, exponentiate = TRUE)
Characteristic OR 95% CI p-value
Chemotherapy Treatment


    Drug A — —
    Drug B 1.12 0.66, 1.89 0.7
Age 1.01 0.99, 1.03 0.4
Abbreviations: CI = Confidence Interval, OR = Odds Ratio

ANOVA

a <- aov(age ~ stage , trial)
summary(a)
##              Df Sum Sq Mean Sq F value Pr(>F)
## stage         3    513   170.9   0.832  0.478
## Residuals   185  37996   205.4               
## 11 observations deleted due to missingness