COD_week9_1_MGK_BTE3207

Minsik Kim

2023-10-23

Before begin..

Let’s load the SBP dataset.

dataset_sbp <- read.csv(file = "/Users/minsikkim/Dropbox (Personal)/Inha/5_Lectures/Advanced biostatistics/scripts/BTE3207_Advanced_Biostatistics/dataset/sbp_dataset_korea_2013-2014.csv")



head(dataset_sbp)
##   SEX BTH_G SBP DBP FBS DIS  BMI
## 1   1     1 116  78  94   4 16.6
## 2   1     1 100  60  79   4 22.3
## 3   1     1 100  60  87   4 21.9
## 4   1     1 111  70  72   4 20.2
## 5   1     1 120  80  98   4 20.0
## 6   1     1 115  79  95   4 23.1

Making function

lm_eqn <- function(m){
    eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(r)^2~"="~r2, 
         list(a = format(unname(coef(m)[1]), digits = 2),
              b = format(unname(coef(m)[2]), digits = 2),
             r2 = format(summary(m)$r.squared, digits = 3)))
    as.character(as.expression(eq));
}

Making a new variable hypertension

dataset_sbp$hypertension <- ifelse(dataset_sbp$SBP > 130 |
                                           dataset_sbp$DBP > 80,
                                   T,
                                   F)

Correlation plot

With a correlation plot, we can see

set.seed(1)
dataset_sbp_small <- subset(dataset_sbp, row.names(dataset_sbp) %in% sample(x = 1:1000000, size = 1000))

ggplot(data = dataset_sbp_small, aes(x = SBP, y = DBP)) +
        geom_point() +
        theme_classic( base_family = "serif", base_size = 20) +
        xlab("SBP (mmHg)") +
        ylab("DBP (mmHg)")

Data with trendline

set.seed(1)
dataset_sbp_small <- subset(dataset_sbp, row.names(dataset_sbp) %in% sample(x = 1:1000000, size = 1000))

ggplot(data = dataset_sbp_small, aes(x = SBP, y = DBP)) +
        geom_point() +
        theme_classic( base_family = "serif", base_size = 20) +
        xlab("SBP (mmHg)") +
        ylab("DBP (mmHg)") + 
        geom_smooth(method = "lm") +
        geom_label(x = 130, y = 115,
                  label = lm_eqn(lm(data = dataset_sbp_small,DBP ~ SBP)),
                  parse = TRUE,
                  family='serif',
                  size = 8, label.size = 0, color = "blue")

#rnorm(100, mean = 100, sd = 1)
set.seed(1)
lm_result <- subset(dataset_sbp, row.names(dataset_sbp) %in% sample(x = 1:1000000, size = 1000)) %>%
        lm(data = .,DBP ~ SBP) #%>% summary

d <- dataset_sbp_small
predict(lm_result)
##        40       860      2079      2833      3328      8101      9101      9690 
##  80.32245  59.43097  69.87671  64.65384  69.87671  75.62187  70.92129  75.09958 
##     10581     10688     11260     13284     13824     15923     18144     19772 
##  75.09958  84.50075  74.57729  69.87671  69.87671  79.27788  69.35442  75.09958 
##     19974     20274     21060     21875     23233     23836     25066     25173 
##  84.50075  64.65384  72.48815  74.05501  76.14416  85.54532  69.87671  81.36702 
##     25393     26593     26946     27075     27219     27248     30302     33622 
##  69.87671  74.05501  76.66644  69.87671  77.18873  72.48815  79.80016  78.23330 
##     35540     39241     39248     40078     40336     43782     47932     49461 
##  77.71102  77.71102  80.32245  64.65384  68.83214  64.65384  72.48815  78.23330 
##     49762     51724     52617     52831     55016     55084     56659     56961 
##  64.65384  75.09958  69.87671  80.32245  84.50075  72.48815  69.87671  75.09958 
##     57635     57719     60016     61140     61565     62913     64250     64509 
##  81.36702  79.80016  84.50075  80.32245  73.01043  69.87671  63.08698  83.45617 
##     64924     65282     66394     67887     68834     69834     70567     70817 
##  75.09958  72.48815  81.36702  80.32245  69.87671  72.48815  80.32245  82.93389 
##     72009     72196     72386     72526     75328     76380     78071     80640 
##  75.62187  69.87671  83.97846  64.65384  72.48815  82.93389  75.09958  78.75559 
##     82735     82879     82963     83733     84804     85725     87081     88307 
##  80.32245  81.88931  67.26528  87.63447  81.88931  80.32245  95.46877  69.87671 
##     89578     90882     92293     92547     94615     95465     97397     99522 
##  76.66644  76.14416  75.09958  80.32245  77.18873  77.71102  74.57729  71.96586 
##    102516    104240    105054    106635    108457    109018    110856    112163 
##  69.87671  69.87671  80.32245  76.14416  59.43097  74.05501  81.36702 101.21393 
##    112229    112587    114104    114237    114677    114959    115757    116048 
##  85.54532  75.09958  69.87671  62.04241  91.29048  72.48815  80.32245  64.65384 
##    116308    116866    117577    118075    119273    119433    119923    122213 
##  90.76819  70.39900  67.26528  92.33505  72.48815  69.87671  80.32245  62.04241 
##    122902    124413    125178    125624    126856    131739    132653    133329 
##  72.48815  81.36702  74.05501  69.35442  68.30985  82.93389  85.02303  80.32245 
##    133402    135329    135948    136466    139537    139768    140281    141442 
##  74.57729  69.87671  76.66644  80.32245  78.75559  85.02303  68.83214  76.66644 
##    141544    141610    142064    143356    143741    145218    146809    147399 
##  76.14416  75.09958  77.71102  75.09958  68.83214  85.54532  82.93389  69.87671 
##    149205    150314    151277    152579    152694    156890    157137    157446 
##  69.87671  69.87671  78.23330  77.71102  86.58989  73.53272  78.23330  75.09958 
##    158141    158326    159350    163988    172429    177686    178253    178772 
##  72.48815  74.05501  80.32245  75.09958  74.05501  83.45617  64.65384  75.09958 
##    180571    181523    182355    182514    183990    184307    185659    186163 
##  68.30985  83.45617  80.32245  80.32245  80.32245  88.67904  75.09958  75.09958 
##    187228    187736    187738    187908    189544    189914    190472    191322 
##  69.87671  80.32245  90.76819  78.23330  75.62187  80.32245  75.62187  78.23330 
##    191420    191844    191941    192620    193198    194287    194985    195019 
##  85.54532  77.71102  75.09958  80.32245  75.09958  74.57729  86.58989  74.05501 
##    195763    197824    198981    199011    199156    199605    199653    199863 
##  83.97846  74.05501  72.48815  77.71102  75.09958  75.09958  75.09958  80.32245 
##    200224    201848    201868    202794    202844    203683    204401    204425 
##  75.09958  80.32245  72.48815  81.88931  83.97846  85.54532  75.09958  73.53272 
##    205424    206423    206793    207199    207722    208237    213241    213648 
##  78.75559  79.27788  69.87671  58.90869  70.92129  84.50075  78.23330  75.09958 
##    217198    217393    218458    219409    220658    222746    222987    224132 
##  80.32245  75.09958  69.87671  85.54532  75.09958 105.91451  75.09958  69.87671 
##    226401    227792    229283    229783    231513    231993    232929    233399 
##  72.48815  69.87671  69.87671  71.96586  90.76819  69.87671  79.27788  81.36702 
##    234512    235319    235324    235733    241097    241492    242126    242920 
##  63.08698  59.95326  75.09958  64.13156  80.32245  77.18873  82.41160  74.57729 
##    243604    244089    244149    244599    244929    245123    245234    245440 
##  74.05501  69.35442  77.18873  72.48815  85.54532  69.87671  68.83214  75.09958 
##    246420    246557    247870    248889    250328    250338    252559    254171 
##  80.32245  75.09958  85.54532  80.32245  74.57729  77.18873  76.14416  80.32245 
##    254807    255652    256005    258348    258672    260423    261630    262277 
##  64.65384  85.54532  69.87671  75.09958  71.44357  69.87671  69.87671  80.32245 
##    266326    266945    267398    269344    270015    270131    270373    270757 
##  80.32245  69.87671  81.36702  68.30985  79.80016  82.41160  82.41160  77.18873 
##    270759    271122    272828    272960    273026    273901    274109    274476 
##  82.93389  75.09958  80.32245  82.93389  69.87671  66.74299  68.30985  75.09958 
##    274741    277769    278363    278929    279780    280277    280296    280684 
##  75.09958  65.17613  80.32245  76.66644  80.84474  68.30985  87.63447  85.54532 
##    281303    282624    283663    284450    284607    284971    287355    287515 
##  83.45617  80.32245  66.22070  80.32245  71.96586  74.05501  72.48815  80.32245 
##    287632    288270    289009    289233    290803    291302    291804    293096 
##  69.87671  64.65384  87.11218  68.83214 101.21393  78.23330  85.54532  75.09958 
##    294271    294762    295295    297664    298069    298470    299805    300562 
##  90.76819  95.99106  76.66644  77.71102  80.32245  88.15675  64.65384  79.27788 
##    302893    306519    307383    307491    307770    309839    310732    311515 
##  80.32245  66.74299  64.65384  84.50075  75.62187  78.23330  75.62187  69.87671 
##    314648    314684    317399    320737    321599    323079    323400    323743 
##  76.14416  66.74299  81.88931  72.48815  67.78756  69.87671  69.87671  80.32245 
##    325425    325683    325772    325875    326028    327801    328614    329647 
##  80.84474  90.76819  92.85734  81.36702  82.41160  78.23330  78.75559  75.09958 
##    329838    330126    330672    332614    335666    335797    337390    339558 
##  64.65384  80.32245  76.66644  77.71102  90.76819  83.97846  69.87671  76.66644 
##    339605    340545    342345    342435    343063    343076    344477    345465 
##  70.39900  67.26528  75.62187  76.66644  81.88931  75.09958  77.18873  80.84474 
##    349071    349464    349667    350290    350967    351987    352453    353032 
##  84.50075  75.09958  69.87671  78.75559  70.39900  68.83214  83.45617  99.64707 
##    353239    353395    353615    353924    354634    355278    355409    355569 
##  71.44357  74.57729  85.02303  76.14416  67.78756  69.87671  85.54532  80.32245 
##    356658    360556    361907    362107    363549    364335    367325    367816 
##  75.09958  80.32245  82.41160  75.62187  84.50075  80.32245  98.08021  85.02303 
##    369216    369951    372024    374357    374376    375337    376616    377259 
##  69.87671  69.87671  71.96586  69.87671  77.71102  75.09958  81.88931  88.15675 
##    379221    379645    380990    383094    383280    383457    384121    385695 
##  73.53272  79.80016  79.27788  85.54532  80.32245  96.51335  76.66644  80.32245 
##    386378    386865    388544    389165    389870    390295    391541    392686 
##  69.87671  78.23330  82.93389  78.23330  68.83214  77.71102  80.32245  66.74299 
##    392907    393433    393860    394589    395500    396918    397529    397853 
##  68.30985  69.87671  67.26528  65.69842  71.44357  76.14416  64.65384  69.35442 
##    398400    398794    399073    399654    400595    402629    404621    405447 
##  80.84474  88.15675  80.32245  69.87671  68.83214  88.67904  83.45617  88.15675 
##    405615    407152    407934    408218    408841    410136    410373    410619 
##  82.41160  74.05501  80.32245  86.06761  80.32245  69.87671  93.90191  77.18873 
##    411619    411736    411950    413666    414539    415102    415342    416409 
##  90.76819  73.53272  85.54532  83.97846  82.41160  75.62187  68.83214  70.92129 
##    416639    418382    419668    419837    421625    421789    423432    423623 
##  74.05501  80.32245  85.54532  64.65384  81.88931  76.14416  75.09958  86.58989 
##    423671    424504    425661    426085    426468    427822    428466    428527 
##  85.54532  80.32245  91.81276  82.93389  74.57729  89.20133  62.56469  75.09958 
##    428648    428662    431183    432180    432249    432433    434349    435668 
##  75.62187  63.08698  75.09958  75.09958  88.15675  74.57729  69.87671  83.97846 
##    436441    436523    436689    437876    438183    438887    439173    439680 
##  80.32245  74.05501  88.15675  89.20133  74.57729  76.66644  72.48815  80.84474 
##    440057    440644    441175    444009    444521    445469    448431    448469 
##  84.50075  82.41160  79.80016  76.66644  65.69842  68.30985  69.87671  75.09958 
##    448893    449499    450108    451002    452346    452426    452582    452737 
##  86.58989  75.09958  75.09958  85.02303  79.27788  82.41160  79.80016  65.69842 
##    452868    454334    454474    454487    455267    455708    455727    456614 
##  77.71102  92.85734  80.84474  83.97846  72.48815  64.65384  75.09958  78.75559 
##    460180    461867    462594    463600    466326    466643    466883    467838 
##  81.88931  63.60927  82.41160  74.05501  77.71102  80.32245  77.71102  80.32245 
##    469264    469451    470475    471355    472262    473588    474796    475895 
##  75.09958  90.76819  91.29048  70.39900  79.80016  84.50075  89.20133  75.09958 
##    478281    478998    480184    481033    483479    483609    485346    486677 
##  72.48815  81.36702  90.76819  80.32245  78.23330  90.76819  74.05501  75.09958 
##    487961    489926    491075    492185    492742    493226    493775    494128 
##  85.54532  69.87671  80.32245  80.32245  75.62187  83.45617  88.15675  69.87671 
##    494295    494643    496651    496664    497731    498713    499006    500558 
##  84.50075  84.50075  83.45617  75.09958  92.33505  80.32245  75.09958  73.01043 
##    501025    503989    504810    505569    509008    512466    512682    513103 
##  74.05501  89.20133  69.87671  80.32245  74.57729  64.65384  72.48815  72.48815 
##    513574    513589    514488    519386    519810    520521    522004    522900 
##  66.22070  70.39900  72.48815  64.65384  75.09958  71.96586  78.75559  80.32245 
##    528151    528646    529389    530505    530807    531419    531848    533078 
##  75.09958  73.53272  63.60927  60.47555  75.09958  69.87671  62.04241  69.87671 
##    533680    535053    535384    536492    538170    538191    539359    540271 
##  64.65384  64.13156  75.09958  75.09958  75.62187  65.17613  59.43097  66.74299 
##    541375    542107    542622    543223    543272    543798    546839    547255 
##  69.87671  67.78756  70.39900  64.13156  60.99783  74.05501  69.87671  75.09958 
##    548676    549099    549536    549593    549658    550296    551009    551704 
##  63.08698  75.09958  69.87671  64.65384  73.01043  74.57729  75.09958  64.65384 
##    551828    552369    552742    553104    553266    553464    553593    554901 
##  72.48815  64.13156  75.09958  66.74299  69.87671  58.38640  74.05501  59.43097 
##    555099    556729    557442    557777    559352    559897    561686    563846 
##  66.22070  74.05501  59.43097  64.65384  62.56469  59.43097  69.87671  69.87671 
##    565265    565896    566239    566501    566946    568578    569687    570474 
##  59.43097  72.48815  59.43097  59.95326  59.43097  80.32245  71.44357  69.87671 
##    571062    571400    573720    574861    575199    575901    578731    580256 
##  59.43097  77.71102  69.87671  75.09958  60.47555  77.18873  74.57729  72.48815 
##    581354    581586    581587    582094    582793    582881    582949    582972 
##  60.99783  69.87671  75.09958  82.93389  75.09958  69.87671  71.44357  68.30985 
##    583207    583412    586086    592097    593242    594078    594148    594650 
##  70.92129  69.87671  67.26528  59.43097  73.01043  64.65384  73.01043  63.60927 
##    596642    597878    599898    600621    601484    603012    603175    604328 
##  59.43097  69.35442  71.96586  64.13156  70.39900  69.87671  69.87671  80.32245 
##    604546    604721    607473    607695    608739    609255    609941    610817 
##  80.32245  81.88931  59.43097  75.09958  73.53272  58.38640  75.62187  74.05501 
##    612648    614892    615010    615179    615610    615852    616487    617022 
##  75.09958  75.62187  74.05501  79.80016  75.09958  77.18873  87.63447  71.96586 
##    617427    620972    621100    621647    622304    623203    623256    623311 
##  77.71102  66.22070  78.75559  64.65384  67.26528  67.26528  90.76819  75.09958 
##    623379    623558    624827    624859    624877    626339    626656    628865 
##  73.53272  72.48815  64.65384  59.43097  64.65384  77.71102  68.83214  75.62187 
##    629021    629118    631951    632230    632936    634164    634243    635424 
##  68.83214  74.05501  75.09958  63.60927  74.57729  69.35442  77.18873  59.43097 
##    637824    638070    639078    639481    639803    640775    640847    641592 
##  69.87671  69.87671  58.90869  79.80016  69.87671  75.09958  71.96586  64.65384 
##    643273    643450    644581    645269    646071    648205    649606    650654 
##  80.32245  65.17613  69.87671  80.32245  80.32245  67.78756  69.87671  79.27788 
##    650724    652092    652456    655260    655325    658742    659693    659971 
##  80.32245  64.65384  72.48815  78.75559  69.87671  69.87671  75.09958  73.01043 
##    660109    660226    660411    660421    662703    663771    664113    664305 
##  69.87671  75.09958  71.96586  80.84474  67.26528  67.78756  77.18873  64.65384 
##    664966    665746    666518    666931    667772    670539    671683    672361 
##  71.96586  59.43097  75.09958  69.87671  78.75559  72.48815  63.08698  64.65384 
##    672394    673002    673666    673958    674243    675793    676909    679048 
##  69.87671  62.56469  64.65384  80.32245  82.93389  66.74299  69.35442  77.18873 
##    680322    680371    681044    681973    683088    684114    684749    685057 
##  64.65384  68.30985  70.39900  80.32245  69.87671  68.30985  75.09958  80.32245 
##    685609    686669    689828    691700    692203    696063    697864    699480 
##  83.97846  74.05501  62.56469  65.69842  73.01043  64.65384  78.23330  76.66644 
##    699713    702796    703226    706682    707304    708495    708858    709002 
##  74.05501  67.26528  67.78756  66.22070  79.80016  82.41160  62.04241  88.67904 
##    709701    712333    712935    713183    716054    716985    717840    719491 
##  79.80016  68.83214  78.75559  80.32245  85.02303  74.57729  75.09958  75.09958 
##    720559    722698    723376    723580    724693    724958    725260    725792 
##  81.36702  81.88931  90.76819  72.48815  70.92129  72.48815  69.87671  64.65384 
##    725920    728157    730279    731592    731595    734836    735226    740534 
##  68.30985  75.09958  75.09958  84.50075  73.01043  75.09958  77.71102  75.09958 
##    741598    742428    744044    744780    746545    748376    749172    749441 
##  59.95326  68.30985  69.87671  75.09958  69.87671  69.87671  82.93389  69.87671 
##    750566    750643    751015    751222    753567    754126    754156    755485 
##  85.54532  84.50075  75.09958  81.36702  75.09958  64.65384  69.87671  85.02303 
##    755825    757027    759436    759978    760319    760604    761472    763059 
##  72.48815  72.48815  81.36702  78.75559  59.43097  65.17613  65.17613  63.60927 
##    763476    765961    766506    767344    772628    774120    774654    777943 
##  67.26528  69.87671  75.09958  67.26528  75.09958  68.83214  80.32245  78.23330 
##    781300    781562    782040    782254    782814    783912    784477    785622 
##  62.04241  75.09958  77.18873  80.32245  69.87671  75.09958  67.26528  90.76819 
##    786175    788672    788744    788995    790192    790718    791022    794408 
##  80.32245  75.09958  85.54532  64.65384  80.32245  80.84474  75.09958  80.32245 
##    795138    795213    796438    796670    797751    798286    798561    799670 
##  74.05501  64.65384  79.80016  85.54532  80.32245  75.09958  74.05501  75.09958 
##    799731    800034    800405    800724    801305    802137    802153    803041 
##  81.36702  80.32245  65.17613  85.54532  69.87671  75.09958  82.93389  69.87671 
##    804058    804340    804633    808510    809119    810882    813308    813849 
##  58.90869  83.45617  67.26528  80.32245  71.44357  80.32245  87.11218  59.43097 
##    814940    815173    817918    818763    819964    820315    820976    822237 
##  69.87671  74.05501  64.65384  76.14416  69.87671  80.32245  72.48815  63.60927 
##    824963    828659    829322    830434    831039    831628    832640    832860 
##  64.65384  70.92129  72.48815  74.57729  74.57729  71.44357  80.32245  75.09958 
##    833417    836037    836154    837550    839249    840317    840355    840921 
##  82.93389  85.54532  75.09958 101.21393  68.30985  75.09958  69.87671  75.09958 
##    841982    843644    844116    845368    847715    847932    849861    852036 
##  69.87671  76.14416  80.32245  75.09958  68.83214  73.53272  85.54532  89.20133 
##    853638    854376    854537    854839    856018    856580    857441    859114 
##  73.01043  67.26528  67.26528  84.50075  80.32245  71.96586  70.39900  75.09958 
##    859726    860373    862116    862239    862809    863397    863568    864269 
##  85.54532  71.96586  75.09958  74.57729  69.87671  82.93389  75.09958  85.02303 
##    865039    866582    868599    868925    870003    870459    871932    872166 
##  77.71102  80.32245  80.32245  82.93389  77.18873  64.65384  60.47555  72.48815 
##    872562    874266    877029    877127    877213    877216    879055    879732 
##  72.48815  82.93389  82.41160  80.32245  80.84474  80.32245  80.84474  80.84474 
##    880609    880969    881323    882730    883492    884079    884667    885774 
##  89.72362  80.32245  82.93389  75.09958  69.87671  75.09958  78.75559  70.92129 
##    885793    886526    888334    888843    889136    889466    889770    892155 
##  76.14416  75.09958  86.06761  85.02303  85.54532  75.09958  68.30985  83.97846 
##    892826    894694    896065    897272    899182    902039    902967    906473 
##  83.97846  90.76819  64.65384  75.09958  90.76819  75.09958  76.14416  85.54532 
##    906533    906966    906982    909396    909813    912068    914565    915189 
##  74.05501  85.54532  76.66644  80.32245  71.96586  72.48815  71.44357  69.87671 
##    917162    917266    920300    921297    922894    923852    924067    926248 
##  74.05501  75.09958  81.36702  75.09958  95.99106  94.42420  77.18873  80.32245 
##    926850    928274    928311    928871    930510    933286    933295    936746 
##  80.32245  85.54532  75.09958  85.02303  80.32245  87.11218  82.41160  79.80016 
##    937226    939175    939346    942957    946191    946436    948266    948433 
##  63.60927  90.76819  82.93389  75.09958  83.97846  80.32245  77.71102  75.09958 
##    948469    948838    950491    952293    953748    955052    955668    956853 
##  80.32245  75.09958  80.32245  90.76819  90.76819  80.32245  71.96586  85.02303 
##    957061    958446    958885    961313    961791    962611    962826    964168 
##  75.09958  85.54532  87.11218  93.90191  69.87671  75.09958  72.48815  88.15675 
##    965524    965818    969045    969197    969856    973171    973696    974688 
##  75.09958  90.76819  78.75559  90.76819  85.54532  85.54532  75.09958  76.14416 
##    974863    977541    977933    978498    979692    980091    980460    980636 
##  64.65384  80.32245  80.32245  90.76819  80.32245  80.32245  80.32245  85.54532 
##    980891    982457    982642    983739    983784    984342    984966    985305 
##  80.32245  78.23330  69.35442  80.32245  84.50075  80.32245  80.84474  75.09958 
##    985851    986356    986466    988197    988235    988886    989279    989803 
##  82.41160  69.87671  75.09958  76.66644  80.32245  95.99106  80.32245  75.09958 
##    990608    991130    991208    991466    993084    993722    994604    999950 
##  85.54532  82.93389  79.27788 101.21393  90.24590  79.27788  80.32245  80.32245
predict(object = lm_result)
##        40       860      2079      2833      3328      8101      9101      9690 
##  80.32245  59.43097  69.87671  64.65384  69.87671  75.62187  70.92129  75.09958 
##     10581     10688     11260     13284     13824     15923     18144     19772 
##  75.09958  84.50075  74.57729  69.87671  69.87671  79.27788  69.35442  75.09958 
##     19974     20274     21060     21875     23233     23836     25066     25173 
##  84.50075  64.65384  72.48815  74.05501  76.14416  85.54532  69.87671  81.36702 
##     25393     26593     26946     27075     27219     27248     30302     33622 
##  69.87671  74.05501  76.66644  69.87671  77.18873  72.48815  79.80016  78.23330 
##     35540     39241     39248     40078     40336     43782     47932     49461 
##  77.71102  77.71102  80.32245  64.65384  68.83214  64.65384  72.48815  78.23330 
##     49762     51724     52617     52831     55016     55084     56659     56961 
##  64.65384  75.09958  69.87671  80.32245  84.50075  72.48815  69.87671  75.09958 
##     57635     57719     60016     61140     61565     62913     64250     64509 
##  81.36702  79.80016  84.50075  80.32245  73.01043  69.87671  63.08698  83.45617 
##     64924     65282     66394     67887     68834     69834     70567     70817 
##  75.09958  72.48815  81.36702  80.32245  69.87671  72.48815  80.32245  82.93389 
##     72009     72196     72386     72526     75328     76380     78071     80640 
##  75.62187  69.87671  83.97846  64.65384  72.48815  82.93389  75.09958  78.75559 
##     82735     82879     82963     83733     84804     85725     87081     88307 
##  80.32245  81.88931  67.26528  87.63447  81.88931  80.32245  95.46877  69.87671 
##     89578     90882     92293     92547     94615     95465     97397     99522 
##  76.66644  76.14416  75.09958  80.32245  77.18873  77.71102  74.57729  71.96586 
##    102516    104240    105054    106635    108457    109018    110856    112163 
##  69.87671  69.87671  80.32245  76.14416  59.43097  74.05501  81.36702 101.21393 
##    112229    112587    114104    114237    114677    114959    115757    116048 
##  85.54532  75.09958  69.87671  62.04241  91.29048  72.48815  80.32245  64.65384 
##    116308    116866    117577    118075    119273    119433    119923    122213 
##  90.76819  70.39900  67.26528  92.33505  72.48815  69.87671  80.32245  62.04241 
##    122902    124413    125178    125624    126856    131739    132653    133329 
##  72.48815  81.36702  74.05501  69.35442  68.30985  82.93389  85.02303  80.32245 
##    133402    135329    135948    136466    139537    139768    140281    141442 
##  74.57729  69.87671  76.66644  80.32245  78.75559  85.02303  68.83214  76.66644 
##    141544    141610    142064    143356    143741    145218    146809    147399 
##  76.14416  75.09958  77.71102  75.09958  68.83214  85.54532  82.93389  69.87671 
##    149205    150314    151277    152579    152694    156890    157137    157446 
##  69.87671  69.87671  78.23330  77.71102  86.58989  73.53272  78.23330  75.09958 
##    158141    158326    159350    163988    172429    177686    178253    178772 
##  72.48815  74.05501  80.32245  75.09958  74.05501  83.45617  64.65384  75.09958 
##    180571    181523    182355    182514    183990    184307    185659    186163 
##  68.30985  83.45617  80.32245  80.32245  80.32245  88.67904  75.09958  75.09958 
##    187228    187736    187738    187908    189544    189914    190472    191322 
##  69.87671  80.32245  90.76819  78.23330  75.62187  80.32245  75.62187  78.23330 
##    191420    191844    191941    192620    193198    194287    194985    195019 
##  85.54532  77.71102  75.09958  80.32245  75.09958  74.57729  86.58989  74.05501 
##    195763    197824    198981    199011    199156    199605    199653    199863 
##  83.97846  74.05501  72.48815  77.71102  75.09958  75.09958  75.09958  80.32245 
##    200224    201848    201868    202794    202844    203683    204401    204425 
##  75.09958  80.32245  72.48815  81.88931  83.97846  85.54532  75.09958  73.53272 
##    205424    206423    206793    207199    207722    208237    213241    213648 
##  78.75559  79.27788  69.87671  58.90869  70.92129  84.50075  78.23330  75.09958 
##    217198    217393    218458    219409    220658    222746    222987    224132 
##  80.32245  75.09958  69.87671  85.54532  75.09958 105.91451  75.09958  69.87671 
##    226401    227792    229283    229783    231513    231993    232929    233399 
##  72.48815  69.87671  69.87671  71.96586  90.76819  69.87671  79.27788  81.36702 
##    234512    235319    235324    235733    241097    241492    242126    242920 
##  63.08698  59.95326  75.09958  64.13156  80.32245  77.18873  82.41160  74.57729 
##    243604    244089    244149    244599    244929    245123    245234    245440 
##  74.05501  69.35442  77.18873  72.48815  85.54532  69.87671  68.83214  75.09958 
##    246420    246557    247870    248889    250328    250338    252559    254171 
##  80.32245  75.09958  85.54532  80.32245  74.57729  77.18873  76.14416  80.32245 
##    254807    255652    256005    258348    258672    260423    261630    262277 
##  64.65384  85.54532  69.87671  75.09958  71.44357  69.87671  69.87671  80.32245 
##    266326    266945    267398    269344    270015    270131    270373    270757 
##  80.32245  69.87671  81.36702  68.30985  79.80016  82.41160  82.41160  77.18873 
##    270759    271122    272828    272960    273026    273901    274109    274476 
##  82.93389  75.09958  80.32245  82.93389  69.87671  66.74299  68.30985  75.09958 
##    274741    277769    278363    278929    279780    280277    280296    280684 
##  75.09958  65.17613  80.32245  76.66644  80.84474  68.30985  87.63447  85.54532 
##    281303    282624    283663    284450    284607    284971    287355    287515 
##  83.45617  80.32245  66.22070  80.32245  71.96586  74.05501  72.48815  80.32245 
##    287632    288270    289009    289233    290803    291302    291804    293096 
##  69.87671  64.65384  87.11218  68.83214 101.21393  78.23330  85.54532  75.09958 
##    294271    294762    295295    297664    298069    298470    299805    300562 
##  90.76819  95.99106  76.66644  77.71102  80.32245  88.15675  64.65384  79.27788 
##    302893    306519    307383    307491    307770    309839    310732    311515 
##  80.32245  66.74299  64.65384  84.50075  75.62187  78.23330  75.62187  69.87671 
##    314648    314684    317399    320737    321599    323079    323400    323743 
##  76.14416  66.74299  81.88931  72.48815  67.78756  69.87671  69.87671  80.32245 
##    325425    325683    325772    325875    326028    327801    328614    329647 
##  80.84474  90.76819  92.85734  81.36702  82.41160  78.23330  78.75559  75.09958 
##    329838    330126    330672    332614    335666    335797    337390    339558 
##  64.65384  80.32245  76.66644  77.71102  90.76819  83.97846  69.87671  76.66644 
##    339605    340545    342345    342435    343063    343076    344477    345465 
##  70.39900  67.26528  75.62187  76.66644  81.88931  75.09958  77.18873  80.84474 
##    349071    349464    349667    350290    350967    351987    352453    353032 
##  84.50075  75.09958  69.87671  78.75559  70.39900  68.83214  83.45617  99.64707 
##    353239    353395    353615    353924    354634    355278    355409    355569 
##  71.44357  74.57729  85.02303  76.14416  67.78756  69.87671  85.54532  80.32245 
##    356658    360556    361907    362107    363549    364335    367325    367816 
##  75.09958  80.32245  82.41160  75.62187  84.50075  80.32245  98.08021  85.02303 
##    369216    369951    372024    374357    374376    375337    376616    377259 
##  69.87671  69.87671  71.96586  69.87671  77.71102  75.09958  81.88931  88.15675 
##    379221    379645    380990    383094    383280    383457    384121    385695 
##  73.53272  79.80016  79.27788  85.54532  80.32245  96.51335  76.66644  80.32245 
##    386378    386865    388544    389165    389870    390295    391541    392686 
##  69.87671  78.23330  82.93389  78.23330  68.83214  77.71102  80.32245  66.74299 
##    392907    393433    393860    394589    395500    396918    397529    397853 
##  68.30985  69.87671  67.26528  65.69842  71.44357  76.14416  64.65384  69.35442 
##    398400    398794    399073    399654    400595    402629    404621    405447 
##  80.84474  88.15675  80.32245  69.87671  68.83214  88.67904  83.45617  88.15675 
##    405615    407152    407934    408218    408841    410136    410373    410619 
##  82.41160  74.05501  80.32245  86.06761  80.32245  69.87671  93.90191  77.18873 
##    411619    411736    411950    413666    414539    415102    415342    416409 
##  90.76819  73.53272  85.54532  83.97846  82.41160  75.62187  68.83214  70.92129 
##    416639    418382    419668    419837    421625    421789    423432    423623 
##  74.05501  80.32245  85.54532  64.65384  81.88931  76.14416  75.09958  86.58989 
##    423671    424504    425661    426085    426468    427822    428466    428527 
##  85.54532  80.32245  91.81276  82.93389  74.57729  89.20133  62.56469  75.09958 
##    428648    428662    431183    432180    432249    432433    434349    435668 
##  75.62187  63.08698  75.09958  75.09958  88.15675  74.57729  69.87671  83.97846 
##    436441    436523    436689    437876    438183    438887    439173    439680 
##  80.32245  74.05501  88.15675  89.20133  74.57729  76.66644  72.48815  80.84474 
##    440057    440644    441175    444009    444521    445469    448431    448469 
##  84.50075  82.41160  79.80016  76.66644  65.69842  68.30985  69.87671  75.09958 
##    448893    449499    450108    451002    452346    452426    452582    452737 
##  86.58989  75.09958  75.09958  85.02303  79.27788  82.41160  79.80016  65.69842 
##    452868    454334    454474    454487    455267    455708    455727    456614 
##  77.71102  92.85734  80.84474  83.97846  72.48815  64.65384  75.09958  78.75559 
##    460180    461867    462594    463600    466326    466643    466883    467838 
##  81.88931  63.60927  82.41160  74.05501  77.71102  80.32245  77.71102  80.32245 
##    469264    469451    470475    471355    472262    473588    474796    475895 
##  75.09958  90.76819  91.29048  70.39900  79.80016  84.50075  89.20133  75.09958 
##    478281    478998    480184    481033    483479    483609    485346    486677 
##  72.48815  81.36702  90.76819  80.32245  78.23330  90.76819  74.05501  75.09958 
##    487961    489926    491075    492185    492742    493226    493775    494128 
##  85.54532  69.87671  80.32245  80.32245  75.62187  83.45617  88.15675  69.87671 
##    494295    494643    496651    496664    497731    498713    499006    500558 
##  84.50075  84.50075  83.45617  75.09958  92.33505  80.32245  75.09958  73.01043 
##    501025    503989    504810    505569    509008    512466    512682    513103 
##  74.05501  89.20133  69.87671  80.32245  74.57729  64.65384  72.48815  72.48815 
##    513574    513589    514488    519386    519810    520521    522004    522900 
##  66.22070  70.39900  72.48815  64.65384  75.09958  71.96586  78.75559  80.32245 
##    528151    528646    529389    530505    530807    531419    531848    533078 
##  75.09958  73.53272  63.60927  60.47555  75.09958  69.87671  62.04241  69.87671 
##    533680    535053    535384    536492    538170    538191    539359    540271 
##  64.65384  64.13156  75.09958  75.09958  75.62187  65.17613  59.43097  66.74299 
##    541375    542107    542622    543223    543272    543798    546839    547255 
##  69.87671  67.78756  70.39900  64.13156  60.99783  74.05501  69.87671  75.09958 
##    548676    549099    549536    549593    549658    550296    551009    551704 
##  63.08698  75.09958  69.87671  64.65384  73.01043  74.57729  75.09958  64.65384 
##    551828    552369    552742    553104    553266    553464    553593    554901 
##  72.48815  64.13156  75.09958  66.74299  69.87671  58.38640  74.05501  59.43097 
##    555099    556729    557442    557777    559352    559897    561686    563846 
##  66.22070  74.05501  59.43097  64.65384  62.56469  59.43097  69.87671  69.87671 
##    565265    565896    566239    566501    566946    568578    569687    570474 
##  59.43097  72.48815  59.43097  59.95326  59.43097  80.32245  71.44357  69.87671 
##    571062    571400    573720    574861    575199    575901    578731    580256 
##  59.43097  77.71102  69.87671  75.09958  60.47555  77.18873  74.57729  72.48815 
##    581354    581586    581587    582094    582793    582881    582949    582972 
##  60.99783  69.87671  75.09958  82.93389  75.09958  69.87671  71.44357  68.30985 
##    583207    583412    586086    592097    593242    594078    594148    594650 
##  70.92129  69.87671  67.26528  59.43097  73.01043  64.65384  73.01043  63.60927 
##    596642    597878    599898    600621    601484    603012    603175    604328 
##  59.43097  69.35442  71.96586  64.13156  70.39900  69.87671  69.87671  80.32245 
##    604546    604721    607473    607695    608739    609255    609941    610817 
##  80.32245  81.88931  59.43097  75.09958  73.53272  58.38640  75.62187  74.05501 
##    612648    614892    615010    615179    615610    615852    616487    617022 
##  75.09958  75.62187  74.05501  79.80016  75.09958  77.18873  87.63447  71.96586 
##    617427    620972    621100    621647    622304    623203    623256    623311 
##  77.71102  66.22070  78.75559  64.65384  67.26528  67.26528  90.76819  75.09958 
##    623379    623558    624827    624859    624877    626339    626656    628865 
##  73.53272  72.48815  64.65384  59.43097  64.65384  77.71102  68.83214  75.62187 
##    629021    629118    631951    632230    632936    634164    634243    635424 
##  68.83214  74.05501  75.09958  63.60927  74.57729  69.35442  77.18873  59.43097 
##    637824    638070    639078    639481    639803    640775    640847    641592 
##  69.87671  69.87671  58.90869  79.80016  69.87671  75.09958  71.96586  64.65384 
##    643273    643450    644581    645269    646071    648205    649606    650654 
##  80.32245  65.17613  69.87671  80.32245  80.32245  67.78756  69.87671  79.27788 
##    650724    652092    652456    655260    655325    658742    659693    659971 
##  80.32245  64.65384  72.48815  78.75559  69.87671  69.87671  75.09958  73.01043 
##    660109    660226    660411    660421    662703    663771    664113    664305 
##  69.87671  75.09958  71.96586  80.84474  67.26528  67.78756  77.18873  64.65384 
##    664966    665746    666518    666931    667772    670539    671683    672361 
##  71.96586  59.43097  75.09958  69.87671  78.75559  72.48815  63.08698  64.65384 
##    672394    673002    673666    673958    674243    675793    676909    679048 
##  69.87671  62.56469  64.65384  80.32245  82.93389  66.74299  69.35442  77.18873 
##    680322    680371    681044    681973    683088    684114    684749    685057 
##  64.65384  68.30985  70.39900  80.32245  69.87671  68.30985  75.09958  80.32245 
##    685609    686669    689828    691700    692203    696063    697864    699480 
##  83.97846  74.05501  62.56469  65.69842  73.01043  64.65384  78.23330  76.66644 
##    699713    702796    703226    706682    707304    708495    708858    709002 
##  74.05501  67.26528  67.78756  66.22070  79.80016  82.41160  62.04241  88.67904 
##    709701    712333    712935    713183    716054    716985    717840    719491 
##  79.80016  68.83214  78.75559  80.32245  85.02303  74.57729  75.09958  75.09958 
##    720559    722698    723376    723580    724693    724958    725260    725792 
##  81.36702  81.88931  90.76819  72.48815  70.92129  72.48815  69.87671  64.65384 
##    725920    728157    730279    731592    731595    734836    735226    740534 
##  68.30985  75.09958  75.09958  84.50075  73.01043  75.09958  77.71102  75.09958 
##    741598    742428    744044    744780    746545    748376    749172    749441 
##  59.95326  68.30985  69.87671  75.09958  69.87671  69.87671  82.93389  69.87671 
##    750566    750643    751015    751222    753567    754126    754156    755485 
##  85.54532  84.50075  75.09958  81.36702  75.09958  64.65384  69.87671  85.02303 
##    755825    757027    759436    759978    760319    760604    761472    763059 
##  72.48815  72.48815  81.36702  78.75559  59.43097  65.17613  65.17613  63.60927 
##    763476    765961    766506    767344    772628    774120    774654    777943 
##  67.26528  69.87671  75.09958  67.26528  75.09958  68.83214  80.32245  78.23330 
##    781300    781562    782040    782254    782814    783912    784477    785622 
##  62.04241  75.09958  77.18873  80.32245  69.87671  75.09958  67.26528  90.76819 
##    786175    788672    788744    788995    790192    790718    791022    794408 
##  80.32245  75.09958  85.54532  64.65384  80.32245  80.84474  75.09958  80.32245 
##    795138    795213    796438    796670    797751    798286    798561    799670 
##  74.05501  64.65384  79.80016  85.54532  80.32245  75.09958  74.05501  75.09958 
##    799731    800034    800405    800724    801305    802137    802153    803041 
##  81.36702  80.32245  65.17613  85.54532  69.87671  75.09958  82.93389  69.87671 
##    804058    804340    804633    808510    809119    810882    813308    813849 
##  58.90869  83.45617  67.26528  80.32245  71.44357  80.32245  87.11218  59.43097 
##    814940    815173    817918    818763    819964    820315    820976    822237 
##  69.87671  74.05501  64.65384  76.14416  69.87671  80.32245  72.48815  63.60927 
##    824963    828659    829322    830434    831039    831628    832640    832860 
##  64.65384  70.92129  72.48815  74.57729  74.57729  71.44357  80.32245  75.09958 
##    833417    836037    836154    837550    839249    840317    840355    840921 
##  82.93389  85.54532  75.09958 101.21393  68.30985  75.09958  69.87671  75.09958 
##    841982    843644    844116    845368    847715    847932    849861    852036 
##  69.87671  76.14416  80.32245  75.09958  68.83214  73.53272  85.54532  89.20133 
##    853638    854376    854537    854839    856018    856580    857441    859114 
##  73.01043  67.26528  67.26528  84.50075  80.32245  71.96586  70.39900  75.09958 
##    859726    860373    862116    862239    862809    863397    863568    864269 
##  85.54532  71.96586  75.09958  74.57729  69.87671  82.93389  75.09958  85.02303 
##    865039    866582    868599    868925    870003    870459    871932    872166 
##  77.71102  80.32245  80.32245  82.93389  77.18873  64.65384  60.47555  72.48815 
##    872562    874266    877029    877127    877213    877216    879055    879732 
##  72.48815  82.93389  82.41160  80.32245  80.84474  80.32245  80.84474  80.84474 
##    880609    880969    881323    882730    883492    884079    884667    885774 
##  89.72362  80.32245  82.93389  75.09958  69.87671  75.09958  78.75559  70.92129 
##    885793    886526    888334    888843    889136    889466    889770    892155 
##  76.14416  75.09958  86.06761  85.02303  85.54532  75.09958  68.30985  83.97846 
##    892826    894694    896065    897272    899182    902039    902967    906473 
##  83.97846  90.76819  64.65384  75.09958  90.76819  75.09958  76.14416  85.54532 
##    906533    906966    906982    909396    909813    912068    914565    915189 
##  74.05501  85.54532  76.66644  80.32245  71.96586  72.48815  71.44357  69.87671 
##    917162    917266    920300    921297    922894    923852    924067    926248 
##  74.05501  75.09958  81.36702  75.09958  95.99106  94.42420  77.18873  80.32245 
##    926850    928274    928311    928871    930510    933286    933295    936746 
##  80.32245  85.54532  75.09958  85.02303  80.32245  87.11218  82.41160  79.80016 
##    937226    939175    939346    942957    946191    946436    948266    948433 
##  63.60927  90.76819  82.93389  75.09958  83.97846  80.32245  77.71102  75.09958 
##    948469    948838    950491    952293    953748    955052    955668    956853 
##  80.32245  75.09958  80.32245  90.76819  90.76819  80.32245  71.96586  85.02303 
##    957061    958446    958885    961313    961791    962611    962826    964168 
##  75.09958  85.54532  87.11218  93.90191  69.87671  75.09958  72.48815  88.15675 
##    965524    965818    969045    969197    969856    973171    973696    974688 
##  75.09958  90.76819  78.75559  90.76819  85.54532  85.54532  75.09958  76.14416 
##    974863    977541    977933    978498    979692    980091    980460    980636 
##  64.65384  80.32245  80.32245  90.76819  80.32245  80.32245  80.32245  85.54532 
##    980891    982457    982642    983739    983784    984342    984966    985305 
##  80.32245  78.23330  69.35442  80.32245  84.50075  80.32245  80.84474  75.09958 
##    985851    986356    986466    988197    988235    988886    989279    989803 
##  82.41160  69.87671  75.09958  76.66644  80.32245  95.99106  80.32245  75.09958 
##    990608    991130    991208    991466    993084    993722    994604    999950 
##  85.54532  82.93389  79.27788 101.21393  90.24590  79.27788  80.32245  80.32245
d$predicted <- lm_result$fitted.values
d$residuals <- residuals(lm_result)

library(ggplot2)
ggplot(d, aes(x = SBP, y = DBP)) +
        geom_smooth(method = "lm", se = FALSE, color = "blue") +  # Plot regression slope
        geom_segment(aes(xend = SBP, yend = predicted), alpha = .2) +  # alpha to fade lines
        geom_point() +
        theme_classic( base_family = "serif", base_size = 20) +
        geom_label(x = 130, y = 115,
                  label = lm_eqn(lm(data = dataset_sbp_small,DBP ~ SBP)),
                  parse = TRUE,
                  family='serif',
                  size = 8, label.size = 0, color = "blue")

Data with binary variable

ggplot(data = dataset_sbp_small, aes(x = as.factor(SEX), y = SBP)) +
        geom_boxplot() +
        theme_classic(base_size = 20, base_family = "serif") +
        scale_x_discrete(breaks=c("1", "2"),
                         labels=c("Male", "Female")) + 
        xlab("Gender") +
        ylab("SBP (mmHg)")

ggplot(data = dataset_sbp_small, aes(x = as.factor(SEX), y = SBP)) +
        geom_point() +
        theme_classic( base_family = "serif", base_size = 20) +
        scale_x_discrete(breaks=c("1", "2"),
                         labels=c("Male", "Female")) + 
        xlab("Gender") +
        ylab("SBP (mmHg)") + 
        geom_smooth(method = "lm")

dataset_sbp_small <- dataset_sbp_small %>% 
        mutate(Gender = ifelse(dataset_sbp_small$SEX == 1, 0, 1)) 




dataset_sbp_small %>%
        ggplot(aes(x = Gender, y = SBP)) +
        geom_point() +
                #scale_x_discrete(breaks=c("1", "2"),
                #                 labels=c("Male", "Female")) + 
        xlab("Gender (0 = Male, 1 = Female)") +
        ylab("SBP (mmHg)") + 
        geom_smooth(method = "lm") +
        geom_label(x = 0.5, y = 140,
                  label = lm_eqn(lm(data = dataset_sbp_small, SBP ~ Gender)),
                  parse = TRUE,
                  family='serif',
                  size = 8, label.size = 0, color = "blue") + 
        theme_classic(base_family = "serif", base_size = 20)

        #theme(text = element_blank())
        #stat_poly_eq(use_label(c("eq", "R2"))) +
lm(data = dataset_sbp_small, SBP ~ Gender) %>% summary
## 
## Call:
## lm(formula = SBP ~ Gender, data = dataset_sbp_small)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -34.779  -8.779   0.221  10.221  55.221 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 123.7795     0.6365  194.46  < 2e-16 ***
## Gender       -5.0921     0.9159   -5.56 3.47e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.47 on 998 degrees of freedom
## Multiple R-squared:  0.03004,    Adjusted R-squared:  0.02907 
## F-statistic: 30.91 on 1 and 998 DF,  p-value: 3.47e-08
t.test(SBP ~ Gender, data = dataset_sbp_small, paired = F, var.equal = F) # Extract the confidence interval 
## 
##  Welch Two Sample t-test
## 
## data:  SBP by Gender
## t = 5.5455, df = 978.21, p-value = 3.77e-08
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  3.290184 6.894069
## sample estimates:
## mean in group 0 mean in group 1 
##        123.7795        118.6874
t.test(SBP ~ Gender, data = dataset_sbp_small, paired = F, var.equal = F)$est[1] - t.test(SBP ~ Gender, data = dataset_sbp_small, paired = F, var.equal = F)$est[2]
## mean in group 0 
##        5.092126

Data with categorical variable

ggplot(data = dataset_sbp_small, aes(x = as.factor(DIS), y = SBP)) +
        geom_boxplot() +
        theme_classic( base_family = "serif", base_size = 20) +
        xlab("Hypertension and diabete history") +
        ylab("SBP (mmHg)") 

lm(SBP ~ as.factor(DIS), data = dataset_sbp_small) %>% summary
## 
## Call:
## lm(formula = SBP ~ as.factor(DIS), data = dataset_sbp_small)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -32.708  -8.187  -0.187   9.813  51.813 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      133.089      1.824  72.957  < 2e-16 ***
## as.factor(DIS)2   -2.381      2.106  -1.130 0.258607    
## as.factor(DIS)3   -9.910      2.847  -3.481 0.000522 ***
## as.factor(DIS)4  -14.902      1.892  -7.875 8.85e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.65 on 996 degrees of freedom
## Multiple R-squared:  0.1389, Adjusted R-squared:  0.1363 
## F-statistic: 53.54 on 3 and 996 DF,  p-value: < 2.2e-16

Bibliography

## Computing. R Foundation for Statistical Computing, Vienna, Austria. <https://www.R-project.org/>. We have invested a lot of time and effort in creating R, please cite it when using it for data analysis. See also 'citation("pkgname")' for citing R packages.
## Grolemund G, Hayes A, Henry L, Hester J, Kuhn M, Pedersen TL, Miller E, Bache SM, Müller K, Ooms J, Robinson D, Seidel DP, Spinu V, Takahashi K, Vaughan D, Wilke C, Woo K, Yutani H (2019). "Welcome to the tidyverse." Journal of Open Source Software_, *4*(43), 1686. doi:10.21105/joss.01686 <https://doi.org/10.21105/joss.01686>.
## R. version 0.5.0. Buffalo, New York. http://github.com/trinker/pacman
## J, reikoch, Beasley W, O'Connor B, Warnes GR, Quinn M, Kamvar ZN (2023). yaml: Methods to Convert R Data to YAML and Back_. R package version 2.3.7, <https://CRAN.R-project.org/package=yaml>. ATTENTION: This citation information has been auto-generated from the package DESCRIPTION file and may need manual editing, see 'help("citation")'.
## Generation in R. R package version 1.44, <https://yihui.org/knitr/>. Yihui Xie (2015) Dynamic Documents with R and knitr. 2nd edition. Chapman and Hall/CRC. ISBN 978-1498716963 Yihui Xie (2014) knitr: A Comprehensive Tool for Reproducible Research in R. In Victoria Stodden, Friedrich Leisch and Roger D. Peng, editors, Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN 978-1466561595