Data Source: Mater Dive Port 7

Load library package

## [1] "C:/Users/User/Documents/RStudio/SpineDivePort_PatientsDetail"
## [1] "C:/Users/User/Documents/RStudio/SpineDivePort_PatientsDetail"
## Warning: package 'stringr' was built under R version 4.3.2
## Warning: package 'readr' was built under R version 4.3.2
## Warning: package 'tidyverse' was built under R version 4.3.2
## Warning: package 'ggplot2' was built under R version 4.3.2
## Warning: package 'tibble' was built under R version 4.3.2
## Warning: package 'tidyr' was built under R version 4.3.2
## Warning: package 'purrr' was built under R version 4.3.2
## Warning: package 'dplyr' was built under R version 4.3.2
## Warning: package 'forcats' was built under R version 4.3.2
## Warning: package 'lubridate' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ purrr     1.0.2
## ✔ forcats   1.0.0     ✔ tibble    3.2.1
## ✔ ggplot2   3.4.4     ✔ tidyr     1.3.0
## ✔ lubridate 1.9.3     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Warning: package 'ggthemes' was built under R version 4.3.2
## Warning: package 'qcc' was built under R version 4.3.2
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
## Warning: package 'qicharts' was built under R version 4.3.2
## qicharts will no longer be maintained. Please consider moving to qicharts2: https://anhoej.github.io/qicharts2/.
## Warning: package 'sqldf' was built under R version 4.3.2
## Loading required package: gsubfn
## Warning: package 'gsubfn' was built under R version 4.3.2
## Loading required package: proto
## Warning: package 'proto' was built under R version 4.3.2
## Loading required package: RSQLite
## Warning: package 'RSQLite' was built under R version 4.3.2
## Warning: package 'gridExtra' was built under R version 4.3.2
## 
## Attaching package: 'gridExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
## Warning: package 'Hmisc' was built under R version 4.3.2
## 
## Attaching package: 'Hmisc'
## 
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## 
## The following objects are masked from 'package:base':
## 
##     format.pval, units
## Warning: package 'psych' was built under R version 4.3.2
## 
## Attaching package: 'psych'
## 
## The following object is masked from 'package:Hmisc':
## 
##     describe
## 
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## Warning: package 'plyr' was built under R version 4.3.2
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
## 
## Attaching package: 'plyr'
## 
## The following objects are masked from 'package:Hmisc':
## 
##     is.discrete, summarize
## 
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## 
## The following object is masked from 'package:purrr':
## 
##     compact
## Warning: package 'pastecs' was built under R version 4.3.2
## 
## Attaching package: 'pastecs'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
## Warning: package 'semTools' was built under R version 4.3.2
## Loading required package: lavaan
## Warning: package 'lavaan' was built under R version 4.3.2
## This is lavaan 0.6-17
## lavaan is FREE software! Please report any bugs.
## 
## Attaching package: 'lavaan'
## 
## The following object is masked from 'package:psych':
## 
##     cor2cov
## 
##  
## ###############################################################################
## This is semTools 0.5-6
## All users of R (or SEM) are invited to submit functions or ideas for functions.
## ###############################################################################
## 
## Attaching package: 'semTools'
## 
## The following object is masked from 'package:moments':
## 
##     kurtosis
## 
## The following objects are masked from 'package:psych':
## 
##     reliability, skew
## 
## The following object is masked from 'package:readr':
## 
##     clipboard
## Warning: package 'car' was built under R version 4.3.2
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.3.2
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:psych':
## 
##     logit
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## The following object is masked from 'package:purrr':
## 
##     some
## Warning: package 'PerformanceAnalytics' was built under R version 4.3.2
## Loading required package: xts
## Warning: package 'xts' was built under R version 4.3.2
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.3.2
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## 
## ######################### Warning from 'xts' package ##########################
## #                                                                             #
## # The dplyr lag() function breaks how base R's lag() function is supposed to  #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or       #
## # source() into this session won't work correctly.                            #
## #                                                                             #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop           #
## # dplyr from breaking base R's lag() function.                                #
## #                                                                             #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning.  #
## #                                                                             #
## ###############################################################################
## 
## Attaching package: 'xts'
## 
## The following objects are masked from 'package:pastecs':
## 
##     first, last
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## 
## Attaching package: 'PerformanceAnalytics'
## 
## The following object is masked from 'package:semTools':
## 
##     kurtosis
## 
## The following objects are masked from 'package:moments':
## 
##     kurtosis, skewness
## 
## The following object is masked from 'package:graphics':
## 
##     legend
## Warning: package 'caret' was built under R version 4.3.2
## Loading required package: lattice
## 
## Attaching package: 'caret'
## 
## The following object is masked from 'package:purrr':
## 
##     lift
## Warning: package 'rcompanion' was built under R version 4.3.2
## 
## Attaching package: 'rcompanion'
## 
## The following object is masked from 'package:psych':
## 
##     phi
## Warning: package 'regclass' was built under R version 4.3.2
## Loading required package: bestglm
## Warning: package 'bestglm' was built under R version 4.3.2
## Loading required package: leaps
## Warning: package 'leaps' was built under R version 4.3.2
## Loading required package: VGAM
## Warning: package 'VGAM' was built under R version 4.3.2
## Loading required package: stats4
## Loading required package: splines
## 
## Attaching package: 'VGAM'
## 
## The following object is masked from 'package:caret':
## 
##     predictors
## 
## The following object is masked from 'package:car':
## 
##     logit
## 
## The following objects are masked from 'package:psych':
## 
##     fisherz, logistic, logit
## 
## Loading required package: rpart
## Warning: package 'rpart' was built under R version 4.3.2
## Loading required package: randomForest
## Warning: package 'randomForest' was built under R version 4.3.2
## randomForest 4.7-1.1
## Type rfNews() to see new features/changes/bug fixes.
## 
## Attaching package: 'randomForest'
## 
## The following object is masked from 'package:psych':
## 
##     outlier
## 
## The following object is masked from 'package:gridExtra':
## 
##     combine
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
## 
## The following object is masked from 'package:ggplot2':
## 
##     margin
## 
## Important regclass change from 1.3:
## All functions that had a . in the name now have an _
## all.correlations -> all_correlations, cor.demo -> cor_demo, etc.
## 
## 
## Attaching package: 'regclass'
## 
## The following object is masked from 'package:lattice':
## 
##     qq
## Warning: package 'AppliedPredictiveModeling' was built under R version 4.3.2
## Warning: package 'rpart.plot' was built under R version 4.3.2
## Warning: package 'pROC' was built under R version 4.3.2
## Type 'citation("pROC")' for a citation.
## 
## Attaching package: 'pROC'
## 
## The following objects are masked from 'package:stats':
## 
##     cov, smooth, var
## Warning: package 'gmodels' was built under R version 4.3.2
## Registered S3 method overwritten by 'gdata':
##   method         from     
##   reorder.factor DescTools
## 
## Attaching package: 'gmodels'
## 
## The following object is masked from 'package:pROC':
## 
##     ci
## Warning: package 'epiDisplay' was built under R version 4.3.2
## Loading required package: foreign
## Loading required package: survival
## 
## Attaching package: 'survival'
## 
## The following object is masked from 'package:caret':
## 
##     cluster
## 
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## 
## The following object is masked from 'package:dplyr':
## 
##     select
## 
## Loading required package: nnet
## 
## Attaching package: 'epiDisplay'
## 
## The following object is masked from 'package:gmodels':
## 
##     ci
## 
## The following object is masked from 'package:pROC':
## 
##     ci
## 
## The following object is masked from 'package:VGAM':
## 
##     lrtest
## 
## The following object is masked from 'package:lattice':
## 
##     dotplot
## 
## The following objects are masked from 'package:psych':
## 
##     alpha, cs, lookup
## 
## The following object is masked from 'package:ggplot2':
## 
##     alpha
## Warning: package 'survey' was built under R version 4.3.2
## Loading required package: grid
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.3.2
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## 
## Attaching package: 'survey'
## 
## The following object is masked from 'package:VGAM':
## 
##     calibrate
## 
## The following object is masked from 'package:Hmisc':
## 
##     deff
## 
## The following object is masked from 'package:graphics':
## 
##     dotchart
## Warning: package 'rattle' was built under R version 4.3.2
## Loading required package: bitops
## 
## Attaching package: 'bitops'
## 
## The following object is masked from 'package:Matrix':
## 
##     %&%
## 
## Rattle: A free graphical interface for data science with R.
## Version 5.5.1 Copyright (c) 2006-2021 Togaware Pty Ltd.
## Type 'rattle()' to shake, rattle, and roll your data.
## 
## Attaching package: 'rattle'
## 
## The following object is masked from 'package:randomForest':
## 
##     importance
## 
## The following object is masked from 'package:VGAM':
## 
##     wine

Load file & some variables values

main <- read.csv("SpinePatientsDetail.csv")
main <- subset(main, Attendance.Year < 2024)

## View variable types
main %>% glimpse() #glimpse from library(dplyr)
## Rows: 82,543
## Columns: 45
## $ Record.Type                  <chr> "Attendance", "Attendance", "Attendance",…
## $ Clinic.Code                  <int> 1038, 1229, 1229, 1229, 1229, 1059, 726, …
## $ Clinic.Type                  <chr> "GEN : GENERAL", "GEN : GENERAL", "GEN : …
## $ NurseFlag                    <chr> "N", "N", "N", "N", "N", "Y", "N", "N", "…
## $ Medical.Record.Number        <int> 118, 118, 118, 118, 118, 367, 532, 532, 5…
## $ Gender                       <chr> "Female", "Female", "Female", "Female", "…
## $ Patient.Name                 <chr> "ST LEGER KATHLEEN", "ST LEGER KATHLEEN",…
## $ Attendance.Day               <chr> "Friday", "Tuesday", "Tuesday", "Tuesday"…
## $ Attendance.MonthYear         <chr> "May-23", "May-23", "May-23", "May-23", "…
## $ Attendance.Date              <chr> "12/05/2023", "16/05/2023", "23/05/2023",…
## $ Attendance.Type.Description  <chr> "RETURN", "RETURN", "RETURN", "RETURN", "…
## $ Referral.Source              <chr> "A : EMERGENCY DEPT", "A : EMERGENCY DEPT…
## $ Clinical.Specialty.Group     <chr> "Surgery", "Surgery", "Surgery", "Surgery…
## $ Specialty.Description.Mater  <chr> "Orthopaedics", "Orthopaedics", "Orthopae…
## $ Consultant                   <chr> "MOROP : MORONEY MR. PAUL", "COLGAN : COL…
## $ Insurance.Scheme             <chr> "D : MEDICAL CARD HOLDER", "D : MEDICAL C…
## $ Eligibility                  <chr> "01 : CAT 1 (MEDICAL CARD)", "01 : CAT 1 …
## $ Age.at.Attendance            <int> 78, 78, 78, 78, 78, 77, 67, 67, 67, 67, 6…
## $ Referring.Hospital           <chr> ":", ":", ":", ":", ":", ":", ":", ":", "…
## $ Area.of.Residence            <chr> "0111 : DUBLIN 11", "0111 : DUBLIN 11", "…
## $ Attendance.Year              <int> 2023, 2023, 2023, 2023, 2023, 2021, 2021,…
## $ Attendance.Month             <chr> "May", "May", "May", "May", "June", "Apri…
## $ Age.at.Attendance.Cat.HSE    <chr> "75 - 84", "75 - 84", "75 - 84", "75 - 84…
## $ Pathway.Number               <int> 57091024, 57094901, 57094901, 57094901, 5…
## $ Present.Address              <chr> "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11", …
## $ Home.Address                 <chr> "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11", …
## $ Home.Phone.No                <chr> "8345436", "8345436", "8345436", "8345436…
## $ Mobile.Phone.No              <chr> "", "", "", "", "", "086 0578834", "086 8…
## $ Appointment.Date...Time      <chr> "", "", "", "", "", "", "20210108 11:00:0…
## $ X                            <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ Booking.Type                 <chr> "C : New  Virtual Phone", "R : RETURN", "…
## $ Booked.Date                  <chr> "11/05/2023", "12/05/2023", "16/05/2023",…
## $ Booked.Time                  <chr> "13:27:00", "17:47:00", "12:35:00", "08:4…
## $ Cancelled.Indicator          <chr> "", "", "", "", "", "", "Rescheduled Appt…
## $ Cancellation.Group           <chr> "N/A", "N/A", "N/A", "N/A", "N/A", "N/A",…
## $ Reason.For.Cancellation      <chr> "", "", "", "", "", "", "COH : Covid 19 O…
## $ Reason.for.Cancellation.Desc <chr> "", "", "", "", "", "", "Covid 19 Outbrea…
## $ Reason.for.Cancel.Text       <chr> "", "", "", "", "", "", "", "as per mr mo…
## $ Rebooked.Indicator..HIS.     <chr> "", "", "", "", "", "", "Yes", "Yes", "No…
## $ Hospital.Catchment           <chr> "Mater Catchment", "Mater Catchment", "Ma…
## $ No.Attendances               <int> 1, 1, 1, 1, 1, 1, NA, NA, NA, 1, NA, 1, 1…
## $ No.New.Attendances           <int> 0, 0, 0, 0, 0, 1, NA, NA, NA, 0, NA, 0, 0…
## $ No.Return.Attendances        <int> 1, 1, 1, 1, 1, 0, NA, NA, NA, 1, NA, 1, 1…
## $ No.DNAs                      <int> NA, NA, NA, NA, NA, NA, 0, 0, 1, NA, 1, N…
## $ No.Cancels                   <int> NA, NA, NA, NA, NA, NA, 1, 1, 0, NA, 0, N…
head(main)
##   Record.Type Clinic.Code                  Clinic.Type NurseFlag
## 1  Attendance        1038                GEN : GENERAL         N
## 2  Attendance        1229                GEN : GENERAL         N
## 3  Attendance        1229                GEN : GENERAL         N
## 4  Attendance        1229                GEN : GENERAL         N
## 5  Attendance        1229                GEN : GENERAL         N
## 6  Attendance        1059 MSK : MUSCULOSKELETAL CLINIC         Y
##   Medical.Record.Number Gender      Patient.Name Attendance.Day
## 1                   118 Female ST LEGER KATHLEEN         Friday
## 2                   118 Female ST LEGER KATHLEEN        Tuesday
## 3                   118 Female ST LEGER KATHLEEN        Tuesday
## 4                   118 Female ST LEGER KATHLEEN        Tuesday
## 5                   118 Female ST LEGER KATHLEEN        Tuesday
## 6                   367   Male     SCULLY GERARD       Thursday
##   Attendance.MonthYear Attendance.Date Attendance.Type.Description
## 1               May-23      12/05/2023                      RETURN
## 2               May-23      16/05/2023                      RETURN
## 3               May-23      23/05/2023                      RETURN
## 4               May-23      30/05/2023                      RETURN
## 5               Jun-23      20/06/2023                      RETURN
## 6               Apr-21      08/04/2021                         NEW
##      Referral.Source Clinical.Specialty.Group Specialty.Description.Mater
## 1 A : EMERGENCY DEPT                  Surgery                Orthopaedics
## 2 A : EMERGENCY DEPT                  Surgery                Orthopaedics
## 3         C : CLINIC                  Surgery                Orthopaedics
## 4         C : CLINIC                  Surgery                Orthopaedics
## 5         C : CLINIC                  Surgery                Orthopaedics
## 6             G : GP                  Surgery                Orthopaedics
##                    Consultant        Insurance.Scheme               Eligibility
## 1    MOROP : MORONEY MR. PAUL D : MEDICAL CARD HOLDER 01 : CAT 1 (MEDICAL CARD)
## 2 COLGAN : COLGAN MS. GRAINNE D : MEDICAL CARD HOLDER 01 : CAT 1 (MEDICAL CARD)
## 3 COLGAN : COLGAN MS. GRAINNE D : MEDICAL CARD HOLDER 01 : CAT 1 (MEDICAL CARD)
## 4 COLGAN : COLGAN MS. GRAINNE D : MEDICAL CARD HOLDER 01 : CAT 1 (MEDICAL CARD)
## 5 COLGAN : COLGAN MS. GRAINNE D : MEDICAL CARD HOLDER 01 : CAT 1 (MEDICAL CARD)
## 6  SYNNOT : SYNNOTT MR. KEITH D : MEDICAL CARD HOLDER 01 : CAT 1 (MEDICAL CARD)
##   Age.at.Attendance Referring.Hospital Area.of.Residence Attendance.Year
## 1                78                  :  0111 : DUBLIN 11            2023
## 2                78                  :  0111 : DUBLIN 11            2023
## 3                78                  :  0111 : DUBLIN 11            2023
## 4                78                  :  0111 : DUBLIN 11            2023
## 5                78                  :  0111 : DUBLIN 11            2023
## 6                77                  :   0107 : DUBLIN 7            2021
##   Attendance.Month Age.at.Attendance.Cat.HSE Pathway.Number
## 1              May                   75 - 84       57091024
## 2              May                   75 - 84       57094901
## 3              May                   75 - 84       57094901
## 4              May                   75 - 84       57094901
## 5             June                   75 - 84       57094901
## 6            April                   75 - 84       56113762
##                            Present.Address
## 1    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 2    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 3    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 4    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 5    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 6 599 CARNLOUGH ROAD, CABRA WEST, DUBLIN 7
##                               Home.Address Home.Phone.No Mobile.Phone.No
## 1    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11       8345436                
## 2    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11       8345436                
## 3    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11       8345436                
## 4    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11       8345436                
## 5    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11       8345436                
## 6 599 CARNLOUGH ROAD, CABRA WEST, DUBLIN 7   NO LANDLINE     086 0578834
##   Appointment.Date...Time  X           Booking.Type Booked.Date Booked.Time
## 1                         NA C : New  Virtual Phone  11/05/2023    13:27:00
## 2                         NA             R : RETURN  12/05/2023    17:47:00
## 3                         NA             R : RETURN  16/05/2023    12:35:00
## 4                         NA             R : RETURN  24/05/2023    08:41:00
## 5                         NA             R : RETURN  30/05/2023    09:35:00
## 6                         NA                N : NEW  19/03/2021    08:51:00
##   Cancelled.Indicator Cancellation.Group Reason.For.Cancellation
## 1                                    N/A                        
## 2                                    N/A                        
## 3                                    N/A                        
## 4                                    N/A                        
## 5                                    N/A                        
## 6                                    N/A                        
##   Reason.for.Cancellation.Desc Reason.for.Cancel.Text Rebooked.Indicator..HIS.
## 1                                                                             
## 2                                                                             
## 3                                                                             
## 4                                                                             
## 5                                                                             
## 6                                                                             
##   Hospital.Catchment No.Attendances No.New.Attendances No.Return.Attendances
## 1    Mater Catchment              1                  0                     1
## 2    Mater Catchment              1                  0                     1
## 3    Mater Catchment              1                  0                     1
## 4    Mater Catchment              1                  0                     1
## 5    Mater Catchment              1                  0                     1
## 6    Mater Catchment              1                  1                     0
##   No.DNAs No.Cancels
## 1      NA         NA
## 2      NA         NA
## 3      NA         NA
## 4      NA         NA
## 5      NA         NA
## 6      NA         NA
#sample <- main %>% group_by(main$Record.Type)
#samplePatients <- sample_frac(main,0.1,replace = F)

## Remove NAs or impute NAs if necessary
allMissing = is.na(main)
counts = colSums(allMissing)
counts [counts>0]
##                      X Reason.for.Cancel.Text         No.Attendances 
##                  82543                      1                  25896 
##     No.New.Attendances  No.Return.Attendances                No.DNAs 
##                  25896                  25896                  56647 
##             No.Cancels 
##                  56647
# main <- na.omit(main)

print(is.data.frame(main))
## [1] TRUE
## Variables description
unique(main$Record.Type)
## [1] "Attendance"   "Cancellation" "DNA"
unique(main$Clinic.Type)
##  [1] "GEN : GENERAL"                       "MSK : MUSCULOSKELETAL CLINIC"       
##  [3] "POD : PODIATRY"                      "SPN : SPINAL CLINIC"                
##  [5] "ULC : UPPER LIMB CLINIC"             "PLS : NTPF ORTHO CLINIC"            
##  [7] "COM : BALLYMUN COMMUNITY MSK TRIAGE" "SCO : SCOLIOSIS CLINIC"             
##  [9] "COS : SUMMERHILL MSK TRIAGE CLINICS" "ABC : ACUTE BACK PAIN CLINIC"       
## [11] "JIC : JOINT INJECTION CLINIC"        "LBP : LOW BACK PAIN PATHWAY"        
## [13] "MSN : MSK NTPF TRIAGE CLINIC"        "BPL : BRACHIAL PLEXUS CLINIC"       
## [15] "CGP : COMBINED GP CLINIC"            "BPP : BACK PAIN PILOT CLINIC"       
## [17] "FED : FRACTURE ED"
unique(main$Clinic.Code)
##  [1] 1038 1229 1059  726 1095  806 1341 1371  444 1206 1207 1197 1282 1283  849
## [16]  416  786  211 1369  846  847  778 1195 1383  184 1065 1114 1498 1405 1368
## [31]  784 1363 1505 1236  524 1467 1471 1448  793 1198  792  854  791 1284  741
## [46] 1031 1362  921
unique(main$NurseFlag)
## [1] "N" "Y"
#unique(main$Medical.Record.Number)
unique(main$Gender)
## [1] "Female"  "Male"    "Unknown"
unique(main$Attendance.Day)
## [1] "Friday"    "Tuesday"   "Thursday"  "Monday"    "Wednesday" "Sunday"   
## [7] "Saturday"
unique(main$Attendance.MonthYear)
##  [1] "May-23" "Jun-23" "Apr-21" "Jan-21" "Feb-21" "Feb-23" "Dec-20" "Jan-23"
##  [9] "Jan-20" "Feb-20" "Mar-20" "Apr-20" "May-20" "Jun-20" "Jul-20" "Aug-20"
## [17] "Oct-20" "Nov-20" "Mar-21" "Jun-21" "Jul-23" "Nov-23" "Dec-23" "Sep-20"
## [25] "May-22" "Oct-21" "Aug-22" "Jul-22" "Feb-22" "Mar-22" "Oct-23" "Mar-23"
## [33] "May-21" "Apr-22" "Jul-21" "Aug-21" "Jun-22" "Oct-22" "Sep-23" "Nov-21"
## [41] "Jan-22" "Sep-22" "Dec-21" "Nov-22" "Sep-21" "Aug-23" "Dec-22" "Apr-23"
unique(main$Attendance.Type)
##  [1] "RETURN"               "NEW"                  "WALK IN - RETURN"    
##  [4] "WALK IN - NEW"        "VIRTUAL NEW"          ""                    
##  [7] "Return Virtual Phone" "New Virtual Phone"    "Return Home Visit"   
## [10] "VIRTUAL RETURN"       "ADD ON - NEW"         "New Virtual Video"   
## [13] "ADD ON - RETURN"      "EMERGENCY"            "Return Virtual Video"
unique(main$Attendance.Year)
## [1] 2023 2021 2020 2022
unique(main$Attendance.Month)
##  [1] "May"       "June"      "April"     "January"   "February"  "December" 
##  [7] "March"     "July"      "August"    "October"   "November"  "September"
unique(main$Referral.Source)
##  [1] "A : EMERGENCY DEPT"                "C : CLINIC"                       
##  [3] "G : GP"                            "S : SELF"                         
##  [5] "W : WARD"                          "O : OTHER CONSULTANT"             
##  [7] "H : OTHER HOSPITAL"                "K : ED SMITHFIELD"                
##  [9] "R : ROOMS"                         "I : SWIFTCARE CLINIC"             
## [11] "X : HEALTH CENTRE REFERRAL"        "T : NTPF"                         
## [13] "Z : X-RAY"                         "B : HEALTH BOARD REFERRAL"        
## [15] "N : BREAST CHECK (NBSP)"           "V : VASCULAR LAB"                 
## [17] "D : DENTIST"                       "Q : REFERRED FROM CAWT INITIATIVE"
## [19] "E : OPTICIAN"
unique(main$Consultant)
##  [1] "MOROP : MORONEY MR. PAUL"        "COLGAN : COLGAN MS. GRAINNE"    
##  [3] "SYNNOT : SYNNOTT MR. KEITH"      "XXXXXX : Unknown"               
##  [5] "MARA : MARA MR. MICHAEL"         "LYONSF : LYONS MR. FRANK"       
##  [7] "BRIAIN : O BRIAIN MR. DAVID"     "OHEIRE : O'HEIREAMHOIN MR. SVEN"
##  [9] "TIMLIN : TIMLIN MR. MARCUS"      "BUTLER : BUTLER PROF. JOSEPH"   
## [11] "CASSID : CASSIDY MS. NOELLE"     "MORRI : MORRIS MR. SEAMUS"      
## [13] "HYNESD : HYNES MR. DARRAGH"      "ONEISH : O NEILL MR. SHANE"     
## [15] "CASHMA : CASHMAN MR. JAMES"      "MURMAR : MURPHY MR. MARTIN"     
## [17] "DODDSM : DODDS MR. MICHAEL"      "MCSORK : MCSORLEY MR. KEVIN"    
## [19] "LYNCSA : LYNCH MR. SAM"          "CARMOO : CARMODY MR. OLAN"      
## [21] "ORTCON : ORTHOPAEDIC CONSULTS"   "FRA : FRACTURE CONSULTS"
unique(main$Insurance.Scheme)
##  [1] "D : MEDICAL CARD HOLDER"    "S : SELF"                  
##  [3] "U : UNKNOWN"                "V : VHI"                   
##  [5] "B : LAYA HEALTHCARE"        "I : IRISH LIFE HEALTH"     
##  [7] "O : OTHER"                  "G : GARDA SCHEME"          
##  [9] "P : PRISON OFFICERS"        "E : E.S.B. SCHEME"         
## [11] "A : ARMY SCHEME"            "H : HOSPITAL SATURDAY FUND"
## [13] "J : GLOHEALTH"              "C : BLUE CROSS"            
## [15] "M : MEDISHIELD"
unique(main$Eligibility)
##  [1] "01 : CAT 1 (MEDICAL CARD)"           "02 : CAT 2 (NON MEDICAL CARD)"      
##  [3] "12 : DAY CASE - EXEMPT STAT. CHG."   "35 : INFECTIOUS OR SUSPECTED INFECT"
##  [5] "16 : NTPF - EXEMPT STAT. CHG."       "19 : STAFF EXEMPT-STATUTORY CHARGE" 
##  [7] "07 : RTA"                            "08 : ELIGIBILITY UNKNOWN"           
##  [9] "23 : NATIONAL COLORECTAL SCREENING"  "20 : HAA CARD HEALTH AMENDMENT ACT" 
## [11] "17 : ARMY - EXEMPT STAT. CHG."       "24 : DIABETIC RETINA TREATMENT"     
## [13] "21 : THE GOVERNOR - PRISONERS"       "10 : UK/NI - EXEMPT STAT.CHG."      
## [15] "11 : ANTI D/RESEARCH/TRIAL"          "03 : CAT 3 (15000 OR MORE)"         
## [17] "06 : NON EU-VISITOR"                 "13 : LONG STAY - EXEMPT STAT. CHG." 
## [19] "05 : EU-VISITOR NO EHIC"             "15 : SPECIAL OLYMPICS WORLD GAMES"  
## [21] "18 : EHIC - EXEMPT STAT. CHG."       "25 : UKRAINIAN CITIZEN"             
## [23] "26 : U16 EXEMPT STAT. CHARGE"
unique(main$Age.at.Attendance.Cat.HSE)
##  [1] "75 - 84" "65 - 74" "85 >="   "55 - 64" "0 - 4"   "45 - 54" "25 - 34"
##  [8] "35 - 44" "15 - 24" "Oct-14"  "05-Sep"
unique(main$Area.of.Residence)
##  [1] "0111 : DUBLIN 11"                 "0107 : DUBLIN 7"                 
##  [3] "0100 : DUBLIN NTH"                "0101 : DUBLIN 1"                 
##  [5] "0103 : DUBLIN 3"                  "0115 : DUBLIN 15"                
##  [7] "0117 : DUBLIN 17"                 "0109 : DUBLIN 9"                 
##  [9] "0600 : WEXFORD"                   "0105 : DUBLIN 5"                 
## [11] "0113 : DUBLIN 13"                 "2900 : CAVAN"                    
## [13] "0206 : DUBLIN 6"                  "0220 : DUBLIN 20"                
## [15] "0212 : DUBLIN 12"                 "0400 : WICKLOW"                  
## [17] "0202 : DUBLIN 2"                  "3100 : LOUTH"                    
## [19] "3200 : MEATH"                     "0000 : UNKNOWN"                  
## [21] "0208 : DUBLIN 8"                  "0214 : DUBLIN 14"                
## [23] "0222 : DUBLIN 22"                 "0300 : KILDARE"                  
## [25] "2400 : OFFALY"                    "0216 : DUBLIN 16"                
## [27] "0204 : DUBLIN 4"                  "0210 : DUBLIN 10"                
## [29] "0224 : DUBLIN 24"                 "2300 : WESTMEATH"                
## [31] "1300 : KERRY"                     "2500 : LAOIS"                    
## [33] "2200 : LONGFORD"                  "1000 : WATERFORD"                
## [35] "2800 : DONEGAL"                   "0500 : CARLOW"                   
## [37] "3000 : MONAGHAN"                  "0200 : DUBLIN STH"               
## [39] "2000 : ROSCOMMON"                 "2100 : MAYO"                     
## [41] "3310 : NORTH IRELAND"             "1900 : GALWAY COUNTY"            
## [43] "2700 : SLIGO"                     "1700 : TIPP. NTH RIDING"         
## [45] "2600 : LEITRIM"                   "1600 : CLARE"                    
## [47] "0218 : DUBLIN 18"                 "3320 : WALES"                    
## [49] "0700 : KILKENNY"                  "0800 : TIPP. STH RIDING"         
## [51] "1200 : CORK COUNTY"               "0901 : WATERFORD CITY"           
## [53] "1500 : LIMERICK COUNTY"           "1101 : CORK CITY"                
## [55] "1401 : LIMERICK CITY"             "3313 : SPAIN"                    
## [57] "3501 : AMERICA NORTH AND CANADA"  "3303 : ENGLAND & WALES"          
## [59] "3314 : PORTUGAL"                  "3305 : GERMANY"                  
## [61] "3304 : FRANCE"                    "3332 : ROMANIA"                  
## [63] "3600 : ASIA,MIDDLE EAST,FAR EAST" "3311 : SCOTLAND"                 
## [65] "3502 : AMERICA SOUTH, CENTRAL"    "3309 : LUXEMBOURG"               
## [67] "3308 : ITALY"                     "3700 : AUSTRALIA, NEW ZEALAND"   
## [69] "1801 : GALWAY CITY"               "3907 : MALTA"
unique(main$Referring.Hospital)
##  [1] ":"                                    
##  [2] "0955 : CAPPAGH NATIONAL ORTHOPAEDIC"  
##  [3] "0100 : ST MARYS HOSPITAL"             
##  [4] "0600 : WATERFORD UNIVERSITY HOSPITAL" 
##  [5] "0954 : CLONTARF HOSPITAL"             
##  [6] "0947 : ST LUKES HOSPITAL"             
##  [7] "0108 : CONNOLLY HOSPITAL"             
##  [8] "1111 : MATER PRIVATE HOSPITAL"        
##  [9] "1307 : BEACON HOSPITAL"               
## [10] "0923 : BEAUMONT HOSPITAL"             
## [11] "0501 : SLIGO UNIVERSITY HOSPITAL"     
## [12] "0110 : CHARTER MEDICAL"               
## [13] "0904 : ST JAMES HOSPITAL"             
## [14] "0960 : NATIONAL REHABILITATION"       
## [15] "1270 : TALLAGHT HOSPITAL AMNCH"       
## [16] "0202 : MULLINGAR MIDLAND REGIONAL"    
## [17] "0605 : WEXFORD GENERAL HOSPITAL"      
## [18] "0403 : OUR LADYS HOSPITAL"            
## [19] "0910 : ST VINCENTS UNIVERSITY"        
## [20] "0203 : TULLAMORE MIDLAND REGIONAL"    
## [21] "9096 : CRC CENTRAL REMEDIAL CLINIC"   
## [22] "0803 : ROSCOMMON UNIVERSITY HOSPITAL" 
## [23] "0704 : BANTRY GENERAL HOSPITAL"       
## [24] "0908 : MATER MISERICORDIAE UNIVERSITY"
## [25] "0300 : LIMERICK UNIVERSITY HOSPITAL"  
## [26] "0402 : CAVAN GENERAL HOSPITAL"        
## [27] "0912 : ST MICHAELS HOSPITAL"          
## [28] "1915 : SANTRY SPORTS SURGERY CLINIC"  
## [29] "1271 : AUT EVEN HOSPITAL"             
## [30] "0302 : CROOM ORTHOPAEDIC HOSPITAL"    
## [31] "0922 : OUR LADY OF LOURDES HOSPITAL"  
## [32] "9060 : PRIVATE HOSPITAL"              
## [33] "9099 : OTHER ACUTE HOSPITAL"          
## [34] "0940 : TEMPLE STREET CHILDRENS"       
## [35] "0724 : CORK UNIVERSITY HOSPITAL"      
## [36] "0726 : UNIVERSITY HOSPITAL KERRY"     
## [37] "0601 : ST LUKES GENERAL HOSPITAL"     
## [38] "0101 : ST COLUMCILLES HOSPITAL"       
## [39] "0998 : DUBLIN DENTAL UNIVERSITY"      
## [40] "1290 : VHI SWIFTCARE CLINIC SWORDS"   
## [41] "0802 : MAYO UNIVERSITY HOSPITAL"      
## [42] "9091 : ST BRENDAN'S HOSPITAL"         
## [43] "0500 : LETTERKENNY UNIVERSITY"        
## [44] "0102 : NAAS GENERAL HOSPITAL"         
## [45] "0400 : LOUTH COUNTY HOSPITAL"         
## [46] "9040 : ACUTE HOSPITAL IN FRANCE"      
## [47] "0607 : SOUTH TIPPERARY GENERAL HOSPIT"
## [48] "9094 : ST JOHN OF GOD HOSPITAL"       
## [49] "0941 : CRUMLIN OUR LADYS CHILDRENS"   
## [50] "0800 : GALWAY UNIVERSITY HOSPITAL"    
## [51] "9080 : ST BRICIN'S MILITARY HOSPITAL" 
## [52] "1291 : VHI SWIFTCARE CLINIC DUNDRUM"  
## [53] "9084 : THE GALWAY CLINIC"             
## [54] "0305 : ENNIS HOSPITAL"                
## [55] "1280 : BLACKROCK CLINIC"              
## [56] "9067 : HERMITAGE MEDICAL CLINIC"      
## [57] "9061 : BONS SECOURS PRIVATE HOSPITAL" 
## [58] "9092 : ST VINCENTS HOSPITAL"          
## [59] "9063 : ST VINCENTS PRIVATE HOSPITAL"  
## [60] "0201 : PORTLAOISE MIDLAND REGIONAL"   
## [61] "0915 : SOUTH INFIRMARY/VICTORIA"      
## [62] "0932 : ROTUNDA HOSPITAL"              
## [63] "0602 : KILCREENE REGIONAL ORTHOPAEDIC"
## [64] "0404 : MONAGHAN COUNTY HOSPITAL"      
## [65] "0801 : REGIONAL HOSPITAL, MERLIN PARK"
## [66] "1303 : BARRINGTONS PRIVATE HOSPITAL"  
## [67] "1112 : MATER PRIVATE HOSPITAL CORK"   
## [68] "9031 : ACUTE HOSPITAL IN ENGLAND"     
## [69] "0304 : NENAGH HOSPITAL"               
## [70] "9065 : BON SECOURS HOSPITAL"          
## [71] "0502 : OUR LADYS COMMUNITY HOSPITAL"  
## [72] "0950 : ROYAL VICTORIA EYE AND EAR"    
## [73] "9090 : PSYCHIATRIC HOSPITAL"
unique(main$Booking.Type)
## [1] "C : New  Virtual Phone"    "R : RETURN"               
## [3] "N : NEW"                   ":"                        
## [5] "W : WARD"                  "B : New  Virtual Video"   
## [7] "E : Return  Virtual Phone" "D : Return  Virtual Video"
## [9] "V : REVIEW"
unique(main$Cancellation.Group)
## [1] "N/A"        "Hospital"   "DNA"        "Patient"    "Validation"
unique(main$Reason.for.Cancellation)
##  [1] ""                                                  
##  [2] "Covid 19 Outbreak Hosp Canc"                       
##  [3] "Appt brought forward by Hosp"                      
##  [4] "NO SHOW"                                           
##  [5] "PERSONAL/FAMILY REASONS"                           
##  [6] "Covid 19 Outbreak Pat Canc"                        
##  [7] "PATIENT IN OTHER HEALTH CARE"                      
##  [8] "Appt issued incorrectly by hosp"                   
##  [9] "Patient requested earlier appt"                    
## [10] "transfer to new consultant"                        
## [11] "Patient no longer requires A"                      
## [12] "PATIENT ATTEND OPD AT MMUH"                        
## [13] "inappropriate appointment"                         
## [14] "TECHNICIAN UNAVAILABLE"                            
## [15] "PATIENT ILL"                                       
## [16] "Clinic reduced on Cons Instru"                     
## [17] "PATIENT CANCELLED APPOINTMENT"                     
## [18] "TEMPLATE / BOOKING DIARY AMEND"                    
## [19] "PATIENT INPATIENT MMUH"                            
## [20] "CONSULTANT AT MEET/CONFER/EXAM"                    
## [21] "CONSULTANT ABSENT ANNUAL LEAVE"                    
## [22] "Appt date time not suitable"                       
## [23] "EARLIER APPOINTMENT IN OTHER PUBLIC HOSPITAL"      
## [24] "PATIENT CANCELLED NO REASON"                       
## [25] "PATIENT ON HOLIDAYS"                               
## [26] "CONSULTANT ABSENT PERSONAL"                        
## [27] "CONSULTANT RETIREMENT"                             
## [28] "Appointment deferred as per Consultant instruction"
## [29] "PATIENT FORGOT APPOINTMENT"                        
## [30] "EARLIER PRIVATE APPOINTMENT"                       
## [31] "PT INDICATES APPT NO REQUIRED"                     
## [32] "DEATH IN FAMILY"                                   
## [33] "ED Requested earlier appointment"                  
## [34] "validation cancelled by pt"                        
## [35] "Patient deceased"                                  
## [36] "CONSULTANT ABSENT - MATERNITY"                     
## [37] "APP CANCELLED - AWAIT RESULTS"                     
## [38] "appointment deferred as per ANP instruction"       
## [39] "patient attends GP for care"                       
## [40] "Adverse weather"                                   
## [41] "PAT ATTENDED OPD AT MMUH"                          
## [42] "CONSULTANT ABSENT - PARENTAL L"                    
## [43] "GP REQUEST EARLIER APPOINTMENT"                    
## [44] "INDUSTRIAL DISPUTE"                                
## [45] "Consultant on Secondment"                          
## [46] "TIME BLOCKED OUT"                                  
## [47] "validation no rsp by pt,apt cx"                    
## [48] "CONSULTANT ABSENT - SICK LEAVE"                    
## [49] "CLINICIAN ON ANNUAL LEAVE"                         
## [50] "BOOKING DIARY MANAGEMENT"                          
## [51] "CONSULTANTS INSTRUCTIONS"
unique(main$Rebooked.Indicator)
## [1] ""    "Yes" "No"
unique(main$Hospital.Catchment)
## [1] "Mater Catchment"         "National Catchment"     
## [3] "Connolly Catchment"      "Beaumont Catchment"     
## [5] "Vincents Catchment"      "James Catchment"        
## [7] "International Catchment" "Tallaght Catchment"
## Transforming data
# main_group <- main_processed %>% group_by(main_processed$Medical.Record.Number) #library(moments)
# main_group$freq_MRN_recode <- ifelse(count(main_group$Medical.Record.Number >= 34)==1,1,0)

#library(plyr)
main$Clinic.Type_recode <- mapvalues(main$Clinic.Type, from = c("GEN : GENERAL","SPN : SPINAL CLINIC","SCO : SCOLIOSIS CLINIC","FED : FRACTURE ED","MSK : MUSCULOSKELETAL CLINIC","JIC : JOINT INJECTION CLINIC","POD : PODIATRY","ULC : UPPER LIMB CLINIC","BPL : BRACHIAL PLEXUS CLINIC","PLS : NTPF ORTHO CLINIC","MSN : MSK NTPF TRIAGE CLINIC","COM : BALLYMUN COMMUNITY MSK TRIAGE","COS : SUMMERHILL MSK TRIAGE CLINICS","CGP : COMBINED GP CLINIC","ABC : ACUTE BACK PAIN CLINIC","LBP : LOW BACK PAIN PATHWAY","BPP : BACK PAIN PILOT CLINIC"), 
                                     to = c("GENERAL","SPINErelated","SPINErelated","SPINErelated","MUSCULOSKELETALrelated","MUSCULOSKELETALrelated","PODIATRY","UPPER_LIMBrelated","UPPER_LIMBrelated","NTPFfund","NTPFfund","NotLocatedInMater","NotLocatedInMater","NotLocatedInMater","BACK_PAINrelated","BACK_PAINrelated","BACK_PAINrelated"))

main$Referral.Source_recode <- mapvalues(main$Referral.Source, from = c("C : CLINIC","G : GP","W : WARD","N : BREAST CHECK (NBSP)","H : OTHER HOSPITAL","S : SELF","O : OTHER CONSULTANT","R : ROOMS","A : EMERGENCY DEPT","B : HEALTH BOARD REFERRAL","K : ED SMITHFIELD","V : VASCULAR LAB","X : HEALTH CENTRE REFERRAL","Q : REFERRED FROM CAWT INITIATIVE","D : DENTIST","I : SWIFTCARE CLINIC","T : NTPF","Z : X-RAY","E : OPTICIAN"), 
                                         to = c("CLINIC","GP","WARD","Elsew of Mater","Elsew outside Mater","Elsew outside Mater","OTHER CONSULTANT","Elsew of Mater","EMERGENCY DEPT","Elsew of Mater","Elsew of Mater","Elsew of Mater","Elsew outside Mater","Elsew outside Mater","OTHER CONSULTANT","Elsew outside Mater","Elsew of Mater","Elsew of Mater","OTHER CONSULTANT"))

main$Consultant_recode <- mapvalues(main$Consultant, from = c("MOROP : MORONEY MR. PAUL","COLGAN : COLGAN MS. GRAINNE","SYNNOT : SYNNOTT MR. KEITH","XXXXXX : Unknown","MARA : MARA MR. MICHAEL","LYONSF : LYONS MR. FRANK","BRIAIN : O BRIAIN MR. DAVID","OHEIRE : O'HEIREAMHOIN MR. SVEN","TIMLIN : TIMLIN MR. MARCUS","BUTLER : BUTLER PROF. JOSEPH","CASSID : CASSIDY MS. NOELLE","MORRI : MORRIS MR. SEAMUS","HYNESD : HYNES MR. DARRAGH","ONEISH : O NEILL MR. SHANE","CASHMA : CASHMAN MR. JAMES","MURMAR : MURPHY MR. MARTIN","DODDSM : DODDS MR. MICHAEL","MCSORK : MCSORLEY MR. KEVIN","LYNCSA : LYNCH MR. SAM","CARMOO : CARMODY MR. OLAN","ORTCON : ORTHOPAEDIC CONSULTS","FRA : FRACTURE CONSULTS"), 
                                    to = c("MOROP","COLGAN","SYNNOT","XX","MARA","LYONSF","BRIAIN","OHEIRE","TIMLIN","BUTLER","CASSID","MORRI","HYNESD","ONEISH","CASHMA","MURMAR","DODDSM","MCSORK","LYNCSA","CARMOO","ORTCON","FRA"))

main$Insurance.Scheme_recode <- mapvalues(main$Insurance.Scheme, from = c("U : UNKNOWN","D : MEDICAL CARD HOLDER","V : VHI","G : GARDA SCHEME","I : IRISH LIFE HEALTH","S : SELF","B : LAYA HEALTHCARE","O : OTHER","J : GLOHEALTH","E : E.S.B. SCHEME","C : BLUE CROSS","P : PRISON OFFICERS","H : HOSPITAL SATURDAY FUND","A : ARMY SCHEME","M : MEDISHIELD"), 
                                          to = c("U","D","V","G","I","S","B","O","J","E","C","P","H","A","M"))

main$Hospital.Catchment_recode <- mapvalues(main$Hospital.Catchment, from = c("Mater Catchment","National Catchment","Connolly Catchment","James Catchment","Tallaght Catchment","Beaumont Catchment","International Catchment","Vincents Catchment"), 
                                            to = c("Mater","National","Connolly","James","Tallaght","Beaumont","International","Vincents"))

main$Attendance.Type_recode <- mapvalues(main$Attendance.Type.Description, from = c("WALK IN - NEW","ADD ON - NEW","WALK IN - RETURN","ADD ON - RETURN","Return Home Visit","Return Virtual Phone","VIRTUAL NEW","New Virtual Phone","New Virtual Video","Return Virtual Video"), 
                                         to = c("NEW","NEW","RETURN","RETURN","RETURN","VIRTUAL(New_Return)","VIRTUAL(New_Return)","VIRTUAL(New_Return)","VIRTUAL(New_Return)","VIRTUAL(New_Return)"))

main$Eligibility_recode <- mapvalues(main$Eligibility, from = c("02 : CAT 2 (NON MEDICAL CARD)","01 : CAT 1 (MEDICAL CARD)","08 : ELIGIBILITY UNKNOWN","12 : DAY CASE - EXEMPT STAT. CHG.","19 : STAFF EXEMPT-STATUTORY CHARGE","35 : INFECTIOUS OR SUSPECTED INFECT","11 : ANTI D/RESEARCH/TRIAL","23 : NATIONAL COLORECTAL SCREENING","16 : NTPF - EXEMPT STAT. CHG.","06 : NON EU-VISITOR","24 : DIABETIC RETINA TREATMENT","07 : RTA","17 : ARMY - EXEMPT STAT. CHG.","10 : UK/NI - EXEMPT STAT.CHG.","21 : THE GOVERNOR - PRISONERS","13 : LONG STAY - EXEMPT STAT. CHG.","25 : UKRAINIAN CITIZEN","20 : HAA CARD HEALTH AMENDMENT ACT","18 : EHIC - EXEMPT STAT. CHG.","05 : EU-VISITOR NO EHIC","26 : U16 EXEMPT STAT. CHARGE","03 : CAT 3 (15000 OR MORE)","15 : SPECIAL OLYMPICS WORLD GAMES"), 
                                     to = c("NON MEDICAL CARD","MEDICAL CARD","ELIGIBILITY UNKNOWN","EXEMPT","EXEMPT","ACUTE UNCLASSIFIED","RESEARCH/NATIONAL PROG.","RESEARCH/NATIONAL PROG.","EXEMPT","NON MEDICAL CARD","NON ACUTE UNCLASSIFIED","ACUTE UNCLASSIFIED","EXEMPT","EXEMPT","EXEMPT","EXEMPT","EXEMPT","RESEARCH/NATIONAL PROG.","EXEMPT","NON MEDICAL CARD","EXEMPT","15000+","EXEMPT"))

dublin_nth <- c("01")
dublin_sth <- c("02")
outside_irl <- c("33","35","36","37","39")
other_eastern.midland_region <- c("0300","0400","0500","2200","2300","2400","2500","3100","3200")
northern.western_region <- c("1801","1900","2000","2100","2600","2700","2800","2900","3000")
southern_region <- c("0600","0700","0800","0901","1000","1101","1200","1300","1401","1500","1600","1700")
main <- main %>%     #library(plyr)
 mutate(Area.of.Residence_recode = case_when(
  substring(main$Area.of.Residence,0,2) %in% dublin_nth ~ "DUBLIN NTH",
  substring(main$Area.of.Residence,0,2) %in% dublin_sth ~ "DUBLIN STH",
  substring(main$Area.of.Residence,0,4) %in% other_eastern.midland_region ~ "EASTERN & MIDLAND REGION (excl.Dublin)",
  substring(main$Area.of.Residence,0,4) %in% northern.western_region ~ "NORTHERN WESTERN REGION",
  substring(main$Area.of.Residence,0,4) %in% southern_region ~ "SOUTHERN REGION",
  substring(main$Area.of.Residence,0,2) %in% outside_irl ~ "OUTSIDE IRELAND",
  substring(main$Area.of.Residence,0,4) == "0000" ~ "UNKNOWN",
  TRUE ~ "Other counties"
))
head (main$Area.of.Residence_recode,10)
##  [1] "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH"
##  [6] "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH"
table(main$Area.of.Residence_recode)
## 
##                             DUBLIN NTH                             DUBLIN STH 
##                                  53149                                  10918 
## EASTERN & MIDLAND REGION (excl.Dublin)                NORTHERN WESTERN REGION 
##                                  11091                                   2918 
##                        OUTSIDE IRELAND                        SOUTHERN REGION 
##                                    137                                   3999 
##                                UNKNOWN 
##                                    331
main$Booking.Type_recode <- ifelse(main$Booking.Type == ":", ifelse(!duplicated(main$Medical.Record.Number), "N : NEW", "R : RETURN"), main$Booking.Type)
main$Booking.Type_recode <- mapvalues(main$Booking.Type_recode, from = c("N : NEW","R : RETURN","W : WARD"), to =c("NEW","RETURN","WARD"))

main$Reason.for.Cancellation_recode <- mapvalues(main$Reason.for.Cancellation.Desc, from = c("NO SHOW","Patient no longer requires A","TEMPLATE / BOOKING DIARY AMEND","Appt brought forward by Hosp","Clinic reduced on Cons Instru","PERSONAL/FAMILY REASONS","PATIENT CANCELLED APPOINTMENT","Covid 19 Outbreak Hosp Canc","Appt issued incorrectly by hosp","PATIENT ILL","APP CANCELLED - AWAIT RESULTS","PATIENT ON HOLIDAYS","Appt date time not suitable","appointment deferred as per ANP instruction","CONSULTANT ABSENT ANNUAL LEAVE","BOOKING DIARY MANAGEMENT","EARLIER PRIVATE APPOINTMENT","TIME BLOCKED OUT","Covid 19 Outbreak Pat Canc","PATIENT IN OTHER HEALTH CARE","Appointment deferred as per Consultant instruction","inappropriate appointment","Patient requested earlier appt","PATIENT CANCELLED NO REASON","Patient deceased","EARLIER APPOINTMENT IN OTHER PUBLIC HOSPITAL","PATIENT FORGOT APPOINTMENT","PT INDICATES APPT NO REQUIRED","PATIENT INPATIENT MMUH","DEATH IN FAMILY","Adverse weather","PAT ATTENDED OPD AT MMUH","transfer to new consultant","PATIENT ATTEND OPD AT MMUH","ED Requested earlier appointment","CONSULTANT ABSENT - SICK LEAVE","patient attends GP for care","Consultant on Secondment","GP REQUEST EARLIER APPOINTMENT","validation cancelled by pt","CONSULTANT AT MEET/CONFER/EXAM","CONSULTANT RETIREMENT","CONSULTANTS INSTRUCTIONS","CLINICIAN ON ANNUAL LEAVE","validation no rsp by pt,apt cx","INDUSTRIAL DISPUTE","CONSULTANT ABSENT - PARENTAL L","CONSULTANT ABSENT - MATERNITY","CONSULTANT ABSENT PERSONAL","TECHNICIAN UNAVAILABLE"), 
                                                 to = c("No show","By Patient","By Hospital","By Hospital","By Cslt/AN/Tech","By Patient","By Patient","By Covid","By Hospital","By Patient-health conditions","By Hospital","By Patient","By Patient","By Cslt/AN/Tech","By Cslt/AN/Tech","By Hospital","By Patient","By Hospital","By Covid","By Patient-health conditions","By Cslt/AN/Tech","By Patient","By Patient","By Patient","By Patient-health conditions","By Patient-health conditions","By Patient","By Patient","By Patient-health conditions","By Patient","By Patient","By Patient-health conditions","By Cslt/AN/Tech","By Patient-health conditions","By Hospital","By Cslt/AN/Tech","By Patient-health conditions","By Cslt/AN/Tech","By Patient-health conditions","By Patient","By Cslt/AN/Tech","By Cslt/AN/Tech","By Cslt/AN/Tech","By Cslt/AN/Tech","By Patient","By Hospital","By Cslt/AN/Tech","By Cslt/AN/Tech","By Cslt/AN/Tech","By Cslt/AN/Tech"))

main$New.Attendances <- ifelse(is.na(main$No.New.Attendances)==F, ifelse(main$No.New.Attendances>0,1,0), main$No.New.Attendances)

# main$Referring.Hospital <-

### Date calculation from Appointment/ Booking to Attendance
main$Attendance.Date <- as.Date(main$Attendance.Date, format="%d/%m/%y")
library(zoo)
main$attendanceMonthYear <- as.yearmon(paste(year(main$Attendance.Date), month(main$Attendance.Date)), "%Y %m") #change date from char format to numeric by using library(zoo)

main$Appointment.Date <- as.POSIXct(main$Appointment.Date...Time,format="%Y%m%d %H:%M:%S",tz=Sys.timezone())
main$Appointment.Date <- as.Date(main$Appointment.Date, format="%d/%m/%y")
main$appointmentMonthYear <- as.yearmon(paste(year(main$Appointment.Date), month(main$Appointment.Date)), "%Y %m") #change date from char format to numeric by using library(zoo)
main$appointmentDay <- weekdays(main$Appointment.Date)


main$Booked.Date <- as.Date(main$Booked.Date, format="%d/%m/%y")
main$bookedMonthYear <- as.yearmon(paste(year(main$Booked.Date), month(main$Booked.Date)), "%Y %m") #change date from char format to numeric by using library(zoo)
main$bookedDay <- weekdays(main$Booked.Date)

main$daysDiff_attendanceAppoint <- difftime(main$Appointment.Date,main$Attendance.Date,units="days")
main$daysDiff_attendanceBooked <- difftime(main$Booked.Date,main$Attendance.Date,units="days")
main$daysDiff_AppointBooked <- difftime(main$Booked.Date,main$Appointment.Date,units="days")

main$addressDiff <- ifelse(main$Present.Address == main$Home.Address, 0, 1)

main$Rebooked.Indicator <- main$Rebooked.Indicator..HIS.

unique(main$Clinic.Type_recode)
## [1] "GENERAL"                "MUSCULOSKELETALrelated" "PODIATRY"              
## [4] "SPINErelated"           "UPPER_LIMBrelated"      "NTPFfund"              
## [7] "NotLocatedInMater"      "BACK_PAINrelated"
#unique(main$Medical.Record.Number)
unique(main$Attendance.Type_recode)
## [1] "RETURN"              "NEW"                 "VIRTUAL(New_Return)"
## [4] ""                    "VIRTUAL RETURN"      "EMERGENCY"
unique(main$Referral.Source_recode)
## [1] "EMERGENCY DEPT"      "CLINIC"              "GP"                 
## [4] "Elsew outside Mater" "WARD"                "OTHER CONSULTANT"   
## [7] "Elsew of Mater"
unique(main$Consultant_recode)
##  [1] "MOROP"  "COLGAN" "SYNNOT" "XX"     "MARA"   "LYONSF" "BRIAIN" "OHEIRE"
##  [9] "TIMLIN" "BUTLER" "CASSID" "MORRI"  "HYNESD" "ONEISH" "CASHMA" "MURMAR"
## [17] "DODDSM" "MCSORK" "LYNCSA" "CARMOO" "ORTCON" "FRA"
unique(main$Insurance.Scheme_recode)
##  [1] "D" "S" "U" "V" "B" "I" "O" "G" "P" "E" "A" "H" "J" "C" "M"
unique(main$Eligibility_recode)
## [1] "MEDICAL CARD"            "NON MEDICAL CARD"       
## [3] "EXEMPT"                  "ACUTE UNCLASSIFIED"     
## [5] "ELIGIBILITY UNKNOWN"     "RESEARCH/NATIONAL PROG."
## [7] "NON ACUTE UNCLASSIFIED"  "15000+"
unique(main$Area.of.Residence_recode)
## [1] "DUBLIN NTH"                            
## [2] "SOUTHERN REGION"                       
## [3] "NORTHERN WESTERN REGION"               
## [4] "DUBLIN STH"                            
## [5] "EASTERN & MIDLAND REGION (excl.Dublin)"
## [6] "UNKNOWN"                               
## [7] "OUTSIDE IRELAND"
unique(main$Booking.Type_recode)
## [1] "C : New  Virtual Phone"    "RETURN"                   
## [3] "NEW"                       "WARD"                     
## [5] "B : New  Virtual Video"    "E : Return  Virtual Phone"
## [7] "D : Return  Virtual Video" "V : REVIEW"
unique(main$Reason.for.Cancellation_recode)
## [1] ""                             "By Covid"                    
## [3] "By Hospital"                  "No show"                     
## [5] "By Patient"                   "By Patient-health conditions"
## [7] "By Cslt/AN/Tech"
unique(main$Hospital.Catchment_recode)
## [1] "Mater"         "National"      "Connolly"      "Beaumont"     
## [5] "Vincents"      "James"         "International" "Tallaght"
## Create dataset for modelling
# main.df <- main %>% select(-rownames,-) #when there are multiple files to combine with same variables

write.csv(main[,c("Record.Type","Clinic.Code","Clinic.Type_recode","NurseFlag","Medical.Record.Number","Gender","Attendance.Day","Attendance.MonthYear","Attendance.Date","Attendance.Type_recode","Attendance.Year","Attendance.Month","Referral.Source_recode","Consultant_recode","Insurance.Scheme_recode","Eligibility_recode","Age.at.Attendance","Age.at.Attendance.Cat.HSE","Pathway.Number","Present.Address","Home.Address","Appointment.Date","appointmentMonthYear","appointmentDay","Area.of.Residence_recode","Referring.Hospital","Booking.Type_recode","Booked.Date","bookedMonthYear","bookedDay","Cancellation.Group","Reason.for.Cancellation_recode","Rebooked.Indicator","Hospital.Catchment_recode","No.Attendances","New.Attendances","No.Cancels","No.DNAs","daysDiff_attendanceAppoint","daysDiff_attendanceBooked","daysDiff_AppointBooked","addressDiff")],"spineDetails.csv")

main_processed <- read.csv("spineDetails.csv")

## Convert all character variables to factor
# main_processed <- main_processed %>% mutate_if(is.character,as.factor)

# main_processed_tibble <- as_tibble(main_processed) #library(tidyverse), tibble never changes [the type of the inputs, the names of variables], it only recycles inputs of length 1, and never creates row.names()

Inspecting data

Inspecting new and re-coded variables

str(main_processed)
## 'data.frame':    82543 obs. of  43 variables:
##  $ X                             : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Record.Type                   : chr  "Attendance" "Attendance" "Attendance" "Attendance" ...
##  $ Clinic.Code                   : int  1038 1229 1229 1229 1229 1059 726 726 726 726 ...
##  $ Clinic.Type_recode            : chr  "GENERAL" "GENERAL" "GENERAL" "GENERAL" ...
##  $ NurseFlag                     : chr  "N" "N" "N" "N" ...
##  $ Medical.Record.Number         : int  118 118 118 118 118 367 532 532 532 532 ...
##  $ Gender                        : chr  "Female" "Female" "Female" "Female" ...
##  $ Attendance.Day                : chr  "Friday" "Tuesday" "Tuesday" "Tuesday" ...
##  $ Attendance.MonthYear          : chr  "May-23" "May-23" "May-23" "May-23" ...
##  $ Attendance.Date               : chr  "2020-05-12" "2020-05-16" "2020-05-23" "2020-05-30" ...
##  $ Attendance.Type_recode        : chr  "RETURN" "RETURN" "RETURN" "RETURN" ...
##  $ Attendance.Year               : int  2023 2023 2023 2023 2023 2021 2021 2021 2021 2021 ...
##  $ Attendance.Month              : chr  "May" "May" "May" "May" ...
##  $ Referral.Source_recode        : chr  "EMERGENCY DEPT" "EMERGENCY DEPT" "CLINIC" "CLINIC" ...
##  $ Consultant_recode             : chr  "MOROP" "COLGAN" "COLGAN" "COLGAN" ...
##  $ Insurance.Scheme_recode       : chr  "D" "D" "D" "D" ...
##  $ Eligibility_recode            : chr  "MEDICAL CARD" "MEDICAL CARD" "MEDICAL CARD" "MEDICAL CARD" ...
##  $ Age.at.Attendance             : int  78 78 78 78 78 77 67 67 67 67 ...
##  $ Age.at.Attendance.Cat.HSE     : chr  "75 - 84" "75 - 84" "75 - 84" "75 - 84" ...
##  $ Pathway.Number                : int  57091024 57094901 57094901 57094901 57094901 56113762 76695773 76673871 76704166 56064254 ...
##  $ Present.Address               : chr  "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" ...
##  $ Home.Address                  : chr  "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" "23 CLOONLARA ROAD, FINGLAS, DUBLIN 11" ...
##  $ Appointment.Date              : chr  NA NA NA NA ...
##  $ appointmentMonthYear          : chr  NA NA NA NA ...
##  $ appointmentDay                : chr  NA NA NA NA ...
##  $ Area.of.Residence_recode      : chr  "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH" "DUBLIN NTH" ...
##  $ Referring.Hospital            : chr  ":" ":" ":" ":" ...
##  $ Booking.Type_recode           : chr  "C : New  Virtual Phone" "RETURN" "RETURN" "RETURN" ...
##  $ Booked.Date                   : chr  "2020-05-11" "2020-05-12" "2020-05-16" "2020-05-24" ...
##  $ bookedMonthYear               : chr  "May 2020" "May 2020" "May 2020" "May 2020" ...
##  $ bookedDay                     : chr  "Monday" "Tuesday" "Saturday" "Sunday" ...
##  $ Cancellation.Group            : chr  "N/A" "N/A" "N/A" "N/A" ...
##  $ Reason.for.Cancellation_recode: chr  "" "" "" "" ...
##  $ Rebooked.Indicator            : chr  "" "" "" "" ...
##  $ Hospital.Catchment_recode     : chr  "Mater" "Mater" "Mater" "Mater" ...
##  $ No.Attendances                : int  1 1 1 1 1 1 NA NA NA 1 ...
##  $ New.Attendances               : int  0 0 0 0 0 1 NA NA NA 0 ...
##  $ No.Cancels                    : int  NA NA NA NA NA NA 1 1 0 NA ...
##  $ No.DNAs                       : int  NA NA NA NA NA NA 0 0 1 NA ...
##  $ daysDiff_attendanceAppoint    : int  NA NA NA NA NA NA 366 366 366 NA ...
##  $ daysDiff_attendanceBooked     : int  -1 -4 -7 -6 -21 -20 345 324 -17 -11 ...
##  $ daysDiff_AppointBooked        : int  NA NA NA NA NA NA -21 -42 -383 NA ...
##  $ addressDiff                   : int  0 0 0 0 0 0 0 0 0 0 ...
summary(main_processed)
##        X         Record.Type         Clinic.Code   Clinic.Type_recode
##  Min.   :    1   Length:82543       Min.   : 184   Length:82543      
##  1st Qu.:20637   Class :character   1st Qu.: 849   Class :character  
##  Median :41272   Mode  :character   Median :1059   Mode  :character  
##  Mean   :41272                      Mean   :1045                     
##  3rd Qu.:61908                      3rd Qu.:1229                     
##  Max.   :82543                      Max.   :1505                     
##                                                                      
##   NurseFlag         Medical.Record.Number    Gender          Attendance.Day    
##  Length:82543       Min.   :    118       Length:82543       Length:82543      
##  Class :character   1st Qu.: 554658       Class :character   Class :character  
##  Mode  :character   Median :1068020       Mode  :character   Mode  :character  
##                     Mean   :1031476                                            
##                     3rd Qu.:1270115                                            
##                     Max.   :9996870                                            
##                                                                                
##  Attendance.MonthYear Attendance.Date    Attendance.Type_recode Attendance.Year
##  Length:82543         Length:82543       Length:82543           Min.   :2020   
##  Class :character     Class :character   Class :character       1st Qu.:2021   
##  Mode  :character     Mode  :character   Mode  :character       Median :2022   
##                                                                 Mean   :2022   
##                                                                 3rd Qu.:2023   
##                                                                 Max.   :2023   
##                                                                                
##  Attendance.Month   Referral.Source_recode Consultant_recode 
##  Length:82543       Length:82543           Length:82543      
##  Class :character   Class :character       Class :character  
##  Mode  :character   Mode  :character       Mode  :character  
##                                                              
##                                                              
##                                                              
##                                                              
##  Insurance.Scheme_recode Eligibility_recode Age.at.Attendance
##  Length:82543            Length:82543       Min.   :  0.00   
##  Class :character        Class :character   1st Qu.: 34.00   
##  Mode  :character        Mode  :character   Median : 50.00   
##                                             Mean   : 49.64   
##                                             3rd Qu.: 64.00   
##                                             Max.   :105.00   
##                                                              
##  Age.at.Attendance.Cat.HSE Pathway.Number     Present.Address   
##  Length:82543              Min.   :52869091   Length:82543      
##  Class :character          1st Qu.:56276830   Class :character  
##  Mode  :character          Median :56916158   Mode  :character  
##                            Mean   :62942726                     
##                            3rd Qu.:76592988                     
##                            Max.   :77884614                     
##                                                                 
##  Home.Address       Appointment.Date   appointmentMonthYear appointmentDay    
##  Length:82543       Length:82543       Length:82543         Length:82543      
##  Class :character   Class :character   Class :character     Class :character  
##  Mode  :character   Mode  :character   Mode  :character     Mode  :character  
##                                                                               
##                                                                               
##                                                                               
##                                                                               
##  Area.of.Residence_recode Referring.Hospital Booking.Type_recode
##  Length:82543             Length:82543       Length:82543       
##  Class :character         Class :character   Class :character   
##  Mode  :character         Mode  :character   Mode  :character   
##                                                                 
##                                                                 
##                                                                 
##                                                                 
##  Booked.Date        bookedMonthYear     bookedDay         Cancellation.Group
##  Length:82543       Length:82543       Length:82543       Length:82543      
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  Reason.for.Cancellation_recode Rebooked.Indicator Hospital.Catchment_recode
##  Length:82543                   Length:82543       Length:82543             
##  Class :character               Class :character   Class :character         
##  Mode  :character               Mode  :character   Mode  :character         
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  No.Attendances  New.Attendances   No.Cancels       No.DNAs     
##  Min.   :1       Min.   :0.000   Min.   :0.00    Min.   :0.00   
##  1st Qu.:1       1st Qu.:0.000   1st Qu.:0.00    1st Qu.:0.00   
##  Median :1       Median :0.000   Median :1.00    Median :0.00   
##  Mean   :1       Mean   :0.388   Mean   :0.66    Mean   :0.34   
##  3rd Qu.:1       3rd Qu.:1.000   3rd Qu.:1.00    3rd Qu.:1.00   
##  Max.   :3       Max.   :1.000   Max.   :1.00    Max.   :1.00   
##  NA's   :25896   NA's   :25896   NA's   :56647   NA's   :56647  
##  daysDiff_attendanceAppoint daysDiff_attendanceBooked daysDiff_AppointBooked
##  Min.   :  -1.0             Min.   :-350.000          Min.   :-1424.0       
##  1st Qu.: 365.0             1st Qu.: -34.000          1st Qu.: -814.0       
##  Median : 730.0             Median : -15.000          Median : -485.0       
##  Mean   : 545.1             Mean   :  -6.073          Mean   : -556.9       
##  3rd Qu.: 731.0             3rd Qu.:  -6.000          3rd Qu.: -137.0       
##  Max.   :1096.0             Max.   : 362.000          Max.   :    0.0       
##  NA's   :56647              NA's   :5680              NA's   :56647         
##   addressDiff    
##  Min.   :0.0000  
##  1st Qu.:0.0000  
##  Median :0.0000  
##  Mean   :0.1505  
##  3rd Qu.:0.0000  
##  Max.   :1.0000  
## 
head(main_processed)
##   X Record.Type Clinic.Code     Clinic.Type_recode NurseFlag
## 1 1  Attendance        1038                GENERAL         N
## 2 2  Attendance        1229                GENERAL         N
## 3 3  Attendance        1229                GENERAL         N
## 4 4  Attendance        1229                GENERAL         N
## 5 5  Attendance        1229                GENERAL         N
## 6 6  Attendance        1059 MUSCULOSKELETALrelated         Y
##   Medical.Record.Number Gender Attendance.Day Attendance.MonthYear
## 1                   118 Female         Friday               May-23
## 2                   118 Female        Tuesday               May-23
## 3                   118 Female        Tuesday               May-23
## 4                   118 Female        Tuesday               May-23
## 5                   118 Female        Tuesday               Jun-23
## 6                   367   Male       Thursday               Apr-21
##   Attendance.Date Attendance.Type_recode Attendance.Year Attendance.Month
## 1      2020-05-12                 RETURN            2023              May
## 2      2020-05-16                 RETURN            2023              May
## 3      2020-05-23                 RETURN            2023              May
## 4      2020-05-30                 RETURN            2023              May
## 5      2020-06-20                 RETURN            2023             June
## 6      2020-04-08                    NEW            2021            April
##   Referral.Source_recode Consultant_recode Insurance.Scheme_recode
## 1         EMERGENCY DEPT             MOROP                       D
## 2         EMERGENCY DEPT            COLGAN                       D
## 3                 CLINIC            COLGAN                       D
## 4                 CLINIC            COLGAN                       D
## 5                 CLINIC            COLGAN                       D
## 6                     GP            SYNNOT                       D
##   Eligibility_recode Age.at.Attendance Age.at.Attendance.Cat.HSE Pathway.Number
## 1       MEDICAL CARD                78                   75 - 84       57091024
## 2       MEDICAL CARD                78                   75 - 84       57094901
## 3       MEDICAL CARD                78                   75 - 84       57094901
## 4       MEDICAL CARD                78                   75 - 84       57094901
## 5       MEDICAL CARD                78                   75 - 84       57094901
## 6       MEDICAL CARD                77                   75 - 84       56113762
##                            Present.Address
## 1    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 2    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 3    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 4    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 5    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11
## 6 599 CARNLOUGH ROAD, CABRA WEST, DUBLIN 7
##                               Home.Address Appointment.Date
## 1    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11             <NA>
## 2    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11             <NA>
## 3    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11             <NA>
## 4    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11             <NA>
## 5    23 CLOONLARA ROAD, FINGLAS, DUBLIN 11             <NA>
## 6 599 CARNLOUGH ROAD, CABRA WEST, DUBLIN 7             <NA>
##   appointmentMonthYear appointmentDay Area.of.Residence_recode
## 1                 <NA>           <NA>               DUBLIN NTH
## 2                 <NA>           <NA>               DUBLIN NTH
## 3                 <NA>           <NA>               DUBLIN NTH
## 4                 <NA>           <NA>               DUBLIN NTH
## 5                 <NA>           <NA>               DUBLIN NTH
## 6                 <NA>           <NA>               DUBLIN NTH
##   Referring.Hospital    Booking.Type_recode Booked.Date bookedMonthYear
## 1                  : C : New  Virtual Phone  2020-05-11        May 2020
## 2                  :                 RETURN  2020-05-12        May 2020
## 3                  :                 RETURN  2020-05-16        May 2020
## 4                  :                 RETURN  2020-05-24        May 2020
## 5                  :                 RETURN  2020-05-30        May 2020
## 6                  :                    NEW  2020-03-19        Mar 2020
##   bookedDay Cancellation.Group Reason.for.Cancellation_recode
## 1    Monday                N/A                               
## 2   Tuesday                N/A                               
## 3  Saturday                N/A                               
## 4    Sunday                N/A                               
## 5  Saturday                N/A                               
## 6  Thursday                N/A                               
##   Rebooked.Indicator Hospital.Catchment_recode No.Attendances New.Attendances
## 1                                        Mater              1               0
## 2                                        Mater              1               0
## 3                                        Mater              1               0
## 4                                        Mater              1               0
## 5                                        Mater              1               0
## 6                                        Mater              1               1
##   No.Cancels No.DNAs daysDiff_attendanceAppoint daysDiff_attendanceBooked
## 1         NA      NA                         NA                        -1
## 2         NA      NA                         NA                        -4
## 3         NA      NA                         NA                        -7
## 4         NA      NA                         NA                        -6
## 5         NA      NA                         NA                       -21
## 6         NA      NA                         NA                       -20
##   daysDiff_AppointBooked addressDiff
## 1                     NA           0
## 2                     NA           0
## 3                     NA           0
## 4                     NA           0
## 5                     NA           0
## 6                     NA           0
any(is.na(main_processed))
## [1] TRUE
colSums(is.na(main_processed))
##                              X                    Record.Type 
##                              0                              0 
##                    Clinic.Code             Clinic.Type_recode 
##                              0                              0 
##                      NurseFlag          Medical.Record.Number 
##                              0                              0 
##                         Gender                 Attendance.Day 
##                              0                              0 
##           Attendance.MonthYear                Attendance.Date 
##                              0                              0 
##         Attendance.Type_recode                Attendance.Year 
##                              0                              0 
##               Attendance.Month         Referral.Source_recode 
##                              0                              0 
##              Consultant_recode        Insurance.Scheme_recode 
##                              0                              0 
##             Eligibility_recode              Age.at.Attendance 
##                              0                              0 
##      Age.at.Attendance.Cat.HSE                 Pathway.Number 
##                              0                              0 
##                Present.Address                   Home.Address 
##                              0                              0 
##               Appointment.Date           appointmentMonthYear 
##                          56647                          56647 
##                 appointmentDay       Area.of.Residence_recode 
##                          56647                              0 
##             Referring.Hospital            Booking.Type_recode 
##                              0                              0 
##                    Booked.Date                bookedMonthYear 
##                           5680                           5680 
##                      bookedDay             Cancellation.Group 
##                           5680                              0 
## Reason.for.Cancellation_recode             Rebooked.Indicator 
##                              0                              0 
##      Hospital.Catchment_recode                 No.Attendances 
##                              0                          25896 
##                New.Attendances                     No.Cancels 
##                          25896                          56647 
##                        No.DNAs     daysDiff_attendanceAppoint 
##                          56647                          56647 
##      daysDiff_attendanceBooked         daysDiff_AppointBooked 
##                           5680                          56647 
##                    addressDiff 
##                              0

Creating descriptive statistics (2020-2023)

Outcome (response variable): Record.Type (including Attendance, Cancellation, DNA)

  1. Total No. of observations: 91169
  2. No. of Attendance: 55297; New Attendance: 30512
  3. No. of Cancellation: 27610
  4. No. of DNA: 8262

Dependable variables (with highest frequency of value):

  1. Clinic relevance
  • Clinic code :757 (12.79%), 1134 (12.72%)
  • Clinic type: Symptomatic spine clinic (48.66%)
  • M.R.N: 51 times is the highest visit
  • Referral source: Clinic (52.71%)
  • Consultant: WAL (27%), BAR (26%)
  • Insurance scheme: Unknown (36.57%)
  • Eligibility: Non medical card (53.08%)
  • Booking Type: Return (57.4%)
  • Hospital catchment: National catchment (57.91%)
  1. Date relevance
  • Attendance Day: Tuesday (26.6%)

  • Attendance Month-Year: 2021-09 (2.96%)

  • Attendance Month: September (10.2%)

  • Attendance Year: 2021 (27%)

  • Attendance Type: Return (49.64%)

  • Appointment Day: Tuesday (27.8%)

  • Appointment Month-Year: 2021-08 (3.42%)

  • Booked Day: Tuesday (22.57%)

  • Booked Month-Year: 2022-10 (2.78%)

  • Days difference between Attendance and Appointment: Mean 580, Median 730 [0-1096]

  • Days difference between Attendance and Booked day: Mean 506, Median 366 [<0,1112]

  • Days difference between Booked day and Appointment: Mean 91, Median 25 [0-672]

  1. Patient relevance
  • Gender: Female (98%)
  • Age at attendance cat.HSE: 45-54 (23.7%), Average 51 [0-105]
  • Area of residence: Dublin north (45.3%)
  • Difference of Home and Present address: No (82%)

Cancellation (N=27610)

  • Cancellation Group: Hospital (57.53%)
  • Reason for cancellation: by hospital (38.62%)
  • Rebooked indicator: Yes (74.5%)
## Outcome description
### Convert dependent variable (outcome, response var.) to factor type if not yet

cbind(sort(table(main_processed$Record.Type),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Record.Type=="Attendance")),5),deparse.level=2,decreasing=TRUE))
## Warning in cbind(sort(table(main_processed$Record.Type), decreasing = TRUE), :
## number of rows of result is not a multiple of vector length (arg 2)
##               [,1]   [,2]
## Attendance   56647 68.627
## Cancellation 17099 31.373
## DNA           8797 68.627
cbind(sort(table(main_processed$Record.Type=="Attendance"),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Record.Type=="Attendance")),5),deparse.level=2,decreasing=TRUE))
##        [,1]   [,2]
## TRUE  56647 68.627
## FALSE 25896 31.373
cbind(sort(table(main_processed$Record.Type=="Cancellation"),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Record.Type=="Cancellation")),5),deparse.level=2,decreasing=TRUE))
##        [,1]   [,2]
## FALSE 65444 79.285
## TRUE  17099 20.715
cbind(sort(table(main_processed$Record.Type=="DNA"),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Record.Type=="DNA")),5),deparse.level=2,decreasing=TRUE))
##        [,1]   [,2]
## FALSE 73746 89.343
## TRUE   8797 10.657
table(main_processed$Record.Type,main_processed$Attendance.MonthYear)
##               
##                Apr-20 Apr-21 Apr-22 Apr-23 Aug-20 Aug-21 Aug-22 Aug-23 Dec-20
##   Attendance      435    999   1152   1240    893   1131   1189   1514    938
##   Cancellation    591    296    419    334    324    292    432    319    251
##   DNA             103    166    206    161    127    254    188    174    188
##               
##                Dec-21 Dec-22 Dec-23 Feb-20 Feb-21 Feb-22 Feb-23 Jan-20 Jan-21
##   Attendance      989   1323   1178   1272    848   1133   1452   1347    846
##   Cancellation    371    299    298    300    419    376    278    108    545
##   DNA             205    156    143    205     94    203    151     79    159
##               
##                Jan-22 Jan-23 Jul-20 Jul-21 Jul-22 Jul-23 Jun-20 Jun-21 Jun-22
##   Attendance     1069   1584    937   1161   1193   1494    689   1114   1176
##   Cancellation    380    378    275    302    326    315    329    313    377
##   DNA             230    175     99    264    279    165    123    209    233
##               
##                Jun-23 Mar-20 Mar-21 Mar-22 Mar-23 May-20 May-21 May-22 May-23
##   Attendance     1501    779   1136   1144   1632    513   1060   1339   1579
##   Cancellation    314    735    349    476    305    359    334    418    373
##   DNA             118    247    146    220    155     82    192    260    156
##               
##                Nov-20 Nov-21 Nov-22 Nov-23 Oct-20 Oct-21 Oct-22 Oct-23 Sep-20
##   Attendance      998   1221   1621   1579   1002   1129   1427   1526   1061
##   Cancellation    315    384    371    349    296    325    327    347    427
##   DNA             141    285    177    173    191    232    178    176    213
##               
##                Sep-21 Sep-22 Sep-23
##   Attendance     1118   1397   1589
##   Cancellation    330    402    316
##   DNA             293    245    178
## Predictor description (categorical)

### Data frame for nominal/ binary values of variables

options(digits=2)
cbind(sort(table(main_processed$Clinic.Type_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Clinic.Type_recode)),5),deparse.level=2,decreasing=TRUE))
##                         [,1]  [,2]
## GENERAL                62429 75.63
## SPINErelated            9460 11.46
## MUSCULOSKELETALrelated  6632  8.04
## PODIATRY                1508  1.83
## UPPER_LIMBrelated       1092  1.32
## NotLocatedInMater        839  1.02
## BACK_PAINrelated         356  0.43
## NTPFfund                 227  0.27
cbind(sort(table(main_processed$Clinic.Code),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Clinic.Code)),5),deparse.level=2,decreasing=TRUE))
##       [,1]   [,2]
## 1038 12729 15.421
## 1229  7170  8.686
## 726   7025  8.511
## 1059  6474  7.843
## 1282  5228  6.334
## 786   4984  6.038
## 1341  4114  4.984
## 1206  4013  4.862
## 849   3385  4.101
## 1371  3339  4.045
## 1195  2902  3.516
## 444   2726  3.303
## 806   2669  3.233
## 1283  2603  3.154
## 1369  2587  3.134
## 1065  2458  2.978
## 1095  1508  1.827
## 1114  1230  1.490
## 416   1180  1.430
## 211    647  0.784
## 1383   449  0.544
## 846    361  0.437
## 1405   344  0.417
## 1207   343  0.416
## 847    307  0.372
## 184    297  0.360
## 1197   223  0.270
## 1448   199  0.241
## 778    192  0.233
## 1368   183  0.222
## 1363   142  0.172
## 524    102  0.124
## 1505    95  0.115
## 1498    84  0.102
## 1198    77  0.093
## 784     56  0.068
## 1467    46  0.056
## 1471    42  0.051
## 1031     7  0.008
## 854      6  0.007
## 1236     4  0.005
## 741      3  0.004
## 792      3  0.004
## 791      2  0.002
## 921      2  0.002
## 793      1  0.001
## 1284     1  0.001
## 1362     1  0.001
cbind(sort(table(main_processed$NurseFlag),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$NurseFlag)),5),deparse.level=2,decreasing=TRUE))
##    [,1] [,2]
## N 74545 90.3
## Y  7998  9.7
head(cbind(sort(table(main_processed$Medical.Record.Number),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Medical.Record.Number)),5),deparse.level=2,decreasing=TRUE)),10) #group freq of MRN at 34
##         [,1]  [,2]
## 288756   161 0.195
## 155594   155 0.188
## 981790   147 0.178
## 554658   110 0.133
## 547856   107 0.130
## 1193377   84 0.102
## 210363    79 0.096
## 587771    60 0.073
## 432736    56 0.068
## 1274389   52 0.063
cbind(sort(table(main_processed$Referral.Source_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Referral.Source_recode)),5),deparse.level=2,decreasing=TRUE))
##                      [,1] [,2]
## CLINIC              34796 42.2
## EMERGENCY DEPT      16125 19.5
## GP                  13796 16.7
## Elsew outside Mater  7522  9.1
## WARD                 6825  8.3
## Elsew of Mater       1814  2.2
## OTHER CONSULTANT     1665  2.0
#cbind(sort(table(main_processed$Referring.Hospital),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Referring.Hospital)),5),deparse.level=2,decreasing=TRUE))

cbind(sort(table(main_processed$Consultant_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Consultant_recode)),5),deparse.level=2,decreasing=TRUE))
##         [,1]   [,2]
## OHEIRE 10913 13.221
## MOROP  10210 12.369
## COLGAN  8857 10.730
## SYNNOT  6292  7.623
## XX      5739  6.953
## MORRI   5725  6.936
## LYONSF  5204  6.305
## BRIAIN  4840  5.864
## MARA    4795  5.809
## TIMLIN  4497  5.448
## ONEISH  3647  4.418
## BUTLER  3537  4.285
## CASSID  3230  3.913
## DODDSM  2467  2.989
## HYNESD  1148  1.391
## CASHMA   837  1.014
## MURMAR   230  0.279
## LYNCSA   200  0.242
## MCSORK   170  0.206
## ORTCON     3  0.004
## CARMOO     1  0.001
## FRA        1  0.001
cbind(sort(table(main_processed$Insurance.Scheme_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Insurance.Scheme_recode)),5),deparse.level=2,decreasing=TRUE))
##    [,1]   [,2]
## U 35556 43.076
## D 32629 39.530
## V  7056  8.548
## B  2473  2.996
## I  2123  2.572
## S  1145  1.387
## O   530  0.642
## G   427  0.517
## A   190  0.230
## P   130  0.157
## E   118  0.143
## H   100  0.121
## J    53  0.064
## C     7  0.008
## M     6  0.007
cbind(sort(table(main_processed$Eligibility_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Eligibility_recode)),5),deparse.level=2,decreasing=TRUE))
##                          [,1]   [,2]
## NON MEDICAL CARD        39208 47.500
## MEDICAL CARD            36831 44.620
## EXEMPT                   3518  4.262
## ELIGIBILITY UNKNOWN      1941  2.352
## ACUTE UNCLASSIFIED        830  1.006
## RESEARCH/NATIONAL PROG.   172  0.208
## NON ACUTE UNCLASSIFIED     41  0.050
## 15000+                      2  0.002
cbind(sort(table(main_processed$Booking.Type_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Booking.Type_recode)),5),deparse.level=2,decreasing=TRUE))
##                            [,1]   [,2]
## RETURN                    45287 54.865
## NEW                       26104 31.625
## WARD                       5635  6.827
## C : New  Virtual Phone     4846  5.871
## B : New  Virtual Video      652  0.790
## E : Return  Virtual Phone    15  0.018
## D : Return  Virtual Video     3  0.004
## V : REVIEW                    1  0.001
cbind(sort(table(main_processed$bookedDay),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$bookedDay)),5),deparse.level=2,decreasing=TRUE))
##            [,1] [,2]
## Monday    15432 20.1
## Tuesday   13990 18.2
## Sunday    12522 16.3
## Wednesday  9996 13.0
## Saturday   9156 11.9
## Friday     8542 11.1
## Thursday   7225  9.4
cbind(sort(table(main_processed$bookedMonthYear),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$bookedMonthYear)),5),deparse.level=2,decreasing=TRUE))
##          [,1] [,2]
## Jan 2020 7743 10.1
## Feb 2020 6893  9.0
## Sep 2020 6785  8.8
## Mar 2020 6604  8.6
## Jul 2020 6588  8.6
## Aug 2020 6586  8.6
## Oct 2020 6559  8.5
## Nov 2020 6534  8.5
## Jun 2020 6149  8.0
## May 2020 6096  7.9
## Apr 2020 5237  6.8
## Dec 2020 5089  6.6
cbind(sort(table(main_processed$appointmentDay),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$appointmentDay)),5),deparse.level=2,decreasing=TRUE))
##           [,1]   [,2]
## Wednesday 6248 24.127
## Monday    5625 21.722
## Thursday  5328 20.575
## Tuesday   4771 18.424
## Friday    3921 15.141
## Sunday       3  0.012
cbind(sort(table(main_processed$appointmentMonthYear),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$appointmentMonthYear)),5),deparse.level=2,decreasing=TRUE))
##          [,1] [,2]
## Mar 2020  982 3.79
## Jan 2021  704 2.72
## Mar 2022  696 2.69
## Apr 2020  694 2.68
## May 2022  678 2.62
## Nov 2021  669 2.58
## Sep 2022  647 2.50
## Sep 2020  640 2.47
## Apr 2022  625 2.41
## Sep 2021  623 2.41
## Aug 2022  620 2.39
## Jan 2022  610 2.36
## Jun 2022  610 2.36
## Jul 2022  605 2.34
## Feb 2022  579 2.24
## Dec 2021  576 2.22
## Jul 2021  566 2.19
## Oct 2021  557 2.15
## Jan 2023  553 2.14
## Nov 2022  548 2.12
## Aug 2021  546 2.11
## May 2023  529 2.04
## May 2021  527 2.04
## Oct 2023  523 2.02
## Nov 2023  522 2.02
## Jun 2021  521 2.01
## Feb 2021  513 1.98
## Feb 2020  505 1.95
## Oct 2022  505 1.95
## Apr 2023  495 1.91
## Mar 2021  495 1.91
## Sep 2023  494 1.91
## Aug 2023  493 1.90
## Oct 2020  487 1.88
## Jul 2023  480 1.85
## Apr 2021  462 1.78
## Mar 2023  460 1.78
## Nov 2020  456 1.76
## Dec 2022  455 1.76
## Jun 2020  452 1.75
## Aug 2020  451 1.74
## Dec 2023  441 1.70
## May 2020  441 1.70
## Dec 2020  439 1.70
## Jun 2023  432 1.67
## Feb 2023  429 1.66
## Jul 2020  374 1.44
## Jan 2020  187 0.72
cbind(sort(table(main_processed$Attendance.Type_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Attendance.Type_recode)),5),deparse.level=2,decreasing=TRUE))
##                      [,1]   [,2]
## RETURN              47699 57.787
## NEW                 28584 34.629
## VIRTUAL(New_Return)  5691  6.895
## VIRTUAL RETURN        402  0.487
##                       164  0.199
## EMERGENCY               3  0.004
cbind(sort(table(main_processed$Attendance.Day),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Attendance.Day)),5),deparse.level=2,decreasing=TRUE))
##            [,1]   [,2]
## Wednesday 18331 22.208
## Monday    17109 20.727
## Friday    16093 19.497
## Thursday  15540 18.827
## Tuesday   15462 18.732
## Sunday        7  0.008
## Saturday      1  0.001
cbind(sort(table(main_processed$Attendance.MonthYear),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Attendance.MonthYear)),5),deparse.level=2,decreasing=TRUE))
##        [,1] [,2]
## Nov-22 2169  2.6
## Jan-23 2137  2.6
## May-23 2108  2.6
## Nov-23 2101  2.5
## Mar-23 2092  2.5
## Sep-23 2083  2.5
## Oct-23 2049  2.5
## Sep-22 2044  2.5
## May-22 2017  2.4
## Aug-23 2007  2.4
## Jul-23 1974  2.4
## Jun-23 1933  2.3
## Oct-22 1932  2.3
## Nov-21 1890  2.3
## Feb-23 1881  2.3
## Mar-22 1840  2.2
## Aug-22 1809  2.2
## Jul-22 1798  2.2
## Jun-22 1786  2.2
## Dec-22 1778  2.2
## Apr-22 1777  2.2
## Feb-20 1777  2.2
## Mar-20 1761  2.1
## Sep-21 1741  2.1
## Apr-23 1735  2.1
## Jul-21 1727  2.1
## Feb-22 1712  2.1
## Sep-20 1701  2.1
## Oct-21 1686  2.0
## Jan-22 1679  2.0
## Aug-21 1677  2.0
## Jun-21 1636  2.0
## Mar-21 1631  2.0
## Dec-23 1619  2.0
## May-21 1586  1.9
## Dec-21 1565  1.9
## Jan-21 1550  1.9
## Jan-20 1534  1.9
## Oct-20 1489  1.8
## Apr-21 1461  1.8
## Nov-20 1454  1.8
## Dec-20 1377  1.7
## Feb-21 1361  1.6
## Aug-20 1344  1.6
## Jul-20 1311  1.6
## Jun-20 1141  1.4
## Apr-20 1129  1.4
## May-20  954  1.2
cbind(sort(table(main_processed$Attendance.Month),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Attendance.Month)),5),deparse.level=2,decreasing=TRUE))
##           [,1] [,2]
## November  7614  9.2
## September 7569  9.2
## March     7324  8.9
## October   7156  8.7
## January   6900  8.4
## August    6837  8.3
## July      6810  8.2
## February  6731  8.2
## May       6665  8.1
## June      6496  7.9
## December  6339  7.7
## April     6102  7.4
cbind(sort(table(main_processed$Attendance.Year),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Attendance.Year)),5),deparse.level=2,decreasing=TRUE))
##       [,1] [,2]
## 2023 23719   29
## 2022 22341   27
## 2021 19511   24
## 2020 16972   21
cbind(sort(table(main_processed$No.Attendances),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$No.Attendances)),5),deparse.level=2,decreasing=TRUE))
##    [,1]  [,2]
## 1 56640 1e+02
## 2     5 9e-03
## 3     2 4e-03
cbind(sort(table(main_processed$New.Attendances),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$New.Attendances)),5),deparse.level=2,decreasing=TRUE))
##    [,1] [,2]
## 0 34655   61
## 1 21992   39
cbind(sort(table(main_processed$No.Cancels),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$No.Cancels)),5),deparse.level=2,decreasing=TRUE))
##    [,1] [,2]
## 1 17099   66
## 0  8797   34
cbind(sort(table(main_processed$Cancellation.Group),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Cancellation.Group)),5),deparse.level=2,decreasing=TRUE))
##             [,1] [,2]
## N/A        56647 68.6
## Hospital   10259 12.4
## DNA         8797 10.7
## Patient     5716  6.9
## Validation  1124  1.4
cbind(sort(table(main_processed$Reason.for.Cancellation_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Reason.for.Cancellation_recode)),5),deparse.level=2,decreasing=TRUE))
##                               [,1] [,2]
##                              56647 68.6
## No show                       8797 10.7
## By Patient                    4985  6.0
## By Cslt/AN/Tech               4393  5.3
## By Hospital                   3696  4.5
## By Covid                      2691  3.3
## By Patient-health conditions  1334  1.6
cbind(sort(table(main_processed$Rebooked.Indicator),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Rebooked.Indicator)),5),deparse.level=2,decreasing=TRUE))
##      [,1] [,2]
##     56647   69
## No  16603   20
## Yes  9293   11
cbind(sort(table(main_processed$Hospital.Catchment_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Hospital.Catchment_recode)),5),deparse.level=2,decreasing=TRUE))
##                [,1]  [,2]
## Mater         38988 47.23
## National      24245 29.37
## James          5422  6.57
## Connolly       4360  5.28
## Beaumont       3669  4.45
## Vincents       3589  4.35
## Tallaght       1853  2.25
## International   417  0.50
cbind(sort(table(main_processed$Gender),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Gender)),5),deparse.level=2,decreasing=TRUE))
##          [,1]  [,2]
## Female  41481 5e+01
## Male    41056 5e+01
## Unknown     6 7e-03
cbind(sort(table(main_processed$Area.of.Residence_recode),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Area.of.Residence_recode)),5),deparse.level=2,decreasing=TRUE))
##                                         [,1]  [,2]
## DUBLIN NTH                             53149 64.39
## EASTERN & MIDLAND REGION (excl.Dublin) 11091 13.44
## DUBLIN STH                             10918 13.23
## SOUTHERN REGION                         3999  4.84
## NORTHERN WESTERN REGION                 2918  3.54
## UNKNOWN                                  331  0.40
## OUTSIDE IRELAND                          137  0.17
cbind(sort(table(main_processed$addressDiff),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$addressDiff)),5),deparse.level=2,decreasing=TRUE))
##    [,1] [,2]
## 0 70120   85
## 1 12423   15
cbind(sort(table(main_processed$Age.at.Attendance.Cat.HSE),decreasing=TRUE),sort(100*round(prop.table(table(main_processed$Age.at.Attendance.Cat.HSE)),5),deparse.level=2,decreasing=TRUE))
##          [,1]   [,2]
## 55 - 64 14948 18.109
## 45 - 54 14508 17.576
## 35 - 44 12611 15.278
## 65 - 74 11913 14.432
## 25 - 34 11585 14.035
## 15 - 24  9032 10.942
## 75 - 84  6236  7.555
## 85 >=    1686  2.043
## Oct-14     14  0.017
## 0 - 4       9  0.011
## 05-Sep      1  0.001
## Predictor description (numeric)
summary(main_processed$Age.at.Attendance)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       0      34      50      50      64     105
stat.desc(main_processed$Age.at.Attendance, basic=F)
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##       50.000       49.637        0.065        0.126      343.618       18.537 
##     coef.var 
##        0.373
skew(main_processed$Age.at.Attendance)
## skew (g1)        se         z         p 
##    0.0235    0.0085    2.7506    0.0059
kurtosis(main_processed$Age.at.Attendance)
## [1] -0.89
summary(main_processed$daysDiff_attendanceAppoint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##      -1     365     730     545     731    1096   56647
stat.desc(main_processed$daysDiff_attendanceAppoint, basic=F)
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##      7.3e+02      5.5e+02      2.5e+00      4.8e+00      1.6e+05      4.0e+02 
##     coef.var 
##      7.3e-01
skew(main_processed$daysDiff_attendanceAppoint)
## Warning in skew(main_processed$daysDiff_attendanceAppoint): Missing
## observations are removed from a vector.
## skew (g1)        se         z         p 
##   -0.0062    0.0152   -0.4084    0.6830
kurtosis(main_processed$daysDiff_attendanceAppoint)
## [1] -1.3
summary(main_processed$daysDiff_attendanceBooked)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    -350     -34     -15      -6      -6     362    5680
stat.desc(main_processed$daysDiff_attendanceBooked, basic=F)
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##       -15.00        -6.07         0.33         0.65      8489.97        92.14 
##     coef.var 
##       -15.17
skew(main_processed$daysDiff_attendanceBooked)
## Warning in skew(main_processed$daysDiff_attendanceBooked): Missing observations
## are removed from a vector.
## skew (g1)        se         z         p 
##   2.4e+00   8.8e-03   2.7e+02   0.0e+00
kurtosis(main_processed$daysDiff_attendanceBooked)
## [1] 6.8
summary(main_processed$daysDiff_AppointBooked)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   -1424    -814    -485    -557    -137       0   56647
stat.desc(main_processed$daysDiff_AppointBooked, basic=F)
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##     -4.8e+02     -5.6e+02      2.5e+00      4.8e+00      1.6e+05      4.0e+02 
##     coef.var 
##     -7.1e-01
skew(main_processed$daysDiff_AppointBooked)
## Warning in skew(main_processed$daysDiff_AppointBooked): Missing observations
## are removed from a vector.
## skew (g1)        se         z         p 
##  -8.8e-02   1.5e-02  -5.8e+00   7.0e-09
kurtosis(main_processed$daysDiff_AppointBooked)
## [1] -1.3

## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Use of `main_processed$Age.at.Attendance` is discouraged.
## ℹ Use `Age.at.Attendance` instead.
## Use of `main_processed$Age.at.Attendance` is discouraged.
## ℹ Use `Age.at.Attendance` instead.

## Warning: Use of `main_processed$Record.Type` is discouraged.
## ℹ Use `Record.Type` instead.

## Warning: Removed 25896 rows containing non-finite values (`stat_count()`).

## <ggproto object: Class ScaleDiscrete, Scale, gg>
##     aesthetics: fill
##     axis_order: function
##     break_info: function
##     break_positions: function
##     breaks: waiver
##     call: call
##     clone: function
##     dimension: function
##     drop: TRUE
##     expand: waiver
##     get_breaks: function
##     get_breaks_minor: function
##     get_labels: function
##     get_limits: function
##     guide: legend
##     is_discrete: function
##     is_empty: function
##     labels:  General
##     limits: NULL
##     make_sec_title: function
##     make_title: function
##     map: function
##     map_df: function
##     n.breaks.cache: NULL
##     na.translate: TRUE
##     na.value: grey50
##     name: waiver
##     palette: function
##     palette.cache: NULL
##     position: left
##     range: environment
##     rescale: function
##     reset: function
##     scale_name: hue
##     train: function
##     train_df: function
##     transform: function
##     transform_df: function
##     super:  <ggproto object: Class ScaleDiscrete, Scale, gg>

## Warning: Removed 5517 rows containing non-finite values (`stat_count()`).

## Warning: Removed 5680 rows containing non-finite values (`stat_count()`).

## Warning: Removed 56650 rows containing non-finite values (`stat_count()`).

## Warning: Removed 569 rows containing non-finite values (`stat_count()`).

## [1] "character"

## List of 11
##  $ call      : language qcc(data = bookedMonthYear_tb$freq, type = "u", sizes = bookedMonthYear_tb$freq,      labels = bookedMonthYear_tb| __truncated__
##  $ type      : chr "u"
##  $ data.name : chr "bookedMonthYear_tb$freq"
##  $ data      : int [1:12, 1] 5237 6586 5089 6893 7743 6588 6149 6604 6096 6534 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "names")= chr [1:12] "Apr 2020" "Aug 2020" "Dec 2020" "Feb 2020" ...
##  $ sizes     : int [1:12] 5237 6586 5089 6893 7743 6588 6149 6604 6096 6534 ...
##  $ center    : num 1
##  $ std.dev   : num 1
##  $ nsigmas   : num 3
##  $ limits    : num [1:12, 1:2] 0.959 0.963 0.958 0.964 0.966 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = bookedMonthYear_tb$freq, type = "c", labels = bookedMonthYear_tb$month,      plot = T)
##  $ type      : chr "c"
##  $ data.name : chr "bookedMonthYear_tb$freq"
##  $ data      : int [1:12, 1] 5237 6586 5089 6893 7743 6588 6149 6604 6096 6534 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named int [1:12] 5237 6586 5089 6893 7743 6588 6149 6604 6096 6534 ...
##   ..- attr(*, "names")= chr [1:12] "Apr 2020" "Aug 2020" "Dec 2020" "Feb 2020" ...
##  $ sizes     : int [1:12] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 6405
##  $ std.dev   : num 80
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 6165 6645
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = appointmentMonthYear_tb$freq, type = "u", sizes = appointmentMonthYear_tb$freq,      labels = appointm| __truncated__
##  $ type      : chr "u"
##  $ data.name : chr "appointmentMonthYear_tb$freq"
##  $ data      : int [1:48, 1] 694 462 625 495 451 546 620 493 439 576 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "names")= chr [1:48] "Apr 2020" "Apr 2021" "Apr 2022" "Apr 2023" ...
##  $ sizes     : int [1:48] 694 462 625 495 451 546 620 493 439 576 ...
##  $ center    : num 1
##  $ std.dev   : num 1
##  $ nsigmas   : num 3
##  $ limits    : num [1:48, 1:2] 0.886 0.86 0.88 0.865 0.859 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = appointmentMonthYear_tb$freq, type = "c", labels = appointmentMonthYear_tb$month,      plot = T)
##  $ type      : chr "c"
##  $ data.name : chr "appointmentMonthYear_tb$freq"
##  $ data      : int [1:48, 1] 694 462 625 495 451 546 620 493 439 576 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named int [1:48] 694 462 625 495 451 546 620 493 439 576 ...
##   ..- attr(*, "names")= chr [1:48] "Apr 2020" "Apr 2021" "Apr 2022" "Apr 2023" ...
##  $ sizes     : int [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 540
##  $ std.dev   : num 23.2
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 470 609
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = attendanceMonthYear_tb$freq, type = "u", sizes = attendanceMonthYear_tb$freq,      labels = attendance| __truncated__
##  $ type      : chr "u"
##  $ data.name : chr "attendanceMonthYear_tb$freq"
##  $ data      : int [1:48, 1] 1129 1461 1777 1735 1344 1677 1809 2007 1377 1565 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "names")= chr [1:48] "Apr-20" "Apr-21" "Apr-22" "Apr-23" ...
##  $ sizes     : int [1:48] 1129 1461 1777 1735 1344 1677 1809 2007 1377 1565 ...
##  $ center    : num 1
##  $ std.dev   : num 1
##  $ nsigmas   : num 3
##  $ limits    : num [1:48, 1:2] 0.911 0.922 0.929 0.928 0.918 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = attendanceMonthYear_tb$freq, type = "c", labels = attendanceMonthYear_tb$month,      plot = T)
##  $ type      : chr "c"
##  $ data.name : chr "attendanceMonthYear_tb$freq"
##  $ data      : int [1:48, 1] 1129 1461 1777 1735 1344 1677 1809 2007 1377 1565 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named int [1:48] 1129 1461 1777 1735 1344 1677 1809 2007 1377 1565 ...
##   ..- attr(*, "names")= chr [1:48] "Apr-20" "Apr-21" "Apr-22" "Apr-23" ...
##  $ sizes     : int [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 1720
##  $ std.dev   : num 41.5
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 1595 1844
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = cancelledMonthYear_tb$Freq, type = "u", sizes = cancelledMonthYear_tb$Freq,      labels = cancelledMon| __truncated__
##  $ type      : chr "u"
##  $ data.name : chr "cancelledMonthYear_tb$Freq"
##  $ data      : int [1:48, 1] 591 296 419 334 324 292 432 319 251 371 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "names")= chr [1:48] "Apr 2020" "Apr 2021" "Apr 2022" "Apr 2023" ...
##  $ sizes     : int [1:48] 591 296 419 334 324 292 432 319 251 371 ...
##  $ center    : num 1
##  $ std.dev   : num 1
##  $ nsigmas   : num 3
##  $ limits    : num [1:48, 1:2] 0.877 0.826 0.853 0.836 0.833 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = cancelledMonthYear_tb$Freq, type = "c", labels = cancelledMonthYear_tb$month,      plot = T)
##  $ type      : chr "c"
##  $ data.name : chr "cancelledMonthYear_tb$Freq"
##  $ data      : int [1:48, 1] 591 296 419 334 324 292 432 319 251 371 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named int [1:48] 591 296 419 334 324 292 432 319 251 371 ...
##   ..- attr(*, "names")= chr [1:48] "Apr 2020" "Apr 2021" "Apr 2022" "Apr 2023" ...
##  $ sizes     : int [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 356
##  $ std.dev   : num 18.9
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 300 413
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = dnaMonthYear_tb$Freq, type = "u", sizes = dnaMonthYear_tb$Freq,      labels = dnaMonthYear_tb$month, plot = T)
##  $ type      : chr "u"
##  $ data.name : chr "dnaMonthYear_tb$Freq"
##  $ data      : int [1:48, 1] 103 166 206 161 127 254 188 174 188 205 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named num [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "names")= chr [1:48] "Apr 2020" "Apr 2021" "Apr 2022" "Apr 2023" ...
##  $ sizes     : int [1:48] 103 166 206 161 127 254 188 174 188 205 ...
##  $ center    : num 1
##  $ std.dev   : num 1
##  $ nsigmas   : num 3
##  $ limits    : num [1:48, 1:2] 0.704 0.767 0.791 0.764 0.734 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## List of 11
##  $ call      : language qcc(data = dnaMonthYear_tb$Freq, type = "c", labels = dnaMonthYear_tb$month,      plot = T)
##  $ type      : chr "c"
##  $ data.name : chr "dnaMonthYear_tb$Freq"
##  $ data      : int [1:48, 1] 103 166 206 161 127 254 188 174 188 205 ...
##   ..- attr(*, "dimnames")=List of 2
##  $ statistics: Named int [1:48] 103 166 206 161 127 254 188 174 188 205 ...
##   ..- attr(*, "names")= chr [1:48] "Apr 2020" "Apr 2021" "Apr 2022" "Apr 2023" ...
##  $ sizes     : int [1:48] 1 1 1 1 1 1 1 1 1 1 ...
##  $ center    : num 183
##  $ std.dev   : num 13.5
##  $ nsigmas   : num 3
##  $ limits    : num [1, 1:2] 143 224
##   ..- attr(*, "dimnames")=List of 2
##  $ violations:List of 2
##  - attr(*, "class")= chr "qcc"

## Warning: tz(): Don't know how to compute timezone for object of class factor;
## returning "UTC".
## Warning: tz(): Don't know how to compute timezone for object of class factor;
## returning "UTC".

## Warning: tz(): Don't know how to compute timezone for object of class factor;
## returning "UTC".

## Warning: tz(): Don't know how to compute timezone for object of class factor;
## returning "UTC".

## Warning: tz(): Don't know how to compute timezone for object of class factor;
## returning "UTC".

## Warning: tz(): Don't know how to compute timezone for object of class factor;
## returning "UTC".

Correlation of outcome and predictor (nominal and nominal)

Total No. correlation

 ## Record Type & Clinic relevance
#library(dplyr)
CrossTable(main_processed$Clinic.Type_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                   | main_processed$Record.Type 
## main_processed$Clinic.Type_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                  BACK_PAINrelated |          188 |          152 |           16 |          356 | 
##                                   |       244.31 |        73.75 |        37.94 |              | 
##                                   |        12.98 |        83.04 |        12.69 |              | 
##                                   |         0.53 |         0.43 |         0.04 |         0.00 | 
##                                   |         0.00 |         0.01 |         0.00 |              | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                           GENERAL |        44958 |        10696 |         6775 |        62429 | 
##                                   |     42843.31 |     12932.33 |      6653.36 |              | 
##                                   |       104.38 |       386.72 |         2.22 |              | 
##                                   |         0.72 |         0.17 |         0.11 |         0.76 | 
##                                   |         0.79 |         0.63 |         0.77 |              | 
##                                   |         0.54 |         0.13 |         0.08 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##            MUSCULOSKELETALrelated |         3846 |         2014 |          772 |         6632 | 
##                                   |      4551.36 |      1373.84 |       706.80 |              | 
##                                   |       109.32 |       298.30 |         6.01 |              | 
##                                   |         0.58 |         0.30 |         0.12 |         0.08 | 
##                                   |         0.07 |         0.12 |         0.09 |              | 
##                                   |         0.05 |         0.02 |         0.01 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                 NotLocatedInMater |          525 |          225 |           89 |          839 | 
##                                   |       575.78 |       173.80 |        89.42 |              | 
##                                   |         4.48 |        15.08 |         0.00 |              | 
##                                   |         0.63 |         0.27 |         0.11 |         0.01 | 
##                                   |         0.01 |         0.01 |         0.01 |              | 
##                                   |         0.01 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                          NTPFfund |           97 |           70 |           60 |          227 | 
##                                   |       155.78 |        47.02 |        24.19 |              | 
##                                   |        22.18 |        11.23 |        53.00 |              | 
##                                   |         0.43 |         0.31 |         0.26 |         0.00 | 
##                                   |         0.00 |         0.00 |         0.01 |              | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                          PODIATRY |         1312 |           64 |          132 |         1508 | 
##                                   |      1034.90 |       312.39 |       160.71 |              | 
##                                   |        74.20 |       197.50 |         5.13 |              | 
##                                   |         0.87 |         0.04 |         0.09 |         0.02 | 
##                                   |         0.02 |         0.00 |         0.02 |              | 
##                                   |         0.02 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                      SPINErelated |         5061 |         3566 |          833 |         9460 | 
##                                   |      6492.14 |      1959.66 |      1008.20 |              | 
##                                   |       315.48 |      1316.71 |        30.44 |              | 
##                                   |         0.53 |         0.38 |         0.09 |         0.11 | 
##                                   |         0.09 |         0.21 |         0.09 |              | 
##                                   |         0.06 |         0.04 |         0.01 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                 UPPER_LIMBrelated |          660 |          312 |          120 |         1092 | 
##                                   |       749.41 |       226.21 |       116.38 |              | 
##                                   |        10.67 |        32.54 |         0.11 |              | 
##                                   |         0.60 |         0.29 |         0.11 |         0.01 | 
##                                   |         0.01 |         0.02 |         0.01 |              | 
##                                   |         0.01 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                      Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                   |         0.69 |         0.21 |         0.11 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  3104     d.f. =  14     p =  0 
## 
## 
## 
CrossTable(main_processed$Clinic.Code, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                            | main_processed$Record.Type 
## main_processed$Clinic.Code |   Attendance | Cancellation |          DNA |    Row Total | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        184 |          167 |          108 |           22 |          297 | 
##                            |       203.82 |        61.52 |        31.65 |              | 
##                            |         6.65 |        35.11 |         2.94 |              | 
##                            |         0.56 |         0.36 |         0.07 |         0.00 | 
##                            |         0.00 |         0.01 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        211 |          370 |          186 |           91 |          647 | 
##                            |       444.02 |       134.03 |        68.95 |              | 
##                            |        12.34 |        20.15 |         7.05 |              | 
##                            |         0.57 |         0.29 |         0.14 |         0.01 | 
##                            |         0.01 |         0.01 |         0.01 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        416 |          693 |          318 |          169 |         1180 | 
##                            |       809.80 |       244.44 |       125.76 |              | 
##                            |        16.85 |        22.14 |        14.87 |              | 
##                            |         0.59 |         0.27 |         0.14 |         0.01 | 
##                            |         0.01 |         0.02 |         0.02 |              | 
##                            |         0.01 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        444 |         2065 |          396 |          265 |         2726 | 
##                            |      1870.78 |       564.70 |       290.52 |              | 
##                            |        20.16 |        50.40 |         2.24 |              | 
##                            |         0.76 |         0.15 |         0.10 |         0.03 | 
##                            |         0.04 |         0.02 |         0.03 |              | 
##                            |         0.03 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        524 |          102 |            0 |            0 |          102 | 
##                            |        70.00 |        21.13 |        10.87 |              | 
##                            |        14.63 |        21.13 |        10.87 |              | 
##                            |         1.00 |         0.00 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        726 |         5066 |         1155 |          804 |         7025 | 
##                            |      4821.07 |      1455.25 |       748.69 |              | 
##                            |        12.44 |        61.95 |         4.09 |              | 
##                            |         0.72 |         0.16 |         0.11 |         0.09 | 
##                            |         0.09 |         0.07 |         0.09 |              | 
##                            |         0.06 |         0.01 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        741 |            2 |            1 |            0 |            3 | 
##                            |         2.06 |         0.62 |         0.32 |              | 
##                            |         0.00 |         0.23 |         0.32 |              | 
##                            |         0.67 |         0.33 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        778 |          119 |           67 |            6 |          192 | 
##                            |       131.76 |        39.77 |        20.46 |              | 
##                            |         1.24 |        18.64 |        10.22 |              | 
##                            |         0.62 |         0.35 |         0.03 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        784 |           29 |           18 |            9 |           56 | 
##                            |        38.43 |        11.60 |         5.97 |              | 
##                            |         2.31 |         3.53 |         1.54 |              | 
##                            |         0.52 |         0.32 |         0.16 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        786 |         2801 |         1697 |          486 |         4984 | 
##                            |      3420.38 |      1032.45 |       531.17 |              | 
##                            |       112.16 |       427.75 |         3.84 |              | 
##                            |         0.56 |         0.34 |         0.10 |         0.06 | 
##                            |         0.05 |         0.10 |         0.06 |              | 
##                            |         0.03 |         0.02 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        791 |            1 |            1 |            0 |            2 | 
##                            |         1.37 |         0.41 |         0.21 |              | 
##                            |         0.10 |         0.83 |         0.21 |              | 
##                            |         0.50 |         0.50 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        792 |            3 |            0 |            0 |            3 | 
##                            |         2.06 |         0.62 |         0.32 |              | 
##                            |         0.43 |         0.62 |         0.32 |              | 
##                            |         1.00 |         0.00 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        793 |            1 |            0 |            0 |            1 | 
##                            |         0.69 |         0.21 |         0.11 |              | 
##                            |         0.14 |         0.21 |         0.11 |              | 
##                            |         1.00 |         0.00 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        806 |         1701 |          759 |          209 |         2669 | 
##                            |      1831.66 |       552.89 |       284.45 |              | 
##                            |         9.32 |        76.83 |        20.01 |              | 
##                            |         0.64 |         0.28 |         0.08 |         0.03 | 
##                            |         0.03 |         0.04 |         0.02 |              | 
##                            |         0.02 |         0.01 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        846 |          256 |           77 |           28 |          361 | 
##                            |       247.74 |        74.78 |        38.47 |              | 
##                            |         0.28 |         0.07 |         2.85 |              | 
##                            |         0.71 |         0.21 |         0.08 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        847 |           97 |          201 |            9 |          307 | 
##                            |       210.69 |        63.60 |        32.72 |              | 
##                            |        61.34 |       296.87 |        17.19 |              | 
##                            |         0.32 |         0.65 |         0.03 |         0.00 | 
##                            |         0.00 |         0.01 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        849 |         1701 |         1375 |          309 |         3385 | 
##                            |      2323.03 |       701.21 |       360.76 |              | 
##                            |       166.56 |       647.44 |         7.43 |              | 
##                            |         0.50 |         0.41 |         0.09 |         0.04 | 
##                            |         0.03 |         0.08 |         0.04 |              | 
##                            |         0.02 |         0.02 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        854 |            6 |            0 |            0 |            6 | 
##                            |         4.12 |         1.24 |         0.64 |              | 
##                            |         0.86 |         1.24 |         0.64 |              | 
##                            |         1.00 |         0.00 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                        921 |            0 |            0 |            2 |            2 | 
##                            |         1.37 |         0.41 |         0.21 |              | 
##                            |         1.37 |         0.41 |        14.98 |              | 
##                            |         0.00 |         0.00 |         1.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1031 |            2 |            4 |            1 |            7 | 
##                            |         4.80 |         1.45 |         0.75 |              | 
##                            |         1.64 |         4.48 |         0.09 |              | 
##                            |         0.29 |         0.57 |         0.14 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1038 |        10260 |         1163 |         1306 |        12729 | 
##                            |      8735.56 |      2636.85 |      1356.59 |              | 
##                            |       266.03 |       823.80 |         1.89 |              | 
##                            |         0.81 |         0.09 |         0.10 |         0.15 | 
##                            |         0.18 |         0.07 |         0.15 |              | 
##                            |         0.12 |         0.01 |         0.02 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1059 |         3732 |         1982 |          760 |         6474 | 
##                            |      4442.93 |      1341.11 |       689.96 |              | 
##                            |       113.76 |       306.27 |         7.11 |              | 
##                            |         0.58 |         0.31 |         0.12 |         0.08 | 
##                            |         0.07 |         0.12 |         0.09 |              | 
##                            |         0.05 |         0.02 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1065 |         1355 |          827 |          276 |         2458 | 
##                            |      1686.86 |       509.18 |       261.96 |              | 
##                            |        65.29 |       198.37 |         0.75 |              | 
##                            |         0.55 |         0.34 |         0.11 |         0.03 | 
##                            |         0.02 |         0.05 |         0.03 |              | 
##                            |         0.02 |         0.01 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1095 |         1312 |           64 |          132 |         1508 | 
##                            |      1034.90 |       312.39 |       160.71 |              | 
##                            |        74.20 |       197.50 |         5.13 |              | 
##                            |         0.87 |         0.04 |         0.09 |         0.02 | 
##                            |         0.02 |         0.00 |         0.02 |              | 
##                            |         0.02 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1114 |          438 |          673 |          119 |         1230 | 
##                            |       844.12 |       254.80 |       131.09 |              | 
##                            |       195.39 |       686.40 |         1.11 |              | 
##                            |         0.36 |         0.55 |         0.10 |         0.01 | 
##                            |         0.01 |         0.04 |         0.01 |              | 
##                            |         0.01 |         0.01 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1195 |         1429 |         1269 |          204 |         2902 | 
##                            |      1991.56 |       601.16 |       309.28 |              | 
##                            |       158.91 |       741.93 |        35.84 |              | 
##                            |         0.49 |         0.44 |         0.07 |         0.04 | 
##                            |         0.03 |         0.07 |         0.02 |              | 
##                            |         0.02 |         0.02 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1197 |           97 |           66 |           60 |          223 | 
##                            |       153.04 |        46.20 |        23.77 |              | 
##                            |        20.52 |         8.49 |        55.24 |              | 
##                            |         0.43 |         0.30 |         0.27 |         0.00 | 
##                            |         0.00 |         0.00 |         0.01 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1198 |           21 |           56 |            0 |           77 | 
##                            |        52.84 |        15.95 |         8.21 |              | 
##                            |        19.19 |       100.56 |         8.21 |              | 
##                            |         0.27 |         0.73 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1206 |         2996 |          565 |          452 |         4013 | 
##                            |      2754.01 |       831.30 |       427.68 |              | 
##                            |        21.26 |        85.31 |         1.38 |              | 
##                            |         0.75 |         0.14 |         0.11 |         0.05 | 
##                            |         0.05 |         0.03 |         0.05 |              | 
##                            |         0.04 |         0.01 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1207 |          188 |          126 |           29 |          343 | 
##                            |       235.39 |        71.05 |        36.56 |              | 
##                            |         9.54 |        42.49 |         1.56 |              | 
##                            |         0.55 |         0.37 |         0.08 |         0.00 | 
##                            |         0.00 |         0.01 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1229 |         5384 |          846 |          940 |         7170 | 
##                            |      4920.57 |      1485.28 |       764.14 |              | 
##                            |        43.65 |       275.16 |        40.47 |              | 
##                            |         0.75 |         0.12 |         0.13 |         0.09 | 
##                            |         0.10 |         0.05 |         0.11 |              | 
##                            |         0.07 |         0.01 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1236 |            0 |            4 |            0 |            4 | 
##                            |         2.75 |         0.83 |         0.43 |              | 
##                            |         2.75 |        12.14 |         0.43 |              | 
##                            |         0.00 |         1.00 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1282 |         4119 |          535 |          574 |         5228 | 
##                            |      3587.83 |      1082.99 |       557.17 |              | 
##                            |        78.64 |       277.28 |         0.51 |              | 
##                            |         0.79 |         0.10 |         0.11 |         0.06 | 
##                            |         0.07 |         0.03 |         0.07 |              | 
##                            |         0.05 |         0.01 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1283 |         1352 |          991 |          260 |         2603 | 
##                            |      1786.37 |       539.22 |       277.41 |              | 
##                            |       105.62 |       378.52 |         1.09 |              | 
##                            |         0.52 |         0.38 |         0.10 |         0.03 | 
##                            |         0.02 |         0.06 |         0.03 |              | 
##                            |         0.02 |         0.01 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1284 |            0 |            0 |            1 |            1 | 
##                            |         0.69 |         0.21 |         0.11 |              | 
##                            |         0.69 |         0.21 |         7.49 |              | 
##                            |         0.00 |         0.00 |         1.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1341 |         3160 |          497 |          457 |         4114 | 
##                            |      2823.33 |       852.23 |       438.45 |              | 
##                            |        40.15 |       148.07 |         0.78 |              | 
##                            |         0.77 |         0.12 |         0.11 |         0.05 | 
##                            |         0.06 |         0.03 |         0.05 |              | 
##                            |         0.04 |         0.01 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1362 |            0 |            1 |            0 |            1 | 
##                            |         0.69 |         0.21 |         0.11 |              | 
##                            |         0.69 |         3.03 |         0.11 |              | 
##                            |         0.00 |         1.00 |         0.00 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1363 |          101 |           30 |           11 |          142 | 
##                            |        97.45 |        29.42 |        15.13 |              | 
##                            |         0.13 |         0.01 |         1.13 |              | 
##                            |         0.71 |         0.21 |         0.08 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1368 |           96 |           76 |           11 |          183 | 
##                            |       125.59 |        37.91 |        19.50 |              | 
##                            |         6.97 |        38.27 |         3.71 |              | 
##                            |         0.52 |         0.42 |         0.06 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1369 |         2080 |          270 |          237 |         2587 | 
##                            |      1775.39 |       535.90 |       275.71 |              | 
##                            |        52.26 |       131.94 |         5.43 |              | 
##                            |         0.80 |         0.10 |         0.09 |         0.03 | 
##                            |         0.04 |         0.02 |         0.03 |              | 
##                            |         0.03 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1371 |         2522 |          398 |          419 |         3339 | 
##                            |      2291.46 |       691.68 |       355.85 |              | 
##                            |        23.19 |       124.70 |        11.21 |              | 
##                            |         0.76 |         0.12 |         0.13 |         0.04 | 
##                            |         0.04 |         0.02 |         0.05 |              | 
##                            |         0.03 |         0.00 |         0.01 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1383 |          296 |          121 |           32 |          449 | 
##                            |       308.14 |        93.01 |        47.85 |              | 
##                            |         0.48 |         8.42 |         5.25 |              | 
##                            |         0.66 |         0.27 |         0.07 |         0.01 | 
##                            |         0.01 |         0.01 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1405 |          210 |           94 |           40 |          344 | 
##                            |       236.08 |        71.26 |        36.66 |              | 
##                            |         2.88 |         7.26 |         0.30 |              | 
##                            |         0.61 |         0.27 |         0.12 |         0.00 | 
##                            |         0.00 |         0.01 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1448 |          138 |           38 |           23 |          199 | 
##                            |       136.57 |        41.22 |        21.21 |              | 
##                            |         0.02 |         0.25 |         0.15 |              | 
##                            |         0.69 |         0.19 |         0.12 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1467 |           19 |           10 |           17 |           46 | 
##                            |        31.57 |         9.53 |         4.90 |              | 
##                            |         5.00 |         0.02 |        29.85 |              | 
##                            |         0.41 |         0.22 |         0.37 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1471 |           25 |           11 |            6 |           42 | 
##                            |        28.82 |         8.70 |         4.48 |              | 
##                            |         0.51 |         0.61 |         0.52 |              | 
##                            |         0.60 |         0.26 |         0.14 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1498 |           64 |            4 |           16 |           84 | 
##                            |        57.65 |        17.40 |         8.95 |              | 
##                            |         0.70 |        10.32 |         5.55 |              | 
##                            |         0.76 |         0.05 |         0.19 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                       1505 |           71 |           19 |            5 |           95 | 
##                            |        65.20 |        19.68 |        10.12 |              | 
##                            |         0.52 |         0.02 |         2.59 |              | 
##                            |         0.75 |         0.20 |         0.05 |         0.00 | 
##                            |         0.00 |         0.00 |         0.00 |              | 
##                            |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##               Column Total |        56647 |        17099 |         8797 |        82543 | 
##                            |         0.69 |         0.21 |         0.11 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  8404     d.f. =  94     p =  0 
## 
## 
## 
CrossTable(main_processed$NurseFlag, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                          | main_processed$Record.Type 
## main_processed$NurseFlag |   Attendance | Cancellation |          DNA |    Row Total | 
## -------------------------|--------------|--------------|--------------|--------------|
##                        N |        51594 |        15047 |         7904 |        74545 | 
##                          |     51158.19 |     15442.19 |      7944.62 |              | 
##                          |         3.71 |        10.11 |         0.21 |              | 
##                          |         0.69 |         0.20 |         0.11 |         0.90 | 
##                          |         0.91 |         0.88 |         0.90 |              | 
##                          |         0.63 |         0.18 |         0.10 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##                        Y |         5053 |         2052 |          893 |         7998 | 
##                          |      5488.81 |      1656.81 |       852.38 |              | 
##                          |        34.60 |        94.26 |         1.94 |              | 
##                          |         0.63 |         0.26 |         0.11 |         0.10 | 
##                          |         0.09 |         0.12 |         0.10 |              | 
##                          |         0.06 |         0.02 |         0.01 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##             Column Total |        56647 |        17099 |         8797 |        82543 | 
##                          |         0.69 |         0.21 |         0.11 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  145     d.f. =  2     p =  3.5e-32 
## 
## 
## 
CrossTable(main_processed$Referral.Source_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                       | main_processed$Record.Type 
## main_processed$Referral.Source_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                                CLINIC |        24269 |         7042 |         3485 |        34796 | 
##                                       |     23879.54 |      7208.08 |      3708.38 |              | 
##                                       |         6.35 |         3.83 |        13.46 |              | 
##                                       |         0.70 |         0.20 |         0.10 |         0.42 | 
##                                       |         0.43 |         0.41 |         0.40 |              | 
##                                       |         0.29 |         0.09 |         0.04 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                        Elsew of Mater |         1658 |          113 |           43 |         1814 | 
##                                       |      1244.90 |       375.77 |       193.33 |              | 
##                                       |       137.08 |       183.76 |       116.89 |              | 
##                                       |         0.91 |         0.06 |         0.02 |         0.02 | 
##                                       |         0.03 |         0.01 |         0.00 |              | 
##                                       |         0.02 |         0.00 |         0.00 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                   Elsew outside Mater |         5012 |         1882 |          628 |         7522 | 
##                                       |      5162.14 |      1558.20 |       801.66 |              | 
##                                       |         4.37 |        67.29 |        37.62 |              | 
##                                       |         0.67 |         0.25 |         0.08 |         0.09 | 
##                                       |         0.09 |         0.11 |         0.07 |              | 
##                                       |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                        EMERGENCY DEPT |        12764 |         1523 |         1838 |        16125 | 
##                                       |     11066.15 |      3340.34 |      1718.52 |              | 
##                                       |       260.50 |       988.74 |         8.31 |              | 
##                                       |         0.79 |         0.09 |         0.11 |         0.20 | 
##                                       |         0.23 |         0.09 |         0.21 |              | 
##                                       |         0.15 |         0.02 |         0.02 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                                    GP |         7387 |         4704 |         1705 |        13796 | 
##                                       |      9467.82 |      2857.88 |      1470.31 |              | 
##                                       |       457.32 |      1192.55 |        37.46 |              | 
##                                       |         0.54 |         0.34 |         0.12 |         0.17 | 
##                                       |         0.13 |         0.28 |         0.19 |              | 
##                                       |         0.09 |         0.06 |         0.02 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                      OTHER CONSULTANT |          991 |          481 |          193 |         1665 | 
##                                       |      1142.64 |       344.91 |       177.45 |              | 
##                                       |        20.13 |        53.70 |         1.36 |              | 
##                                       |         0.60 |         0.29 |         0.12 |         0.02 | 
##                                       |         0.02 |         0.03 |         0.02 |              | 
##                                       |         0.01 |         0.01 |         0.00 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                                  WARD |         4566 |         1354 |          905 |         6825 | 
##                                       |      4683.81 |      1413.82 |       727.37 |              | 
##                                       |         2.96 |         2.53 |        43.38 |              | 
##                                       |         0.67 |         0.20 |         0.13 |         0.08 | 
##                                       |         0.08 |         0.08 |         0.10 |              | 
##                                       |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                          Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                       |         0.69 |         0.21 |         0.11 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  3640     d.f. =  12     p =  0 
## 
## 
## 
#CrossTable(main_processed$Referring.Hospital, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
CrossTable(main_processed$Consultant_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                  | main_processed$Record.Type 
## main_processed$Consultant_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           BRIAIN |         3668 |          691 |          481 |         4840 | 
##                                  |      3321.56 |      1002.62 |       515.82 |              | 
##                                  |        36.13 |        96.85 |         2.35 |              | 
##                                  |         0.76 |         0.14 |         0.10 |         0.06 | 
##                                  |         0.06 |         0.04 |         0.05 |              | 
##                                  |         0.04 |         0.01 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           BUTLER |         2064 |         1269 |          204 |         3537 | 
##                                  |      2427.35 |       732.70 |       376.95 |              | 
##                                  |        54.39 |       392.55 |        79.36 |              | 
##                                  |         0.58 |         0.36 |         0.06 |         0.04 | 
##                                  |         0.04 |         0.07 |         0.02 |              | 
##                                  |         0.03 |         0.02 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           CARMOO |            1 |            0 |            0 |            1 | 
##                                  |         0.69 |         0.21 |         0.11 |              | 
##                                  |         0.14 |         0.21 |         0.11 |              | 
##                                  |         1.00 |         0.00 |         0.00 |         0.00 | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           CASHMA |          522 |          278 |           37 |          837 | 
##                                  |       574.41 |       173.39 |        89.20 |              | 
##                                  |         4.78 |        63.12 |        30.55 |              | 
##                                  |         0.62 |         0.33 |         0.04 |         0.01 | 
##                                  |         0.01 |         0.02 |         0.00 |              | 
##                                  |         0.01 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           CASSID |         1951 |          991 |          288 |         3230 | 
##                                  |      2216.66 |       669.10 |       344.24 |              | 
##                                  |        31.84 |       154.86 |         9.19 |              | 
##                                  |         0.60 |         0.31 |         0.09 |         0.04 | 
##                                  |         0.03 |         0.06 |         0.03 |              | 
##                                  |         0.02 |         0.01 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           COLGAN |         7071 |          846 |          940 |         8857 | 
##                                  |      6078.32 |      1834.75 |       943.93 |              | 
##                                  |       162.12 |       532.84 |         0.02 |              | 
##                                  |         0.80 |         0.10 |         0.11 |         0.11 | 
##                                  |         0.12 |         0.05 |         0.11 |              | 
##                                  |         0.09 |         0.01 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           DODDSM |         1359 |          831 |          277 |         2467 | 
##                                  |      1693.03 |       511.05 |       262.92 |              | 
##                                  |        65.90 |       200.32 |         0.75 |              | 
##                                  |         0.55 |         0.34 |         0.11 |         0.03 | 
##                                  |         0.02 |         0.05 |         0.03 |              | 
##                                  |         0.02 |         0.01 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                              FRA |            1 |            0 |            0 |            1 | 
##                                  |         0.69 |         0.21 |         0.11 |              | 
##                                  |         0.14 |         0.21 |         0.11 |              | 
##                                  |         1.00 |         0.00 |         0.00 |         0.00 | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           HYNESD |          741 |          294 |          113 |         1148 | 
##                                  |       787.84 |       237.81 |       122.35 |              | 
##                                  |         2.78 |        13.28 |         0.71 |              | 
##                                  |         0.65 |         0.26 |         0.10 |         0.01 | 
##                                  |         0.01 |         0.02 |         0.01 |              | 
##                                  |         0.01 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           LYNCSA |          139 |           38 |           23 |          200 | 
##                                  |       137.25 |        41.43 |        21.31 |              | 
##                                  |         0.02 |         0.28 |         0.13 |              | 
##                                  |         0.69 |         0.19 |         0.12 |         0.00 | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           LYONSF |         4387 |          398 |          419 |         5204 | 
##                                  |      3571.36 |      1078.02 |       554.62 |              | 
##                                  |       186.28 |       428.96 |        33.16 |              | 
##                                  |         0.84 |         0.08 |         0.08 |         0.06 | 
##                                  |         0.08 |         0.02 |         0.05 |              | 
##                                  |         0.05 |         0.00 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                             MARA |         3841 |          497 |          457 |         4795 | 
##                                  |      3290.68 |       993.30 |       511.03 |              | 
##                                  |        92.03 |       247.97 |         5.71 |              | 
##                                  |         0.80 |         0.10 |         0.10 |         0.06 | 
##                                  |         0.07 |         0.03 |         0.05 |              | 
##                                  |         0.05 |         0.01 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           MCSORK |          150 |            4 |           16 |          170 | 
##                                  |       116.67 |        35.22 |        18.12 |              | 
##                                  |         9.52 |        27.67 |         0.25 |              | 
##                                  |         0.88 |         0.02 |         0.09 |         0.00 | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                            MOROP |         8054 |         1220 |          936 |        10210 | 
##                                  |      7006.84 |      2115.03 |      1088.13 |              | 
##                                  |       156.50 |       378.75 |        21.27 |              | 
##                                  |         0.79 |         0.12 |         0.09 |         0.12 | 
##                                  |         0.14 |         0.07 |         0.11 |              | 
##                                  |         0.10 |         0.01 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                            MORRI |         3488 |         1725 |          512 |         5725 | 
##                                  |      3928.91 |      1185.95 |       610.14 |              | 
##                                  |        49.48 |       245.02 |        15.79 |              | 
##                                  |         0.61 |         0.30 |         0.09 |         0.07 | 
##                                  |         0.06 |         0.10 |         0.06 |              | 
##                                  |         0.04 |         0.02 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           MURMAR |          157 |           67 |            6 |          230 | 
##                                  |       157.84 |        47.65 |        24.51 |              | 
##                                  |         0.00 |         7.86 |        13.98 |              | 
##                                  |         0.68 |         0.29 |         0.03 |         0.00 | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           OHEIRE |         8511 |         1556 |          846 |        10913 | 
##                                  |      7489.29 |      2260.66 |      1163.05 |              | 
##                                  |       139.38 |       219.64 |        86.43 |              | 
##                                  |         0.78 |         0.14 |         0.08 |         0.13 | 
##                                  |         0.15 |         0.09 |         0.10 |              | 
##                                  |         0.10 |         0.02 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           ONEISH |         3123 |          281 |          243 |         3647 | 
##                                  |      2502.84 |       755.49 |       388.68 |              | 
##                                  |       153.67 |       298.00 |        54.60 |              | 
##                                  |         0.86 |         0.08 |         0.07 |         0.04 | 
##                                  |         0.06 |         0.02 |         0.03 |              | 
##                                  |         0.04 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           ORTCON |            1 |            0 |            2 |            3 | 
##                                  |         2.06 |         0.62 |         0.32 |              | 
##                                  |         0.54 |         0.62 |         8.83 |              | 
##                                  |         0.33 |         0.00 |         0.67 |         0.00 | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
##                                  |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           SYNNOT |         4662 |         1156 |          474 |         6292 | 
##                                  |      4318.03 |      1303.40 |       670.57 |              | 
##                                  |        27.40 |        16.67 |        57.62 |              | 
##                                  |         0.74 |         0.18 |         0.08 |         0.08 | 
##                                  |         0.08 |         0.07 |         0.05 |              | 
##                                  |         0.06 |         0.01 |         0.01 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                           TIMLIN |         2756 |         1432 |          309 |         4497 | 
##                                  |      3086.17 |       931.57 |       479.27 |              | 
##                                  |        35.32 |       268.83 |        60.49 |              | 
##                                  |         0.61 |         0.32 |         0.07 |         0.05 | 
##                                  |         0.05 |         0.08 |         0.04 |              | 
##                                  |         0.03 |         0.02 |         0.00 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                               XX |            0 |         3525 |         2214 |         5739 | 
##                                  |      3938.52 |      1188.85 |       611.63 |              | 
##                                  |      3938.52 |      4590.66 |      4197.92 |              | 
##                                  |         0.00 |         0.61 |         0.39 |         0.07 | 
##                                  |         0.00 |         0.21 |         0.25 |              | 
##                                  |         0.00 |         0.04 |         0.03 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
##                     Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                  |         0.69 |         0.21 |         0.11 |              | 
## ---------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  18011     d.f. =  42     p =  0 
## 
## 
## 
CrossTable(main_processed$Insurance.Scheme_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                        | main_processed$Record.Type 
## main_processed$Insurance.Scheme_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      A |          137 |           34 |           19 |          190 | 
##                                        |       130.39 |        39.36 |        20.25 |              | 
##                                        |         0.33 |         0.73 |         0.08 |              | 
##                                        |         0.72 |         0.18 |         0.10 |         0.00 | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      B |         1780 |          539 |          154 |         2473 | 
##                                        |      1697.15 |       512.29 |       263.56 |              | 
##                                        |         4.04 |         1.39 |        45.54 |              | 
##                                        |         0.72 |         0.22 |         0.06 |         0.03 | 
##                                        |         0.03 |         0.03 |         0.02 |              | 
##                                        |         0.02 |         0.01 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      C |            6 |            0 |            1 |            7 | 
##                                        |         4.80 |         1.45 |         0.75 |              | 
##                                        |         0.30 |         1.45 |         0.09 |              | 
##                                        |         0.86 |         0.00 |         0.14 |         0.00 | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      D |        21396 |         7210 |         4023 |        32629 | 
##                                        |     22392.39 |      6759.18 |      3477.43 |              | 
##                                        |        44.34 |        30.07 |        85.59 |              | 
##                                        |         0.66 |         0.22 |         0.12 |         0.40 | 
##                                        |         0.38 |         0.42 |         0.46 |              | 
##                                        |         0.26 |         0.09 |         0.05 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      E |           83 |           28 |            7 |          118 | 
##                                        |        80.98 |        24.44 |        12.58 |              | 
##                                        |         0.05 |         0.52 |         2.47 |              | 
##                                        |         0.70 |         0.24 |         0.06 |         0.00 | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      G |          336 |           64 |           27 |          427 | 
##                                        |       293.04 |        88.45 |        45.51 |              | 
##                                        |         6.30 |         6.76 |         7.53 |              | 
##                                        |         0.79 |         0.15 |         0.06 |         0.01 | 
##                                        |         0.01 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      H |           70 |           20 |           10 |          100 | 
##                                        |        68.63 |        20.72 |        10.66 |              | 
##                                        |         0.03 |         0.02 |         0.04 |              | 
##                                        |         0.70 |         0.20 |         0.10 |         0.00 | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      I |         1562 |          424 |          137 |         2123 | 
##                                        |      1456.96 |       439.79 |       226.26 |              | 
##                                        |         7.57 |         0.57 |        35.21 |              | 
##                                        |         0.74 |         0.20 |         0.06 |         0.03 | 
##                                        |         0.03 |         0.02 |         0.02 |              | 
##                                        |         0.02 |         0.01 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      J |           42 |            8 |            3 |           53 | 
##                                        |        36.37 |        10.98 |         5.65 |              | 
##                                        |         0.87 |         0.81 |         1.24 |              | 
##                                        |         0.79 |         0.15 |         0.06 |         0.00 | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      M |            5 |            0 |            1 |            6 | 
##                                        |         4.12 |         1.24 |         0.64 |              | 
##                                        |         0.19 |         1.24 |         0.20 |              | 
##                                        |         0.83 |         0.00 |         0.17 |         0.00 | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      O |          368 |           82 |           80 |          530 | 
##                                        |       363.72 |       109.79 |        56.48 |              | 
##                                        |         0.05 |         7.03 |         9.79 |              | 
##                                        |         0.69 |         0.15 |         0.15 |         0.01 | 
##                                        |         0.01 |         0.00 |         0.01 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      P |          104 |           22 |            4 |          130 | 
##                                        |        89.22 |        26.93 |        13.85 |              | 
##                                        |         2.45 |         0.90 |         7.01 |              | 
##                                        |         0.80 |         0.17 |         0.03 |         0.00 | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
##                                        |         0.00 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      S |          881 |          191 |           73 |         1145 | 
##                                        |       785.78 |       237.19 |       122.03 |              | 
##                                        |        11.54 |         8.99 |        19.70 |              | 
##                                        |         0.77 |         0.17 |         0.06 |         0.01 | 
##                                        |         0.02 |         0.01 |         0.01 |              | 
##                                        |         0.01 |         0.00 |         0.00 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      U |        24738 |         7096 |         3722 |        35556 | 
##                                        |     24401.11 |      7365.52 |      3789.37 |              | 
##                                        |         4.65 |         9.86 |         1.20 |              | 
##                                        |         0.70 |         0.20 |         0.10 |         0.43 | 
##                                        |         0.44 |         0.41 |         0.42 |              | 
##                                        |         0.30 |         0.09 |         0.05 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                                      V |         5139 |         1381 |          536 |         7056 | 
##                                        |      4842.34 |      1461.67 |       751.99 |              | 
##                                        |        18.17 |         4.45 |        62.04 |              | 
##                                        |         0.73 |         0.20 |         0.08 |         0.09 | 
##                                        |         0.09 |         0.08 |         0.06 |              | 
##                                        |         0.06 |         0.02 |         0.01 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
##                           Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                        |         0.69 |         0.21 |         0.11 |              | 
## ---------------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  453     d.f. =  28     p =  2.5e-78 
## 
## 
## 
CrossTable(main_processed$Eligibility_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                   | main_processed$Record.Type 
## main_processed$Eligibility_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                            15000+ |            0 |            2 |            0 |            2 | 
##                                   |         1.37 |         0.41 |         0.21 |              | 
##                                   |         1.37 |         6.07 |         0.21 |              | 
##                                   |         0.00 |         1.00 |         0.00 |         0.00 | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                ACUTE UNCLASSIFIED |          560 |          163 |          107 |          830 | 
##                                   |       569.61 |       171.94 |        88.46 |              | 
##                                   |         0.16 |         0.46 |         3.89 |              | 
##                                   |         0.67 |         0.20 |         0.13 |         0.01 | 
##                                   |         0.01 |         0.01 |         0.01 |              | 
##                                   |         0.01 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##               ELIGIBILITY UNKNOWN |          588 |          863 |          490 |         1941 | 
##                                   |      1332.06 |       402.08 |       206.86 |              | 
##                                   |       415.61 |       528.36 |       387.54 |              | 
##                                   |         0.30 |         0.44 |         0.25 |         0.02 | 
##                                   |         0.01 |         0.05 |         0.06 |              | 
##                                   |         0.01 |         0.01 |         0.01 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                            EXEMPT |         2560 |          686 |          272 |         3518 | 
##                                   |      2414.31 |       728.76 |       374.93 |              | 
##                                   |         8.79 |         2.51 |        28.26 |              | 
##                                   |         0.73 |         0.19 |         0.08 |         0.04 | 
##                                   |         0.05 |         0.04 |         0.03 |              | 
##                                   |         0.03 |         0.01 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                      MEDICAL CARD |        24168 |         8438 |         4225 |        36831 | 
##                                   |     25276.11 |      7629.64 |      3925.25 |              | 
##                                   |        48.58 |        85.65 |        22.89 |              | 
##                                   |         0.66 |         0.23 |         0.11 |         0.45 | 
##                                   |         0.43 |         0.49 |         0.48 |              | 
##                                   |         0.29 |         0.10 |         0.05 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##            NON ACUTE UNCLASSIFIED |           29 |            9 |            3 |           41 | 
##                                   |        28.14 |         8.49 |         4.37 |              | 
##                                   |         0.03 |         0.03 |         0.43 |              | 
##                                   |         0.71 |         0.22 |         0.07 |         0.00 | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                  NON MEDICAL CARD |        28632 |         6888 |         3688 |        39208 | 
##                                   |     26907.38 |      8122.04 |      4178.58 |              | 
##                                   |       110.54 |       187.50 |        57.60 |              | 
##                                   |         0.73 |         0.18 |         0.09 |         0.48 | 
##                                   |         0.51 |         0.40 |         0.42 |              | 
##                                   |         0.35 |         0.08 |         0.04 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##           RESEARCH/NATIONAL PROG. |          110 |           50 |           12 |          172 | 
##                                   |       118.04 |        35.63 |        18.33 |              | 
##                                   |         0.55 |         5.80 |         2.19 |              | 
##                                   |         0.64 |         0.29 |         0.07 |         0.00 | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
##                                   |         0.00 |         0.00 |         0.00 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
##                      Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                   |         0.69 |         0.21 |         0.11 |              | 
## ----------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  1905     d.f. =  14     p =  0 
## 
## 
## 
CrossTable(main_processed$Booking.Type_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                    | main_processed$Record.Type 
## main_processed$Booking.Type_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##             B : New  Virtual Video |          489 |           86 |           77 |          652 | 
##                                    |       447.45 |       135.06 |        69.49 |              | 
##                                    |         3.86 |        17.82 |         0.81 |              | 
##                                    |         0.75 |         0.13 |         0.12 |         0.01 | 
##                                    |         0.01 |         0.01 |         0.01 |              | 
##                                    |         0.01 |         0.00 |         0.00 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##             C : New  Virtual Phone |         4567 |          202 |           77 |         4846 | 
##                                    |      3325.68 |      1003.86 |       516.46 |              | 
##                                    |       463.33 |       640.51 |       373.94 |              | 
##                                    |         0.94 |         0.04 |         0.02 |         0.06 | 
##                                    |         0.08 |         0.01 |         0.01 |              | 
##                                    |         0.06 |         0.00 |         0.00 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##          D : Return  Virtual Video |            3 |            0 |            0 |            3 | 
##                                    |         2.06 |         0.62 |         0.32 |              | 
##                                    |         0.43 |         0.62 |         0.32 |              | 
##                                    |         1.00 |         0.00 |         0.00 |         0.00 | 
##                                    |         0.00 |         0.00 |         0.00 |              | 
##                                    |         0.00 |         0.00 |         0.00 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##          E : Return  Virtual Phone |           12 |            0 |            3 |           15 | 
##                                    |        10.29 |         3.11 |         1.60 |              | 
##                                    |         0.28 |         3.11 |         1.23 |              | 
##                                    |         0.80 |         0.00 |         0.20 |         0.00 | 
##                                    |         0.00 |         0.00 |         0.00 |              | 
##                                    |         0.00 |         0.00 |         0.00 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##                                NEW |        16164 |         6589 |         3351 |        26104 | 
##                                    |     17914.46 |      5407.51 |      2782.03 |              | 
##                                    |       171.04 |       258.14 |       116.36 |              | 
##                                    |         0.62 |         0.25 |         0.13 |         0.32 | 
##                                    |         0.29 |         0.39 |         0.38 |              | 
##                                    |         0.20 |         0.08 |         0.04 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##                             RETURN |        31668 |         9125 |         4494 |        45287 | 
##                                    |     31079.23 |      9381.32 |      4826.45 |              | 
##                                    |        11.15 |         7.00 |        22.90 |              | 
##                                    |         0.70 |         0.20 |         0.10 |         0.55 | 
##                                    |         0.56 |         0.53 |         0.51 |              | 
##                                    |         0.38 |         0.11 |         0.05 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##                         V : REVIEW |            0 |            1 |            0 |            1 | 
##                                    |         0.69 |         0.21 |         0.11 |              | 
##                                    |         0.69 |         3.03 |         0.11 |              | 
##                                    |         0.00 |         1.00 |         0.00 |         0.00 | 
##                                    |         0.00 |         0.00 |         0.00 |              | 
##                                    |         0.00 |         0.00 |         0.00 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##                               WARD |         3744 |         1096 |          795 |         5635 | 
##                                    |      3867.15 |      1167.31 |       600.55 |              | 
##                                    |         3.92 |         4.36 |        62.96 |              | 
##                                    |         0.66 |         0.19 |         0.14 |         0.07 | 
##                                    |         0.07 |         0.06 |         0.09 |              | 
##                                    |         0.05 |         0.01 |         0.01 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
##                       Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                    |         0.69 |         0.21 |         0.11 |              | 
## -----------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  2168     d.f. =  14     p =  0 
## 
## 
## 
CrossTable(main_processed$Hospital.Catchment_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                          | main_processed$Record.Type 
## main_processed$Hospital.Catchment_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                 Beaumont |         2707 |          644 |          318 |         3669 | 
##                                          |      2517.93 |       760.04 |       391.02 |              | 
##                                          |        14.20 |        17.72 |        13.64 |              | 
##                                          |         0.74 |         0.18 |         0.09 |         0.04 | 
##                                          |         0.05 |         0.04 |         0.04 |              | 
##                                          |         0.03 |         0.01 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                 Connolly |         2986 |          961 |          413 |         4360 | 
##                                          |      2992.15 |       903.19 |       464.67 |              | 
##                                          |         0.01 |         3.70 |         5.74 |              | 
##                                          |         0.68 |         0.22 |         0.09 |         0.05 | 
##                                          |         0.05 |         0.06 |         0.05 |              | 
##                                          |         0.04 |         0.01 |         0.01 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                            International |          256 |           94 |           67 |          417 | 
##                                          |       286.18 |        86.38 |        44.44 |              | 
##                                          |         3.18 |         0.67 |        11.45 |              | 
##                                          |         0.61 |         0.23 |         0.16 |         0.01 | 
##                                          |         0.00 |         0.01 |         0.01 |              | 
##                                          |         0.00 |         0.00 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                    James |         3884 |          885 |          653 |         5422 | 
##                                          |      3720.97 |      1123.18 |       577.85 |              | 
##                                          |         7.14 |        50.51 |         9.77 |              | 
##                                          |         0.72 |         0.16 |         0.12 |         0.07 | 
##                                          |         0.07 |         0.05 |         0.07 |              | 
##                                          |         0.05 |         0.01 |         0.01 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                    Mater |        27563 |         6791 |         4634 |        38988 | 
##                                          |     26756.40 |      8076.47 |      4155.14 |              | 
##                                          |        24.32 |       204.60 |        55.19 |              | 
##                                          |         0.71 |         0.17 |         0.12 |         0.47 | 
##                                          |         0.49 |         0.40 |         0.53 |              | 
##                                          |         0.33 |         0.08 |         0.06 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                 National |        15402 |         6726 |         2117 |        24245 | 
##                                          |     16638.68 |      5022.42 |      2583.90 |              | 
##                                          |        91.92 |       577.85 |        84.37 |              | 
##                                          |         0.64 |         0.28 |         0.09 |         0.29 | 
##                                          |         0.27 |         0.39 |         0.24 |              | 
##                                          |         0.19 |         0.08 |         0.03 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                 Tallaght |         1301 |          332 |          220 |         1853 | 
##                                          |      1271.66 |       383.85 |       197.48 |              | 
##                                          |         0.68 |         7.00 |         2.57 |              | 
##                                          |         0.70 |         0.18 |         0.12 |         0.02 | 
##                                          |         0.02 |         0.02 |         0.03 |              | 
##                                          |         0.02 |         0.00 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                 Vincents |         2548 |          666 |          375 |         3589 | 
##                                          |      2463.03 |       743.47 |       382.50 |              | 
##                                          |         2.93 |         8.07 |         0.15 |              | 
##                                          |         0.71 |         0.19 |         0.10 |         0.04 | 
##                                          |         0.04 |         0.04 |         0.04 |              | 
##                                          |         0.03 |         0.01 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                             Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                          |         0.69 |         0.21 |         0.11 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  1197     d.f. =  14     p =  6.4e-247 
## 
## 
## 
CrossTable(main_processed$Attendance.Type_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                       | main_processed$Record.Type 
## main_processed$Attendance.Type_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                                       |            0 |           87 |           77 |          164 | 
##                                       |       112.55 |        33.97 |        17.48 |              | 
##                                       |       112.55 |        82.77 |       202.70 |              | 
##                                       |         0.00 |         0.53 |         0.47 |         0.00 | 
##                                       |         0.00 |         0.01 |         0.01 |              | 
##                                       |         0.00 |         0.00 |         0.00 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                             EMERGENCY |            0 |            0 |            3 |            3 | 
##                                       |         2.06 |         0.62 |         0.32 |              | 
##                                       |         2.06 |         0.62 |        22.47 |              | 
##                                       |         0.00 |         0.00 |         1.00 |         0.00 | 
##                                       |         0.00 |         0.00 |         0.00 |              | 
##                                       |         0.00 |         0.00 |         0.00 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                                   NEW |        16753 |         7685 |         4146 |        28584 | 
##                                       |     19616.42 |      5921.25 |      3046.33 |              | 
##                                       |       417.97 |       525.36 |       396.96 |              | 
##                                       |         0.59 |         0.27 |         0.15 |         0.35 | 
##                                       |         0.30 |         0.45 |         0.47 |              | 
##                                       |         0.20 |         0.09 |         0.05 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                                RETURN |        34080 |         9125 |         4494 |        47699 | 
##                                       |     32734.52 |      9880.97 |      5083.51 |              | 
##                                       |        55.30 |        57.84 |        68.36 |              | 
##                                       |         0.71 |         0.19 |         0.09 |         0.58 | 
##                                       |         0.60 |         0.53 |         0.51 |              | 
##                                       |         0.41 |         0.11 |         0.05 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                        VIRTUAL RETURN |          402 |            0 |            0 |          402 | 
##                                       |       275.88 |        83.28 |        42.84 |              | 
##                                       |        57.65 |        83.28 |        42.84 |              | 
##                                       |         1.00 |         0.00 |         0.00 |         0.00 | 
##                                       |         0.01 |         0.00 |         0.00 |              | 
##                                       |         0.00 |         0.00 |         0.00 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                   VIRTUAL(New_Return) |         5412 |          202 |           77 |         5691 | 
##                                       |      3905.58 |      1178.91 |       606.52 |              | 
##                                       |       581.04 |       809.52 |       462.29 |              | 
##                                       |         0.95 |         0.04 |         0.01 |         0.07 | 
##                                       |         0.10 |         0.01 |         0.01 |              | 
##                                       |         0.07 |         0.00 |         0.00 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
##                          Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                       |         0.69 |         0.21 |         0.11 |              | 
## --------------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  3982     d.f. =  10     p =  0 
## 
## 
## 
## Record Type & Date relevance
CrossTable(main_processed$bookedDay, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  76863 
## 
##  
##                          | main_processed$Record.Type 
## main_processed$bookedDay |   Attendance | Cancellation |          DNA |    Row Total | 
## -------------------------|--------------|--------------|--------------|--------------|
##                   Friday |         6093 |         1624 |          825 |         8542 | 
##                          |      5664.11 |      1900.26 |       977.64 |              | 
##                          |        32.48 |        40.16 |        23.83 |              | 
##                          |         0.71 |         0.19 |         0.10 |         0.11 | 
##                          |         0.12 |         0.09 |         0.09 |              | 
##                          |         0.08 |         0.02 |         0.01 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##                   Monday |        10047 |         3542 |         1843 |        15432 | 
##                          |     10232.79 |      3433.01 |      1766.20 |              | 
##                          |         3.37 |         3.46 |         3.34 |              | 
##                          |         0.65 |         0.23 |         0.12 |         0.20 | 
##                          |         0.20 |         0.21 |         0.21 |              | 
##                          |         0.13 |         0.05 |         0.02 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##                 Saturday |         6436 |         1785 |          935 |         9156 | 
##                          |      6071.24 |      2036.85 |      1047.91 |              | 
##                          |        21.91 |        31.14 |        12.17 |              | 
##                          |         0.70 |         0.19 |         0.10 |         0.12 | 
##                          |         0.13 |         0.10 |         0.11 |              | 
##                          |         0.08 |         0.02 |         0.01 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##                   Sunday |         8519 |         2600 |         1403 |        12522 | 
##                          |      8303.20 |      2785.65 |      1433.15 |              | 
##                          |         5.61 |        12.37 |         0.63 |              | 
##                          |         0.68 |         0.21 |         0.11 |         0.16 | 
##                          |         0.17 |         0.15 |         0.16 |              | 
##                          |         0.11 |         0.03 |         0.02 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##                 Thursday |         4574 |         1830 |          821 |         7225 | 
##                          |      4790.82 |      1607.28 |       826.90 |              | 
##                          |         9.81 |        30.86 |         0.04 |              | 
##                          |         0.63 |         0.25 |         0.11 |         0.09 | 
##                          |         0.09 |         0.11 |         0.09 |              | 
##                          |         0.06 |         0.02 |         0.01 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##                  Tuesday |         9013 |         3259 |         1718 |        13990 | 
##                          |      9276.61 |      3112.23 |      1601.16 |              | 
##                          |         7.49 |         6.92 |         8.53 |              | 
##                          |         0.64 |         0.23 |         0.12 |         0.18 | 
##                          |         0.18 |         0.19 |         0.20 |              | 
##                          |         0.12 |         0.04 |         0.02 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##                Wednesday |         6285 |         2459 |         1252 |         9996 | 
##                          |      6628.24 |      2223.72 |      1144.05 |              | 
##                          |        17.77 |        24.89 |        10.19 |              | 
##                          |         0.63 |         0.25 |         0.13 |         0.13 | 
##                          |         0.12 |         0.14 |         0.14 |              | 
##                          |         0.08 |         0.03 |         0.02 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
##             Column Total |        50967 |        17099 |         8797 |        76863 | 
##                          |         0.66 |         0.22 |         0.11 |              | 
## -------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  307     d.f. =  12     p =  1.6e-58 
## 
## 
## 
CrossTable(main_processed$bookedMonthYear, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  76863 
## 
##  
##                                | main_processed$Record.Type 
## main_processed$bookedMonthYear |   Attendance | Cancellation |          DNA |    Row Total | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Apr 2020 |         3537 |         1064 |          636 |         5237 | 
##                                |      3472.60 |      1165.03 |       599.38 |              | 
##                                |         1.19 |         8.76 |         2.24 |              | 
##                                |         0.68 |         0.20 |         0.12 |         0.07 | 
##                                |         0.07 |         0.06 |         0.07 |              | 
##                                |         0.05 |         0.01 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Aug 2020 |         4456 |         1319 |          811 |         6586 | 
##                                |      4367.10 |      1465.13 |       753.77 |              | 
##                                |         1.81 |        14.57 |         4.35 |              | 
##                                |         0.68 |         0.20 |         0.12 |         0.09 | 
##                                |         0.09 |         0.08 |         0.09 |              | 
##                                |         0.06 |         0.02 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Dec 2020 |         3651 |          935 |          503 |         5089 | 
##                                |      3374.46 |      1132.10 |       582.44 |              | 
##                                |        22.66 |        34.32 |        10.83 |              | 
##                                |         0.72 |         0.18 |         0.10 |         0.07 | 
##                                |         0.07 |         0.05 |         0.06 |              | 
##                                |         0.05 |         0.01 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Feb 2020 |         4193 |         1933 |          767 |         6893 | 
##                                |      4570.67 |      1533.42 |       788.91 |              | 
##                                |        31.21 |       104.12 |         0.61 |              | 
##                                |         0.61 |         0.28 |         0.11 |         0.09 | 
##                                |         0.08 |         0.11 |         0.09 |              | 
##                                |         0.05 |         0.03 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Jan 2020 |         4682 |         2291 |          770 |         7743 | 
##                                |      5134.30 |      1722.51 |       886.19 |              | 
##                                |        39.84 |       187.62 |        15.23 |              | 
##                                |         0.60 |         0.30 |         0.10 |         0.10 | 
##                                |         0.09 |         0.13 |         0.09 |              | 
##                                |         0.06 |         0.03 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Jul 2020 |         4430 |         1368 |          790 |         6588 | 
##                                |      4368.43 |      1465.57 |       754.00 |              | 
##                                |         0.87 |         6.50 |         1.72 |              | 
##                                |         0.67 |         0.21 |         0.12 |         0.09 | 
##                                |         0.09 |         0.08 |         0.09 |              | 
##                                |         0.06 |         0.02 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Jun 2020 |         4334 |         1080 |          735 |         6149 | 
##                                |      4077.33 |      1367.91 |       703.76 |              | 
##                                |        16.16 |        60.60 |         1.39 |              | 
##                                |         0.70 |         0.18 |         0.12 |         0.08 | 
##                                |         0.09 |         0.06 |         0.08 |              | 
##                                |         0.06 |         0.01 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Mar 2020 |         4034 |         1788 |          782 |         6604 | 
##                                |      4379.04 |      1469.13 |       755.83 |              | 
##                                |        27.19 |        69.21 |         0.91 |              | 
##                                |         0.61 |         0.27 |         0.12 |         0.09 | 
##                                |         0.08 |         0.10 |         0.09 |              | 
##                                |         0.05 |         0.02 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       May 2020 |         4117 |         1197 |          782 |         6096 | 
##                                |      4042.19 |      1356.12 |       697.69 |              | 
##                                |         1.38 |        18.67 |        10.19 |              | 
##                                |         0.68 |         0.20 |         0.13 |         0.08 | 
##                                |         0.08 |         0.07 |         0.09 |              | 
##                                |         0.05 |         0.02 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Nov 2020 |         4524 |         1306 |          704 |         6534 | 
##                                |      4332.62 |      1453.56 |       747.82 |              | 
##                                |         8.45 |        14.98 |         2.57 |              | 
##                                |         0.69 |         0.20 |         0.11 |         0.09 | 
##                                |         0.09 |         0.08 |         0.08 |              | 
##                                |         0.06 |         0.02 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Oct 2020 |         4555 |         1292 |          712 |         6559 | 
##                                |      4349.20 |      1459.12 |       750.68 |              | 
##                                |         9.74 |        19.14 |         1.99 |              | 
##                                |         0.69 |         0.20 |         0.11 |         0.09 | 
##                                |         0.09 |         0.08 |         0.08 |              | 
##                                |         0.06 |         0.02 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                       Sep 2020 |         4454 |         1526 |          805 |         6785 | 
##                                |      4499.06 |      1509.40 |       776.55 |              | 
##                                |         0.45 |         0.18 |         1.04 |              | 
##                                |         0.66 |         0.22 |         0.12 |         0.09 | 
##                                |         0.09 |         0.09 |         0.09 |              | 
##                                |         0.06 |         0.02 |         0.01 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                   Column Total |        50967 |        17099 |         8797 |        76863 | 
##                                |         0.66 |         0.22 |         0.11 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  753     d.f. =  22     p =  5.8e-145 
## 
## 
## 
CrossTable(main_processed$Attendance.Day, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                               | main_processed$Record.Type 
## main_processed$Attendance.Day |   Attendance | Cancellation |          DNA |    Row Total | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                        Friday |        12168 |         2218 |         1707 |        16093 | 
##                               |     11044.19 |      3333.71 |      1715.11 |              | 
##                               |       114.36 |       373.40 |         0.04 |              | 
##                               |         0.76 |         0.14 |         0.11 |         0.19 | 
##                               |         0.21 |         0.13 |         0.19 |              | 
##                               |         0.15 |         0.03 |         0.02 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                        Monday |        11482 |         3854 |         1773 |        17109 | 
##                               |     11741.44 |      3544.17 |      1823.39 |              | 
##                               |         5.73 |        27.08 |         1.39 |              | 
##                               |         0.67 |         0.23 |         0.10 |         0.21 | 
##                               |         0.20 |         0.23 |         0.20 |              | 
##                               |         0.14 |         0.05 |         0.02 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                      Saturday |            1 |            0 |            0 |            1 | 
##                               |         0.69 |         0.21 |         0.11 |              | 
##                               |         0.14 |         0.21 |         0.11 |              | 
##                               |         1.00 |         0.00 |         0.00 |         0.00 | 
##                               |         0.00 |         0.00 |         0.00 |              | 
##                               |         0.00 |         0.00 |         0.00 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                        Sunday |            7 |            0 |            0 |            7 | 
##                               |         4.80 |         1.45 |         0.75 |              | 
##                               |         1.00 |         1.45 |         0.75 |              | 
##                               |         1.00 |         0.00 |         0.00 |         0.00 | 
##                               |         0.00 |         0.00 |         0.00 |              | 
##                               |         0.00 |         0.00 |         0.00 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                      Thursday |        10214 |         3754 |         1572 |        15540 | 
##                               |     10664.68 |      3219.15 |      1656.17 |              | 
##                               |        19.05 |        88.86 |         4.28 |              | 
##                               |         0.66 |         0.24 |         0.10 |         0.19 | 
##                               |         0.18 |         0.22 |         0.18 |              | 
##                               |         0.12 |         0.05 |         0.02 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                       Tuesday |        10694 |         2906 |         1862 |        15462 | 
##                               |     10611.15 |      3202.99 |      1647.86 |              | 
##                               |         0.65 |        27.54 |        27.83 |              | 
##                               |         0.69 |         0.19 |         0.12 |         0.19 | 
##                               |         0.19 |         0.17 |         0.21 |              | 
##                               |         0.13 |         0.04 |         0.02 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                     Wednesday |        12081 |         4367 |         1883 |        18331 | 
##                               |     12580.06 |      3797.31 |      1953.62 |              | 
##                               |        19.80 |        85.47 |         2.55 |              | 
##                               |         0.66 |         0.24 |         0.10 |         0.22 | 
##                               |         0.21 |         0.26 |         0.21 |              | 
##                               |         0.15 |         0.05 |         0.02 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
##                  Column Total |        56647 |        17099 |         8797 |        82543 | 
##                               |         0.69 |         0.21 |         0.11 |              | 
## ------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  802     d.f. =  12     p =  7.2e-164 
## 
## 
## 
CrossTable(main_processed$Attendance.Month, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                 | main_processed$Record.Type 
## main_processed$Attendance.Month |   Attendance | Cancellation |          DNA |    Row Total | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                           April |         3826 |         1640 |          636 |         6102 | 
##                                 |      4187.64 |      1264.05 |       650.32 |              | 
##                                 |        31.23 |       111.82 |         0.32 |              | 
##                                 |         0.63 |         0.27 |         0.10 |         0.07 | 
##                                 |         0.07 |         0.10 |         0.07 |              | 
##                                 |         0.05 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                          August |         4727 |         1367 |          743 |         6837 | 
##                                 |      4692.05 |      1416.30 |       728.65 |              | 
##                                 |         0.26 |         1.72 |         0.28 |              | 
##                                 |         0.69 |         0.20 |         0.11 |         0.08 | 
##                                 |         0.08 |         0.08 |         0.08 |              | 
##                                 |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                        December |         4428 |         1219 |          692 |         6339 | 
##                                 |      4350.28 |      1313.14 |       675.58 |              | 
##                                 |         1.39 |         6.75 |         0.40 |              | 
##                                 |         0.70 |         0.19 |         0.11 |         0.08 | 
##                                 |         0.08 |         0.07 |         0.08 |              | 
##                                 |         0.05 |         0.01 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                        February |         4705 |         1373 |          653 |         6731 | 
##                                 |      4619.30 |      1394.34 |       717.35 |              | 
##                                 |         1.59 |         0.33 |         5.77 |              | 
##                                 |         0.70 |         0.20 |         0.10 |         0.08 | 
##                                 |         0.08 |         0.08 |         0.07 |              | 
##                                 |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                         January |         4846 |         1411 |          643 |         6900 | 
##                                 |      4735.28 |      1429.35 |       735.37 |              | 
##                                 |         2.59 |         0.24 |        11.60 |              | 
##                                 |         0.70 |         0.20 |         0.09 |         0.08 | 
##                                 |         0.09 |         0.08 |         0.07 |              | 
##                                 |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                            July |         4785 |         1218 |          807 |         6810 | 
##                                 |      4673.52 |      1410.71 |       725.77 |              | 
##                                 |         2.66 |        26.33 |         9.09 |              | 
##                                 |         0.70 |         0.18 |         0.12 |         0.08 | 
##                                 |         0.08 |         0.07 |         0.09 |              | 
##                                 |         0.06 |         0.01 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                            June |         4480 |         1333 |          683 |         6496 | 
##                                 |      4458.03 |      1345.66 |       692.31 |              | 
##                                 |         0.11 |         0.12 |         0.13 |              | 
##                                 |         0.69 |         0.21 |         0.11 |         0.08 | 
##                                 |         0.08 |         0.08 |         0.08 |              | 
##                                 |         0.05 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                           March |         4691 |         1865 |          768 |         7324 | 
##                                 |      5026.26 |      1517.19 |       780.55 |              | 
##                                 |        22.36 |        79.74 |         0.20 |              | 
##                                 |         0.64 |         0.25 |         0.10 |         0.09 | 
##                                 |         0.08 |         0.11 |         0.09 |              | 
##                                 |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                             May |         4491 |         1484 |          690 |         6665 | 
##                                 |      4574.01 |      1380.67 |       710.32 |              | 
##                                 |         1.51 |         7.73 |         0.58 |              | 
##                                 |         0.67 |         0.22 |         0.10 |         0.08 | 
##                                 |         0.08 |         0.09 |         0.08 |              | 
##                                 |         0.05 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                        November |         5419 |         1419 |          776 |         7614 | 
##                                 |      5225.28 |      1577.26 |       811.46 |              | 
##                                 |         7.18 |        15.88 |         1.55 |              | 
##                                 |         0.71 |         0.19 |         0.10 |         0.09 | 
##                                 |         0.10 |         0.08 |         0.09 |              | 
##                                 |         0.07 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                         October |         5084 |         1295 |          777 |         7156 | 
##                                 |      4910.97 |      1482.38 |       762.65 |              | 
##                                 |         6.10 |        23.69 |         0.27 |              | 
##                                 |         0.71 |         0.18 |         0.11 |         0.09 | 
##                                 |         0.09 |         0.08 |         0.09 |              | 
##                                 |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                       September |         5165 |         1475 |          929 |         7569 | 
##                                 |      5194.40 |      1567.94 |       806.66 |              | 
##                                 |         0.17 |         5.51 |        18.55 |              | 
##                                 |         0.68 |         0.19 |         0.12 |         0.09 | 
##                                 |         0.09 |         0.09 |         0.11 |              | 
##                                 |         0.06 |         0.02 |         0.01 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
##                    Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                 |         0.69 |         0.21 |         0.11 |              | 
## --------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  406     d.f. =  22     p =  2.7e-72 
## 
## 
## 
CrossTable(main_processed$Attendance.Year, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                | main_processed$Record.Type 
## main_processed$Attendance.Year |   Attendance | Cancellation |          DNA |    Row Total | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                           2020 |        10864 |         4310 |         1798 |        16972 | 
##                                |     11647.42 |      3515.79 |      1808.79 |              | 
##                                |        52.69 |       179.41 |         0.06 |              | 
##                                |         0.64 |         0.25 |         0.11 |         0.21 | 
##                                |         0.19 |         0.25 |         0.20 |              | 
##                                |         0.13 |         0.05 |         0.02 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                           2021 |        12752 |         4260 |         2499 |        19511 | 
##                                |     13389.86 |      4041.76 |      2079.38 |              | 
##                                |        30.39 |        11.78 |        84.68 |              | 
##                                |         0.65 |         0.22 |         0.13 |         0.24 | 
##                                |         0.23 |         0.25 |         0.28 |              | 
##                                |         0.15 |         0.05 |         0.03 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                           2022 |        15163 |         4603 |         2575 |        22341 | 
##                                |     15332.02 |      4628.00 |      2380.99 |              | 
##                                |         1.86 |         0.14 |        15.81 |              | 
##                                |         0.68 |         0.21 |         0.12 |         0.27 | 
##                                |         0.27 |         0.27 |         0.29 |              | 
##                                |         0.18 |         0.06 |         0.03 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                           2023 |        17868 |         3926 |         1925 |        23719 | 
##                                |     16277.70 |      4913.45 |      2527.85 |              | 
##                                |       155.37 |       198.45 |       143.77 |              | 
##                                |         0.75 |         0.17 |         0.08 |         0.29 | 
##                                |         0.32 |         0.23 |         0.22 |              | 
##                                |         0.22 |         0.05 |         0.02 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
##                   Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                |         0.69 |         0.21 |         0.11 |              | 
## -------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  874     d.f. =  6     p =  1.3e-185 
## 
## 
## 
CrossTable(main_processed$Attendance.MonthYear, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                     | main_processed$Record.Type 
## main_processed$Attendance.MonthYear |   Attendance | Cancellation |          DNA |    Row Total | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Apr-20 |          435 |          591 |          103 |         1129 | 
##                                     |       774.80 |       233.88 |       120.32 |              | 
##                                     |       149.03 |       545.32 |         2.49 |              | 
##                                     |         0.39 |         0.52 |         0.09 |         0.01 | 
##                                     |         0.01 |         0.03 |         0.01 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Apr-21 |          999 |          296 |          166 |         1461 | 
##                                     |      1002.64 |       302.65 |       155.71 |              | 
##                                     |         0.01 |         0.15 |         0.68 |              | 
##                                     |         0.68 |         0.20 |         0.11 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Apr-22 |         1152 |          419 |          206 |         1777 | 
##                                     |      1219.51 |       368.11 |       189.38 |              | 
##                                     |         3.74 |         7.04 |         1.46 |              | 
##                                     |         0.65 |         0.24 |         0.12 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Apr-23 |         1240 |          334 |          161 |         1735 | 
##                                     |      1190.68 |       359.41 |       184.91 |              | 
##                                     |         2.04 |         1.80 |         3.09 |              | 
##                                     |         0.71 |         0.19 |         0.09 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Aug-20 |          893 |          324 |          127 |         1344 | 
##                                     |       922.35 |       278.41 |       143.24 |              | 
##                                     |         0.93 |         7.46 |         1.84 |              | 
##                                     |         0.66 |         0.24 |         0.09 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.01 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Aug-21 |         1131 |          292 |          254 |         1677 | 
##                                     |      1150.88 |       347.39 |       178.73 |              | 
##                                     |         0.34 |         8.83 |        31.70 |              | 
##                                     |         0.67 |         0.17 |         0.15 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Aug-22 |         1189 |          432 |          188 |         1809 | 
##                                     |      1241.47 |       374.74 |       192.79 |              | 
##                                     |         2.22 |         8.75 |         0.12 |              | 
##                                     |         0.66 |         0.24 |         0.10 |         0.02 | 
##                                     |         0.02 |         0.03 |         0.02 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Aug-23 |         1514 |          319 |          174 |         2007 | 
##                                     |      1377.35 |       415.76 |       213.90 |              | 
##                                     |        13.56 |        22.52 |         7.44 |              | 
##                                     |         0.75 |         0.16 |         0.09 |         0.02 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Dec-20 |          938 |          251 |          188 |         1377 | 
##                                     |       945.00 |       285.25 |       146.75 |              | 
##                                     |         0.05 |         4.11 |        11.59 |              | 
##                                     |         0.68 |         0.18 |         0.14 |         0.02 | 
##                                     |         0.02 |         0.01 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Dec-21 |          989 |          371 |          205 |         1565 | 
##                                     |      1074.02 |       324.19 |       166.79 |              | 
##                                     |         6.73 |         6.76 |         8.75 |              | 
##                                     |         0.63 |         0.24 |         0.13 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Dec-22 |         1323 |          299 |          156 |         1778 | 
##                                     |      1220.19 |       368.32 |       189.49 |              | 
##                                     |         8.66 |        13.05 |         5.92 |              | 
##                                     |         0.74 |         0.17 |         0.09 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Dec-23 |         1178 |          298 |          143 |         1619 | 
##                                     |      1111.08 |       335.38 |       172.54 |              | 
##                                     |         4.03 |         4.17 |         5.06 |              | 
##                                     |         0.73 |         0.18 |         0.09 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Feb-20 |         1272 |          300 |          205 |         1777 | 
##                                     |      1219.51 |       368.11 |       189.38 |              | 
##                                     |         2.26 |        12.60 |         1.29 |              | 
##                                     |         0.72 |         0.17 |         0.12 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Feb-21 |          848 |          419 |           94 |         1361 | 
##                                     |       934.02 |       281.93 |       145.05 |              | 
##                                     |         7.92 |        66.64 |        17.97 |              | 
##                                     |         0.62 |         0.31 |         0.07 |         0.02 | 
##                                     |         0.01 |         0.02 |         0.01 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Feb-22 |         1133 |          376 |          203 |         1712 | 
##                                     |      1174.90 |       354.65 |       182.46 |              | 
##                                     |         1.49 |         1.29 |         2.31 |              | 
##                                     |         0.66 |         0.22 |         0.12 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Feb-23 |         1452 |          278 |          151 |         1881 | 
##                                     |      1290.88 |       389.65 |       200.47 |              | 
##                                     |        20.11 |        31.99 |        12.21 |              | 
##                                     |         0.77 |         0.15 |         0.08 |         0.02 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jan-20 |         1347 |          108 |           79 |         1534 | 
##                                     |      1052.74 |       317.77 |       163.49 |              | 
##                                     |        82.25 |       138.48 |        43.66 |              | 
##                                     |         0.88 |         0.07 |         0.05 |         0.02 | 
##                                     |         0.02 |         0.01 |         0.01 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jan-21 |          846 |          545 |          159 |         1550 | 
##                                     |      1063.72 |       321.09 |       165.19 |              | 
##                                     |        44.56 |       156.15 |         0.23 |              | 
##                                     |         0.55 |         0.35 |         0.10 |         0.02 | 
##                                     |         0.01 |         0.03 |         0.02 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jan-22 |         1069 |          380 |          230 |         1679 | 
##                                     |      1152.25 |       347.81 |       178.94 |              | 
##                                     |         6.02 |         2.98 |        14.57 |              | 
##                                     |         0.64 |         0.23 |         0.14 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jan-23 |         1584 |          378 |          175 |         2137 | 
##                                     |      1466.56 |       442.69 |       227.75 |              | 
##                                     |         9.40 |         9.45 |        12.22 |              | 
##                                     |         0.74 |         0.18 |         0.08 |         0.03 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jul-20 |          937 |          275 |           99 |         1311 | 
##                                     |       899.70 |       271.58 |       139.72 |              | 
##                                     |         1.55 |         0.04 |        11.87 |              | 
##                                     |         0.71 |         0.21 |         0.08 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.01 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jul-21 |         1161 |          302 |          264 |         1727 | 
##                                     |      1185.19 |       357.75 |       184.05 |              | 
##                                     |         0.49 |         8.69 |        34.72 |              | 
##                                     |         0.67 |         0.17 |         0.15 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jul-22 |         1193 |          326 |          279 |         1798 | 
##                                     |      1233.92 |       372.46 |       191.62 |              | 
##                                     |         1.36 |         5.80 |        39.84 |              | 
##                                     |         0.66 |         0.18 |         0.16 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jul-23 |         1494 |          315 |          165 |         1974 | 
##                                     |      1354.70 |       408.92 |       210.38 |              | 
##                                     |        14.32 |        21.57 |         9.79 |              | 
##                                     |         0.76 |         0.16 |         0.08 |         0.02 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jun-20 |          689 |          329 |          123 |         1141 | 
##                                     |       783.04 |       236.36 |       121.60 |              | 
##                                     |        11.29 |        36.31 |         0.02 |              | 
##                                     |         0.60 |         0.29 |         0.11 |         0.01 | 
##                                     |         0.01 |         0.02 |         0.01 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jun-21 |         1114 |          313 |          209 |         1636 | 
##                                     |      1122.74 |       338.90 |       174.36 |              | 
##                                     |         0.07 |         1.98 |         6.88 |              | 
##                                     |         0.68 |         0.19 |         0.13 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jun-22 |         1176 |          377 |          233 |         1786 | 
##                                     |      1225.68 |       369.97 |       190.34 |              | 
##                                     |         2.01 |         0.13 |         9.56 |              | 
##                                     |         0.66 |         0.21 |         0.13 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Jun-23 |         1501 |          314 |          118 |         1933 | 
##                                     |      1326.56 |       400.43 |       206.01 |              | 
##                                     |        22.94 |        18.65 |        37.60 |              | 
##                                     |         0.78 |         0.16 |         0.06 |         0.02 | 
##                                     |         0.03 |         0.02 |         0.01 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Mar-20 |          779 |          735 |          247 |         1761 | 
##                                     |      1208.53 |       364.80 |       187.68 |              | 
##                                     |       152.66 |       375.69 |        18.75 |              | 
##                                     |         0.44 |         0.42 |         0.14 |         0.02 | 
##                                     |         0.01 |         0.04 |         0.03 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Mar-21 |         1136 |          349 |          146 |         1631 | 
##                                     |      1119.31 |       337.87 |       173.82 |              | 
##                                     |         0.25 |         0.37 |         4.45 |              | 
##                                     |         0.70 |         0.21 |         0.09 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Mar-22 |         1144 |          476 |          220 |         1840 | 
##                                     |      1262.74 |       381.16 |       196.10 |              | 
##                                     |        11.17 |        23.60 |         2.91 |              | 
##                                     |         0.62 |         0.26 |         0.12 |         0.02 | 
##                                     |         0.02 |         0.03 |         0.03 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Mar-23 |         1632 |          305 |          155 |         2092 | 
##                                     |      1435.68 |       433.36 |       222.95 |              | 
##                                     |        26.84 |        38.02 |        20.71 |              | 
##                                     |         0.78 |         0.15 |         0.07 |         0.03 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              May-20 |          513 |          359 |           82 |          954 | 
##                                     |       654.70 |       197.62 |       101.67 |              | 
##                                     |        30.67 |       131.78 |         3.81 |              | 
##                                     |         0.54 |         0.38 |         0.09 |         0.01 | 
##                                     |         0.01 |         0.02 |         0.01 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              May-21 |         1060 |          334 |          192 |         1586 | 
##                                     |      1088.43 |       328.54 |       169.03 |              | 
##                                     |         0.74 |         0.09 |         3.12 |              | 
##                                     |         0.67 |         0.21 |         0.12 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              May-22 |         1339 |          418 |          260 |         2017 | 
##                                     |      1384.21 |       417.83 |       214.96 |              | 
##                                     |         1.48 |         0.00 |         9.44 |              | 
##                                     |         0.66 |         0.21 |         0.13 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.02 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              May-23 |         1579 |          373 |          156 |         2108 | 
##                                     |      1446.66 |       436.68 |       224.66 |              | 
##                                     |        12.11 |         9.29 |        20.98 |              | 
##                                     |         0.75 |         0.18 |         0.07 |         0.03 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Nov-20 |          998 |          315 |          141 |         1454 | 
##                                     |       997.84 |       301.20 |       154.96 |              | 
##                                     |         0.00 |         0.63 |         1.26 |              | 
##                                     |         0.69 |         0.22 |         0.10 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Nov-21 |         1221 |          384 |          285 |         1890 | 
##                                     |      1297.06 |       391.52 |       201.43 |              | 
##                                     |         4.46 |         0.14 |        34.68 |              | 
##                                     |         0.65 |         0.20 |         0.15 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Nov-22 |         1621 |          371 |          177 |         2169 | 
##                                     |      1488.53 |       449.31 |       231.16 |              | 
##                                     |        11.79 |        13.65 |        12.69 |              | 
##                                     |         0.75 |         0.17 |         0.08 |         0.03 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Nov-23 |         1579 |          349 |          173 |         2101 | 
##                                     |      1441.86 |       435.23 |       223.91 |              | 
##                                     |        13.04 |        17.08 |        11.58 |              | 
##                                     |         0.75 |         0.17 |         0.08 |         0.03 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Oct-20 |         1002 |          296 |          191 |         1489 | 
##                                     |      1021.86 |       308.45 |       158.69 |              | 
##                                     |         0.39 |         0.50 |         6.58 |              | 
##                                     |         0.67 |         0.20 |         0.13 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Oct-21 |         1129 |          325 |          232 |         1686 | 
##                                     |      1157.06 |       349.26 |       179.69 |              | 
##                                     |         0.68 |         1.69 |        15.23 |              | 
##                                     |         0.67 |         0.19 |         0.14 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Oct-22 |         1427 |          327 |          178 |         1932 | 
##                                     |      1325.88 |       400.22 |       205.90 |              | 
##                                     |         7.71 |        13.40 |         3.78 |              | 
##                                     |         0.74 |         0.17 |         0.09 |         0.02 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Oct-23 |         1526 |          347 |          176 |         2049 | 
##                                     |      1406.17 |       424.46 |       218.37 |              | 
##                                     |        10.21 |        14.13 |         8.22 |              | 
##                                     |         0.74 |         0.17 |         0.09 |         0.02 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Sep-20 |         1061 |          427 |          213 |         1701 | 
##                                     |      1167.35 |       352.37 |       181.28 |              | 
##                                     |         9.69 |        15.81 |         5.55 |              | 
##                                     |         0.62 |         0.25 |         0.13 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.02 |              | 
##                                     |         0.01 |         0.01 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Sep-21 |         1118 |          330 |          293 |         1741 | 
##                                     |      1194.80 |       360.65 |       185.55 |              | 
##                                     |         4.94 |         2.61 |        62.23 |              | 
##                                     |         0.64 |         0.19 |         0.17 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.01 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Sep-22 |         1397 |          402 |          245 |         2044 | 
##                                     |      1402.74 |       423.42 |       217.84 |              | 
##                                     |         0.02 |         1.08 |         3.39 |              | 
##                                     |         0.68 |         0.20 |         0.12 |         0.02 | 
##                                     |         0.02 |         0.02 |         0.03 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                              Sep-23 |         1589 |          316 |          178 |         2083 | 
##                                     |      1429.51 |       431.50 |       222.00 |              | 
##                                     |        17.80 |        30.92 |         8.72 |              | 
##                                     |         0.76 |         0.15 |         0.09 |         0.03 | 
##                                     |         0.03 |         0.02 |         0.02 |              | 
##                                     |         0.02 |         0.00 |         0.00 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
##                        Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                     |         0.69 |         0.21 |         0.11 |              | 
## ------------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  3162     d.f. =  94     p =  0 
## 
## 
## 
### & difference of days
bartlett.test(main_processed$daysDiff_attendanceAppoint,main_processed$Record.Type)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  main_processed$daysDiff_attendanceAppoint and main_processed$Record.Type
## Bartlett's K-squared = 29, df = 1, p-value = 6e-08
kruskal.test(main_processed$daysDiff_attendanceAppoint ~ main_processed$Record.Type, data=main_processed)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  main_processed$daysDiff_attendanceAppoint by main_processed$Record.Type
## Kruskal-Wallis chi-squared = 5, df = 1, p-value = 0.03
dunn_result <- dunn.test(main_processed$daysDiff_attendanceAppoint, g=main_processed$Record.Type, method="bonferroni")
##   Kruskal-Wallis rank sum test
## 
## data: x and group
## Kruskal-Wallis chi-squared = 5.0153, df = 1, p-value = 0.03
## 
## 
##                            Comparison of x by group                            
##                                  (Bonferroni)                                  
## Col Mean-|
## Row Mean |   Cancella
## ---------+-----------
##      DNA |  -2.239482
##          |    0.0126*
## 
## alpha = 0.05
## Reject Ho if p <= alpha/2
bartlett.test(main_processed$daysDiff_attendanceBooked,main_processed$Record.Type)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  main_processed$daysDiff_attendanceBooked and main_processed$Record.Type
## Bartlett's K-squared = 2420, df = 2, p-value <2e-16
kruskal.test(main_processed$daysDiff_attendanceBooked ~ main_processed$Record.Type, data=main_processed)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  main_processed$daysDiff_attendanceBooked by main_processed$Record.Type
## Kruskal-Wallis chi-squared = 3583, df = 2, p-value <2e-16
dunn_result <- dunn.test(main_processed$daysDiff_attendanceBooked, g=main_processed$Record.Type, method="bonferroni")
##   Kruskal-Wallis rank sum test
## 
## data: x and group
## Kruskal-Wallis chi-squared = 3583.4806, df = 2, p-value = 0
## 
## 
##                            Comparison of x by group                            
##                                  (Bonferroni)                                  
## Col Mean-|
## Row Mean |   Attendan   Cancella
## ---------+----------------------
## Cancella |   59.36667
##          |    0.0000*
##          |
##      DNA |   18.95871  -23.30438
##          |    0.0000*    0.0000*
## 
## alpha = 0.05
## Reject Ho if p <= alpha/2
## Record Type & Patient characteristics relevance
CrossTable(main_processed$Gender, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                       | main_processed$Record.Type 
## main_processed$Gender |   Attendance | Cancellation |          DNA |    Row Total | 
## ----------------------|--------------|--------------|--------------|--------------|
##                Female |        28325 |         9417 |         3739 |        41481 | 
##                       |     28467.27 |      8592.90 |      4420.83 |              | 
##                       |         0.71 |        79.04 |       105.16 |              | 
##                       |         0.68 |         0.23 |         0.09 |         0.50 | 
##                       |         0.50 |         0.55 |         0.43 |              | 
##                       |         0.34 |         0.11 |         0.05 |              | 
## ----------------------|--------------|--------------|--------------|--------------|
##                  Male |        28317 |         7682 |         5057 |        41056 | 
##                       |     28175.61 |      8504.86 |      4375.53 |              | 
##                       |         0.71 |        79.61 |       106.13 |              | 
##                       |         0.69 |         0.19 |         0.12 |         0.50 | 
##                       |         0.50 |         0.45 |         0.57 |              | 
##                       |         0.34 |         0.09 |         0.06 |              | 
## ----------------------|--------------|--------------|--------------|--------------|
##               Unknown |            5 |            0 |            1 |            6 | 
##                       |         4.12 |         1.24 |         0.64 |              | 
##                       |         0.19 |         1.24 |         0.20 |              | 
##                       |         0.83 |         0.00 |         0.17 |         0.00 | 
##                       |         0.00 |         0.00 |         0.00 |              | 
##                       |         0.00 |         0.00 |         0.00 |              | 
## ----------------------|--------------|--------------|--------------|--------------|
##          Column Total |        56647 |        17099 |         8797 |        82543 | 
##                       |         0.69 |         0.21 |         0.11 |              | 
## ----------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  373     d.f. =  4     p =  1.9e-79 
## 
## 
## 
CrossTable(main_processed$Age.at.Attendance.Cat.HSE, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE) #age group
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                          | main_processed$Record.Type 
## main_processed$Age.at.Attendance.Cat.HSE |   Attendance | Cancellation |          DNA |    Row Total | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                    0 - 4 |            2 |            5 |            2 |            9 | 
##                                          |         6.18 |         1.86 |         0.96 |              | 
##                                          |         2.82 |         5.27 |         1.13 |              | 
##                                          |         0.22 |         0.56 |         0.22 |         0.00 | 
##                                          |         0.00 |         0.00 |         0.00 |              | 
##                                          |         0.00 |         0.00 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                   05-Sep |            0 |            1 |            0 |            1 | 
##                                          |         0.69 |         0.21 |         0.11 |              | 
##                                          |         0.69 |         3.03 |         0.11 |              | 
##                                          |         0.00 |         1.00 |         0.00 |         0.00 | 
##                                          |         0.00 |         0.00 |         0.00 |              | 
##                                          |         0.00 |         0.00 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                  15 - 24 |         6413 |         1457 |         1162 |         9032 | 
##                                          |      6198.41 |      1871.00 |       962.58 |              | 
##                                          |         7.43 |        91.61 |        41.31 |              | 
##                                          |         0.71 |         0.16 |         0.13 |         0.11 | 
##                                          |         0.11 |         0.09 |         0.13 |              | 
##                                          |         0.08 |         0.02 |         0.01 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                  25 - 34 |         8202 |         1824 |         1559 |        11585 | 
##                                          |      7950.47 |      2399.86 |      1234.67 |              | 
##                                          |         7.96 |       138.18 |        85.20 |              | 
##                                          |         0.71 |         0.16 |         0.13 |         0.14 | 
##                                          |         0.14 |         0.11 |         0.18 |              | 
##                                          |         0.10 |         0.02 |         0.02 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                  35 - 44 |         8527 |         2530 |         1554 |        12611 | 
##                                          |      8654.58 |      2612.40 |      1344.01 |              | 
##                                          |         1.88 |         2.60 |        32.81 |              | 
##                                          |         0.68 |         0.20 |         0.12 |         0.15 | 
##                                          |         0.15 |         0.15 |         0.18 |              | 
##                                          |         0.10 |         0.03 |         0.02 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                  45 - 54 |         9890 |         3109 |         1509 |        14508 | 
##                                          |      9956.44 |      3005.37 |      1546.19 |              | 
##                                          |         0.44 |         3.57 |         0.89 |              | 
##                                          |         0.68 |         0.21 |         0.10 |         0.18 | 
##                                          |         0.17 |         0.18 |         0.17 |              | 
##                                          |         0.12 |         0.04 |         0.02 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                  55 - 64 |        10402 |         3319 |         1227 |        14948 | 
##                                          |     10258.40 |      3096.52 |      1593.08 |              | 
##                                          |         2.01 |        15.99 |        84.12 |              | 
##                                          |         0.70 |         0.22 |         0.08 |         0.18 | 
##                                          |         0.18 |         0.19 |         0.14 |              | 
##                                          |         0.13 |         0.04 |         0.01 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                  65 - 74 |         8174 |         2825 |          914 |        11913 | 
##                                          |      8175.57 |      2467.81 |      1269.63 |              | 
##                                          |         0.00 |        51.70 |        99.61 |              | 
##                                          |         0.69 |         0.24 |         0.08 |         0.14 | 
##                                          |         0.14 |         0.17 |         0.10 |              | 
##                                          |         0.10 |         0.03 |         0.01 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                  75 - 84 |         4009 |         1584 |          643 |         6236 | 
##                                          |      4279.60 |      1291.80 |       664.60 |              | 
##                                          |        17.11 |        66.09 |         0.70 |              | 
##                                          |         0.64 |         0.25 |         0.10 |         0.08 | 
##                                          |         0.07 |         0.09 |         0.07 |              | 
##                                          |         0.05 |         0.02 |         0.01 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                    85 >= |         1015 |          444 |          227 |         1686 | 
##                                          |      1157.06 |       349.26 |       179.69 |              | 
##                                          |        17.44 |        25.70 |        12.46 |              | 
##                                          |         0.60 |         0.26 |         0.13 |         0.02 | 
##                                          |         0.02 |         0.03 |         0.03 |              | 
##                                          |         0.01 |         0.01 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                                   Oct-14 |           13 |            1 |            0 |           14 | 
##                                          |         9.61 |         2.90 |         1.49 |              | 
##                                          |         1.20 |         1.24 |         1.49 |              | 
##                                          |         0.93 |         0.07 |         0.00 |         0.00 | 
##                                          |         0.00 |         0.00 |         0.00 |              | 
##                                          |         0.00 |         0.00 |         0.00 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
##                             Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                          |         0.69 |         0.21 |         0.11 |              | 
## -----------------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  824     d.f. =  20     p =  1.2e-161 
## 
## 
## 
bartlett.test(main_processed$Age.at.Attendance,main_processed$Record.Type) # unequal variances
## 
##  Bartlett test of homogeneity of variances
## 
## data:  main_processed$Age.at.Attendance and main_processed$Record.Type
## Bartlett's K-squared = 16, df = 2, p-value = 3e-04
kruskal.test(main_processed$Age.at.Attendance ~ main_processed$Record.Type, data=main_processed)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  main_processed$Age.at.Attendance by main_processed$Record.Type
## Kruskal-Wallis chi-squared = 621, df = 2, p-value <2e-16
dunn_result <- dunn.test(main_processed$Age.at.Attendance, g=main_processed$Record.Type, method="bonferroni") #run library(dunn.test) for this test
##   Kruskal-Wallis rank sum test
## 
## data: x and group
## Kruskal-Wallis chi-squared = 621.0394, df = 2, p-value = 0
## 
## 
##                            Comparison of x by group                            
##                                  (Bonferroni)                                  
## Col Mean-|
## Row Mean |   Attendan   Cancella
## ---------+----------------------
## Cancella |  -19.29601
##          |    0.0000*
##          |
##      DNA |   12.11606   23.41437
##          |    0.0000*    0.0000*
## 
## alpha = 0.05
## Reject Ho if p <= alpha/2
CrossTable(main_processed$Area.of.Residence_recode, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                         | main_processed$Record.Type 
## main_processed$Area.of.Residence_recode |   Attendance | Cancellation |          DNA |    Row Total | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##                              DUBLIN NTH |        37613 |         9639 |         5897 |        53149 | 
##                                         |     36474.70 |     11009.96 |      5664.34 |              | 
##                                         |        35.52 |       170.71 |         9.56 |              | 
##                                         |         0.71 |         0.18 |         0.11 |         0.64 | 
##                                         |         0.66 |         0.56 |         0.67 |              | 
##                                         |         0.46 |         0.12 |         0.07 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##                              DUBLIN STH |         7770 |         1894 |         1254 |        10918 | 
##                                         |      7492.72 |      2261.69 |      1163.58 |              | 
##                                         |        10.26 |        59.78 |         7.03 |              | 
##                                         |         0.71 |         0.17 |         0.11 |         0.13 | 
##                                         |         0.14 |         0.11 |         0.14 |              | 
##                                         |         0.09 |         0.02 |         0.02 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##  EASTERN & MIDLAND REGION (excl.Dublin) |         7024 |         3086 |          981 |        11091 | 
##                                         |      7611.45 |      2297.53 |      1182.02 |              | 
##                                         |        45.34 |       270.59 |        34.19 |              | 
##                                         |         0.63 |         0.28 |         0.09 |         0.13 | 
##                                         |         0.12 |         0.18 |         0.11 |              | 
##                                         |         0.09 |         0.04 |         0.01 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##                 NORTHERN WESTERN REGION |         1689 |         1000 |          229 |         2918 | 
##                                         |      2002.54 |       604.47 |       310.99 |              | 
##                                         |        49.09 |       258.81 |        21.61 |              | 
##                                         |         0.58 |         0.34 |         0.08 |         0.04 | 
##                                         |         0.03 |         0.06 |         0.03 |              | 
##                                         |         0.02 |         0.01 |         0.00 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##                         OUTSIDE IRELAND |           93 |           24 |           20 |          137 | 
##                                         |        94.02 |        28.38 |        14.60 |              | 
##                                         |         0.01 |         0.68 |         2.00 |              | 
##                                         |         0.68 |         0.18 |         0.15 |         0.00 | 
##                                         |         0.00 |         0.00 |         0.00 |              | 
##                                         |         0.00 |         0.00 |         0.00 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##                         SOUTHERN REGION |         2261 |         1373 |          365 |         3999 | 
##                                         |      2744.40 |       828.40 |       426.19 |              | 
##                                         |        85.15 |       358.02 |         8.79 |              | 
##                                         |         0.57 |         0.34 |         0.09 |         0.05 | 
##                                         |         0.04 |         0.08 |         0.04 |              | 
##                                         |         0.03 |         0.02 |         0.00 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##                                 UNKNOWN |          197 |           83 |           51 |          331 | 
##                                         |       227.16 |        68.57 |        35.28 |              | 
##                                         |         4.00 |         3.04 |         7.01 |              | 
##                                         |         0.60 |         0.25 |         0.15 |         0.00 | 
##                                         |         0.00 |         0.00 |         0.01 |              | 
##                                         |         0.00 |         0.00 |         0.00 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
##                            Column Total |        56647 |        17099 |         8797 |        82543 | 
##                                         |         0.69 |         0.21 |         0.11 |              | 
## ----------------------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  1441     d.f. =  12     p =  1.8e-301 
## 
## 
## 
CrossTable(main_processed$addressDiff, main_processed$Record.Type, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                            | main_processed$Record.Type 
## main_processed$addressDiff |   Attendance | Cancellation |          DNA |    Row Total | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                          0 |        49341 |        14025 |         6754 |        70120 | 
##                            |     48121.44 |     14525.54 |      7473.02 |              | 
##                            |        30.91 |        17.25 |        69.18 |              | 
##                            |         0.70 |         0.20 |         0.10 |         0.85 | 
##                            |         0.87 |         0.82 |         0.77 |              | 
##                            |         0.60 |         0.17 |         0.08 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##                          1 |         7306 |         3074 |         2043 |        12423 | 
##                            |      8525.56 |      2573.46 |      1323.98 |              | 
##                            |       174.46 |        97.36 |       390.48 |              | 
##                            |         0.59 |         0.25 |         0.16 |         0.15 | 
##                            |         0.13 |         0.18 |         0.23 |              | 
##                            |         0.09 |         0.04 |         0.02 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
##               Column Total |        56647 |        17099 |         8797 |        82543 | 
##                            |         0.69 |         0.21 |         0.11 |              | 
## ---------------------------|--------------|--------------|--------------|--------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  780     d.f. =  2     p =  5.1e-170 
## 
## 
## 

Cancellation & DNA correlation

  • Clinic relevance: Consultant, Insurance scheme, Eligibility, Hospital catchment, Clinic type, Clinic code, Referral source, Booking Type
  • Date relevance: booked Day, booked Month-Year, appointment Day, appointment Month-Year, daysDiff_AppointBooked, attendance Day, attendance Month-Year
  • Patient relevance: Gender, Age at attendance, Area of residence, address difference
  • Cancellation group: Reason for cancellation, Rebooked indicator
# cancellation (No.Cancels=1) & DNA (No.Cancels=0)

## clinic relevance
CrossTable(main_processed$Clinic.Type_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                   | main_processed$No.Cancels 
## main_processed$Clinic.Type_recode |         0 |         1 | Row Total | 
## ----------------------------------|-----------|-----------|-----------|
##                  BACK_PAINrelated |        16 |       152 |       168 | 
##                                   |     57.07 |    110.93 |           | 
##                                   |     29.56 |     15.21 |           | 
##                                   |      0.10 |      0.90 |      0.01 | 
##                                   |      0.00 |      0.01 |           | 
##                                   |      0.00 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                           GENERAL |      6775 |     10696 |     17471 | 
##                                   |   5934.99 |  11536.01 |           | 
##                                   |    118.89 |     61.17 |           | 
##                                   |      0.39 |      0.61 |      0.67 | 
##                                   |      0.77 |      0.63 |           | 
##                                   |      0.26 |      0.41 |           | 
## ----------------------------------|-----------|-----------|-----------|
##            MUSCULOSKELETALrelated |       772 |      2014 |      2786 | 
##                                   |    946.42 |   1839.58 |           | 
##                                   |     32.14 |     16.54 |           | 
##                                   |      0.28 |      0.72 |      0.11 | 
##                                   |      0.09 |      0.12 |           | 
##                                   |      0.03 |      0.08 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                 NotLocatedInMater |        89 |       225 |       314 | 
##                                   |    106.67 |    207.33 |           | 
##                                   |      2.93 |      1.51 |           | 
##                                   |      0.28 |      0.72 |      0.01 | 
##                                   |      0.01 |      0.01 |           | 
##                                   |      0.00 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                          NTPFfund |        60 |        70 |       130 | 
##                                   |     44.16 |     85.84 |           | 
##                                   |      5.68 |      2.92 |           | 
##                                   |      0.46 |      0.54 |      0.01 | 
##                                   |      0.01 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                          PODIATRY |       132 |        64 |       196 | 
##                                   |     66.58 |    129.42 |           | 
##                                   |     64.27 |     33.07 |           | 
##                                   |      0.67 |      0.33 |      0.01 | 
##                                   |      0.02 |      0.00 |           | 
##                                   |      0.01 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      SPINErelated |       833 |      3566 |      4399 | 
##                                   |   1494.36 |   2904.64 |           | 
##                                   |    292.70 |    150.59 |           | 
##                                   |      0.19 |      0.81 |      0.17 | 
##                                   |      0.09 |      0.21 |           | 
##                                   |      0.03 |      0.14 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                 UPPER_LIMBrelated |       120 |       312 |       432 | 
##                                   |    146.75 |    285.25 |           | 
##                                   |      4.88 |      2.51 |           | 
##                                   |      0.28 |      0.72 |      0.02 | 
##                                   |      0.01 |      0.02 |           | 
##                                   |      0.00 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      Column Total |      8797 |     17099 |     25896 | 
##                                   |      0.34 |      0.66 |           | 
## ----------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  835     d.f. =  7     p =  6.5e-176 
## 
## 
## 
CrossTable(main_processed$Clinic.Code, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                            | main_processed$No.Cancels 
## main_processed$Clinic.Code |         0 |         1 | Row Total | 
## ---------------------------|-----------|-----------|-----------|
##                        184 |        22 |       108 |       130 | 
##                            |     44.16 |     85.84 |           | 
##                            |     11.12 |      5.72 |           | 
##                            |      0.17 |      0.83 |      0.01 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        211 |        91 |       186 |       277 | 
##                            |     94.10 |    182.90 |           | 
##                            |      0.10 |      0.05 |           | 
##                            |      0.33 |      0.67 |      0.01 | 
##                            |      0.01 |      0.01 |           | 
##                            |      0.00 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        416 |       169 |       318 |       487 | 
##                            |    165.44 |    321.56 |           | 
##                            |      0.08 |      0.04 |           | 
##                            |      0.35 |      0.65 |      0.02 | 
##                            |      0.02 |      0.02 |           | 
##                            |      0.01 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        444 |       265 |       396 |       661 | 
##                            |    224.54 |    436.46 |           | 
##                            |      7.29 |      3.75 |           | 
##                            |      0.40 |      0.60 |      0.03 | 
##                            |      0.03 |      0.02 |           | 
##                            |      0.01 |      0.02 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        524 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        726 |       804 |      1155 |      1959 | 
##                            |    665.48 |   1293.52 |           | 
##                            |     28.83 |     14.83 |           | 
##                            |      0.41 |      0.59 |      0.08 | 
##                            |      0.09 |      0.07 |           | 
##                            |      0.03 |      0.04 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        741 |         0 |         1 |         1 | 
##                            |      0.34 |      0.66 |           | 
##                            |      0.34 |      0.17 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        778 |         6 |        67 |        73 | 
##                            |     24.80 |     48.20 |           | 
##                            |     14.25 |      7.33 |           | 
##                            |      0.08 |      0.92 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        784 |         9 |        18 |        27 | 
##                            |      9.17 |     17.83 |           | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.33 |      0.67 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        786 |       486 |      1697 |      2183 | 
##                            |    741.58 |   1441.42 |           | 
##                            |     88.08 |     45.32 |           | 
##                            |      0.22 |      0.78 |      0.08 | 
##                            |      0.06 |      0.10 |           | 
##                            |      0.02 |      0.07 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        791 |         0 |         1 |         1 | 
##                            |      0.34 |      0.66 |           | 
##                            |      0.34 |      0.17 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        792 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        793 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        806 |       209 |       759 |       968 | 
##                            |    328.83 |    639.17 |           | 
##                            |     43.67 |     22.47 |           | 
##                            |      0.22 |      0.78 |      0.04 | 
##                            |      0.02 |      0.04 |           | 
##                            |      0.01 |      0.03 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        846 |        28 |        77 |       105 | 
##                            |     35.67 |     69.33 |           | 
##                            |      1.65 |      0.85 |           | 
##                            |      0.27 |      0.73 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        847 |         9 |       201 |       210 | 
##                            |     71.34 |    138.66 |           | 
##                            |     54.47 |     28.03 |           | 
##                            |      0.04 |      0.96 |      0.01 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        849 |       309 |      1375 |      1684 | 
##                            |    572.06 |   1111.94 |           | 
##                            |    120.97 |     62.24 |           | 
##                            |      0.18 |      0.82 |      0.07 | 
##                            |      0.04 |      0.08 |           | 
##                            |      0.01 |      0.05 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        854 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        921 |         2 |         0 |         2 | 
##                            |      0.68 |      1.32 |           | 
##                            |      2.57 |      1.32 |           | 
##                            |      1.00 |      0.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1031 |         1 |         4 |         5 | 
##                            |      1.70 |      3.30 |           | 
##                            |      0.29 |      0.15 |           | 
##                            |      0.20 |      0.80 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1038 |      1306 |      1163 |      2469 | 
##                            |    838.73 |   1630.27 |           | 
##                            |    260.32 |    133.93 |           | 
##                            |      0.53 |      0.47 |      0.10 | 
##                            |      0.15 |      0.07 |           | 
##                            |      0.05 |      0.04 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1059 |       760 |      1982 |      2742 | 
##                            |    931.47 |   1810.53 |           | 
##                            |     31.57 |     16.24 |           | 
##                            |      0.28 |      0.72 |      0.11 | 
##                            |      0.09 |      0.12 |           | 
##                            |      0.03 |      0.08 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1065 |       276 |       827 |      1103 | 
##                            |    374.69 |    728.31 |           | 
##                            |     26.00 |     13.37 |           | 
##                            |      0.25 |      0.75 |      0.04 | 
##                            |      0.03 |      0.05 |           | 
##                            |      0.01 |      0.03 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1095 |       132 |        64 |       196 | 
##                            |     66.58 |    129.42 |           | 
##                            |     64.27 |     33.07 |           | 
##                            |      0.67 |      0.33 |      0.01 | 
##                            |      0.02 |      0.00 |           | 
##                            |      0.01 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1114 |       119 |       673 |       792 | 
##                            |    269.05 |    522.95 |           | 
##                            |     83.68 |     43.05 |           | 
##                            |      0.15 |      0.85 |      0.03 | 
##                            |      0.01 |      0.04 |           | 
##                            |      0.00 |      0.03 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1195 |       204 |      1269 |      1473 | 
##                            |    500.39 |    972.61 |           | 
##                            |    175.55 |     90.32 |           | 
##                            |      0.14 |      0.86 |      0.06 | 
##                            |      0.02 |      0.07 |           | 
##                            |      0.01 |      0.05 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1197 |        60 |        66 |       126 | 
##                            |     42.80 |     83.20 |           | 
##                            |      6.91 |      3.55 |           | 
##                            |      0.48 |      0.52 |      0.00 | 
##                            |      0.01 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1198 |         0 |        56 |        56 | 
##                            |     19.02 |     36.98 |           | 
##                            |     19.02 |      9.79 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1206 |       452 |       565 |      1017 | 
##                            |    345.48 |    671.52 |           | 
##                            |     32.84 |     16.90 |           | 
##                            |      0.44 |      0.56 |      0.04 | 
##                            |      0.05 |      0.03 |           | 
##                            |      0.02 |      0.02 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1207 |        29 |       126 |       155 | 
##                            |     52.65 |    102.35 |           | 
##                            |     10.63 |      5.47 |           | 
##                            |      0.19 |      0.81 |      0.01 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1229 |       940 |       846 |      1786 | 
##                            |    606.71 |   1179.29 |           | 
##                            |    183.09 |     94.19 |           | 
##                            |      0.53 |      0.47 |      0.07 | 
##                            |      0.11 |      0.05 |           | 
##                            |      0.04 |      0.03 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1236 |         0 |         4 |         4 | 
##                            |      1.36 |      2.64 |           | 
##                            |      1.36 |      0.70 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1282 |       574 |       535 |      1109 | 
##                            |    376.73 |    732.27 |           | 
##                            |    103.29 |     53.14 |           | 
##                            |      0.52 |      0.48 |      0.04 | 
##                            |      0.07 |      0.03 |           | 
##                            |      0.02 |      0.02 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1283 |       260 |       991 |      1251 | 
##                            |    424.97 |    826.03 |           | 
##                            |     64.04 |     32.95 |           | 
##                            |      0.21 |      0.79 |      0.05 | 
##                            |      0.03 |      0.06 |           | 
##                            |      0.01 |      0.04 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1284 |         1 |         0 |         1 | 
##                            |      0.34 |      0.66 |           | 
##                            |      1.28 |      0.66 |           | 
##                            |      1.00 |      0.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1341 |       457 |       497 |       954 | 
##                            |    324.08 |    629.92 |           | 
##                            |     54.52 |     28.05 |           | 
##                            |      0.48 |      0.52 |      0.04 | 
##                            |      0.05 |      0.03 |           | 
##                            |      0.02 |      0.02 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1362 |         0 |         1 |         1 | 
##                            |      0.34 |      0.66 |           | 
##                            |      0.34 |      0.17 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1363 |        11 |        30 |        41 | 
##                            |     13.93 |     27.07 |           | 
##                            |      0.62 |      0.32 |           | 
##                            |      0.27 |      0.73 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1368 |        11 |        76 |        87 | 
##                            |     29.55 |     57.45 |           | 
##                            |     11.65 |      5.99 |           | 
##                            |      0.13 |      0.87 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1369 |       237 |       270 |       507 | 
##                            |    172.23 |    334.77 |           | 
##                            |     24.36 |     12.53 |           | 
##                            |      0.47 |      0.53 |      0.02 | 
##                            |      0.03 |      0.02 |           | 
##                            |      0.01 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1371 |       419 |       398 |       817 | 
##                            |    277.54 |    539.46 |           | 
##                            |     72.10 |     37.09 |           | 
##                            |      0.51 |      0.49 |      0.03 | 
##                            |      0.05 |      0.02 |           | 
##                            |      0.02 |      0.02 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1383 |        32 |       121 |       153 | 
##                            |     51.97 |    101.03 |           | 
##                            |      7.68 |      3.95 |           | 
##                            |      0.21 |      0.79 |      0.01 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1405 |        40 |        94 |       134 | 
##                            |     45.52 |     88.48 |           | 
##                            |      0.67 |      0.34 |           | 
##                            |      0.30 |      0.70 |      0.01 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1448 |        23 |        38 |        61 | 
##                            |     20.72 |     40.28 |           | 
##                            |      0.25 |      0.13 |           | 
##                            |      0.38 |      0.62 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1467 |        17 |        10 |        27 | 
##                            |      9.17 |     17.83 |           | 
##                            |      6.68 |      3.44 |           | 
##                            |      0.63 |      0.37 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1471 |         6 |        11 |        17 | 
##                            |      5.77 |     11.23 |           | 
##                            |      0.01 |      0.00 |           | 
##                            |      0.35 |      0.65 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1498 |        16 |         4 |        20 | 
##                            |      6.79 |     13.21 |           | 
##                            |     12.47 |      6.42 |           | 
##                            |      0.80 |      0.20 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1505 |         5 |        19 |        24 | 
##                            |      8.15 |     15.85 |           | 
##                            |      1.22 |      0.63 |           | 
##                            |      0.21 |      0.79 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##               Column Total |      8797 |     17099 |     25896 | 
##                            |      0.34 |      0.66 |           | 
## ---------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  47     p =  NaN 
## 
## 
## 
CrossTable(main_processed$NurseFlag, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                          | main_processed$No.Cancels 
## main_processed$NurseFlag |         0 |         1 | Row Total | 
## -------------------------|-----------|-----------|-----------|
##                        N |      7904 |     15047 |     22951 | 
##                          |   7796.57 |  15154.43 |           | 
##                          |      1.48 |      0.76 |           | 
##                          |      0.34 |      0.66 |      0.89 | 
##                          |      0.90 |      0.88 |           | 
##                          |      0.31 |      0.58 |           | 
## -------------------------|-----------|-----------|-----------|
##                        Y |       893 |      2052 |      2945 | 
##                          |   1000.43 |   1944.57 |           | 
##                          |     11.54 |      5.94 |           | 
##                          |      0.30 |      0.70 |      0.11 | 
##                          |      0.10 |      0.12 |           | 
##                          |      0.03 |      0.08 |           | 
## -------------------------|-----------|-----------|-----------|
##             Column Total |      8797 |     17099 |     25896 | 
##                          |      0.34 |      0.66 |           | 
## -------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  20     d.f. =  1     p =  9e-06 
## 
## Pearson's Chi-squared test with Yates' continuity correction 
## ------------------------------------------------------------
## Chi^2 =  20     d.f. =  1     p =  9.9e-06 
## 
## 
CrossTable(main_processed$Referral.Source_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                       | main_processed$No.Cancels 
## main_processed$Referral.Source_recode |         0 |         1 | Row Total | 
## --------------------------------------|-----------|-----------|-----------|
##                                CLINIC |      3485 |      7042 |     10527 | 
##                                       |   3576.07 |   6950.93 |           | 
##                                       |      2.32 |      1.19 |           | 
##                                       |      0.33 |      0.67 |      0.41 | 
##                                       |      0.40 |      0.41 |           | 
##                                       |      0.13 |      0.27 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                        Elsew of Mater |        43 |       113 |       156 | 
##                                       |     52.99 |    103.01 |           | 
##                                       |      1.88 |      0.97 |           | 
##                                       |      0.28 |      0.72 |      0.01 | 
##                                       |      0.00 |      0.01 |           | 
##                                       |      0.00 |      0.00 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                   Elsew outside Mater |       628 |      1882 |      2510 | 
##                                       |    852.66 |   1657.34 |           | 
##                                       |     59.19 |     30.45 |           | 
##                                       |      0.25 |      0.75 |      0.10 | 
##                                       |      0.07 |      0.11 |           | 
##                                       |      0.02 |      0.07 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                        EMERGENCY DEPT |      1838 |      1523 |      3361 | 
##                                       |   1141.75 |   2219.25 |           | 
##                                       |    424.58 |    218.44 |           | 
##                                       |      0.55 |      0.45 |      0.13 | 
##                                       |      0.21 |      0.09 |           | 
##                                       |      0.07 |      0.06 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                                    GP |      1705 |      4704 |      6409 | 
##                                       |   2177.17 |   4231.83 |           | 
##                                       |    102.40 |     52.68 |           | 
##                                       |      0.27 |      0.73 |      0.25 | 
##                                       |      0.19 |      0.28 |           | 
##                                       |      0.07 |      0.18 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                      OTHER CONSULTANT |       193 |       481 |       674 | 
##                                       |    228.96 |    445.04 |           | 
##                                       |      5.65 |      2.91 |           | 
##                                       |      0.29 |      0.71 |      0.03 | 
##                                       |      0.02 |      0.03 |           | 
##                                       |      0.01 |      0.02 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                                  WARD |       905 |      1354 |      2259 | 
##                                       |    767.39 |   1491.61 |           | 
##                                       |     24.68 |     12.69 |           | 
##                                       |      0.40 |      0.60 |      0.09 | 
##                                       |      0.10 |      0.08 |           | 
##                                       |      0.03 |      0.05 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                          Column Total |      8797 |     17099 |     25896 | 
##                                       |      0.34 |      0.66 |           | 
## --------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  940     d.f. =  6     p =  8.3e-200 
## 
## 
## 
# CrossTable(main_processed$Referring.Hospital, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
CrossTable(main_processed$Consultant_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                  | main_processed$No.Cancels 
## main_processed$Consultant_recode |         0 |         1 | Row Total | 
## ---------------------------------|-----------|-----------|-----------|
##                           BRIAIN |       481 |       691 |      1172 | 
##                                  |    398.13 |    773.87 |           | 
##                                  |     17.25 |      8.87 |           | 
##                                  |      0.41 |      0.59 |      0.05 | 
##                                  |      0.05 |      0.04 |           | 
##                                  |      0.02 |      0.03 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           BUTLER |       204 |      1269 |      1473 | 
##                                  |    500.39 |    972.61 |           | 
##                                  |    175.55 |     90.32 |           | 
##                                  |      0.14 |      0.86 |      0.06 | 
##                                  |      0.02 |      0.07 |           | 
##                                  |      0.01 |      0.05 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           CARMOO |         0 |         0 |         0 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |       NaN |       NaN |           | 
##                                  |       NaN |       NaN |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           CASHMA |        37 |       278 |       315 | 
##                                  |    107.01 |    207.99 |           | 
##                                  |     45.80 |     23.56 |           | 
##                                  |      0.12 |      0.88 |      0.01 | 
##                                  |      0.00 |      0.02 |           | 
##                                  |      0.00 |      0.01 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           CASSID |       288 |       991 |      1279 | 
##                                  |    434.48 |    844.52 |           | 
##                                  |     49.39 |     25.41 |           | 
##                                  |      0.23 |      0.77 |      0.05 | 
##                                  |      0.03 |      0.06 |           | 
##                                  |      0.01 |      0.04 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           COLGAN |       940 |       846 |      1786 | 
##                                  |    606.71 |   1179.29 |           | 
##                                  |    183.09 |     94.19 |           | 
##                                  |      0.53 |      0.47 |      0.07 | 
##                                  |      0.11 |      0.05 |           | 
##                                  |      0.04 |      0.03 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           DODDSM |       277 |       831 |      1108 | 
##                                  |    376.39 |    731.61 |           | 
##                                  |     26.25 |     13.50 |           | 
##                                  |      0.25 |      0.75 |      0.04 | 
##                                  |      0.03 |      0.05 |           | 
##                                  |      0.01 |      0.03 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                              FRA |         0 |         0 |         0 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |       NaN |       NaN |           | 
##                                  |       NaN |       NaN |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           HYNESD |       113 |       294 |       407 | 
##                                  |    138.26 |    268.74 |           | 
##                                  |      4.61 |      2.37 |           | 
##                                  |      0.28 |      0.72 |      0.02 | 
##                                  |      0.01 |      0.02 |           | 
##                                  |      0.00 |      0.01 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           LYNCSA |        23 |        38 |        61 | 
##                                  |     20.72 |     40.28 |           | 
##                                  |      0.25 |      0.13 |           | 
##                                  |      0.38 |      0.62 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           LYONSF |       419 |       398 |       817 | 
##                                  |    277.54 |    539.46 |           | 
##                                  |     72.10 |     37.09 |           | 
##                                  |      0.51 |      0.49 |      0.03 | 
##                                  |      0.05 |      0.02 |           | 
##                                  |      0.02 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                             MARA |       457 |       497 |       954 | 
##                                  |    324.08 |    629.92 |           | 
##                                  |     54.52 |     28.05 |           | 
##                                  |      0.48 |      0.52 |      0.04 | 
##                                  |      0.05 |      0.03 |           | 
##                                  |      0.02 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           MCSORK |        16 |         4 |        20 | 
##                                  |      6.79 |     13.21 |           | 
##                                  |     12.47 |      6.42 |           | 
##                                  |      0.80 |      0.20 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                            MOROP |       936 |      1220 |      2156 | 
##                                  |    732.40 |   1423.60 |           | 
##                                  |     56.60 |     29.12 |           | 
##                                  |      0.43 |      0.57 |      0.08 | 
##                                  |      0.11 |      0.07 |           | 
##                                  |      0.04 |      0.05 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                            MORRI |       512 |      1725 |      2237 | 
##                                  |    759.92 |   1477.08 |           | 
##                                  |     80.88 |     41.61 |           | 
##                                  |      0.23 |      0.77 |      0.09 | 
##                                  |      0.06 |      0.10 |           | 
##                                  |      0.02 |      0.07 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           MURMAR |         6 |        67 |        73 | 
##                                  |     24.80 |     48.20 |           | 
##                                  |     14.25 |      7.33 |           | 
##                                  |      0.08 |      0.92 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           OHEIRE |       846 |      1556 |      2402 | 
##                                  |    815.97 |   1586.03 |           | 
##                                  |      1.11 |      0.57 |           | 
##                                  |      0.35 |      0.65 |      0.09 | 
##                                  |      0.10 |      0.09 |           | 
##                                  |      0.03 |      0.06 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           ONEISH |       243 |       281 |       524 | 
##                                  |    178.01 |    345.99 |           | 
##                                  |     23.73 |     12.21 |           | 
##                                  |      0.46 |      0.54 |      0.02 | 
##                                  |      0.03 |      0.02 |           | 
##                                  |      0.01 |      0.01 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           ORTCON |         2 |         0 |         2 | 
##                                  |      0.68 |      1.32 |           | 
##                                  |      2.57 |      1.32 |           | 
##                                  |      1.00 |      0.00 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           SYNNOT |       474 |      1156 |      1630 | 
##                                  |    553.72 |   1076.28 |           | 
##                                  |     11.48 |      5.90 |           | 
##                                  |      0.29 |      0.71 |      0.06 | 
##                                  |      0.05 |      0.07 |           | 
##                                  |      0.02 |      0.04 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           TIMLIN |       309 |      1432 |      1741 | 
##                                  |    591.43 |   1149.57 |           | 
##                                  |    134.87 |     69.39 |           | 
##                                  |      0.18 |      0.82 |      0.07 | 
##                                  |      0.04 |      0.08 |           | 
##                                  |      0.01 |      0.06 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                               XX |      2214 |      3525 |      5739 | 
##                                  |   1949.57 |   3789.43 |           | 
##                                  |     35.87 |     18.45 |           | 
##                                  |      0.39 |      0.61 |      0.22 | 
##                                  |      0.25 |      0.21 |           | 
##                                  |      0.09 |      0.14 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                     Column Total |      8797 |     17099 |     25896 | 
##                                  |      0.34 |      0.66 |           | 
## ---------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  21     p =  NaN 
## 
## 
## 
CrossTable(main_processed$Insurance.Scheme_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                        | main_processed$No.Cancels 
## main_processed$Insurance.Scheme_recode |         0 |         1 | Row Total | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      A |        19 |        34 |        53 | 
##                                        |     18.00 |     35.00 |           | 
##                                        |      0.06 |      0.03 |           | 
##                                        |      0.36 |      0.64 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      B |       154 |       539 |       693 | 
##                                        |    235.42 |    457.58 |           | 
##                                        |     28.16 |     14.49 |           | 
##                                        |      0.22 |      0.78 |      0.03 | 
##                                        |      0.02 |      0.03 |           | 
##                                        |      0.01 |      0.02 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      C |         1 |         0 |         1 | 
##                                        |      0.34 |      0.66 |           | 
##                                        |      1.28 |      0.66 |           | 
##                                        |      1.00 |      0.00 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      D |      4023 |      7210 |     11233 | 
##                                        |   3815.91 |   7417.09 |           | 
##                                        |     11.24 |      5.78 |           | 
##                                        |      0.36 |      0.64 |      0.43 | 
##                                        |      0.46 |      0.42 |           | 
##                                        |      0.16 |      0.28 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      E |         7 |        28 |        35 | 
##                                        |     11.89 |     23.11 |           | 
##                                        |      2.01 |      1.03 |           | 
##                                        |      0.20 |      0.80 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      G |        27 |        64 |        91 | 
##                                        |     30.91 |     60.09 |           | 
##                                        |      0.50 |      0.25 |           | 
##                                        |      0.30 |      0.70 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      H |        10 |        20 |        30 | 
##                                        |     10.19 |     19.81 |           | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.33 |      0.67 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      I |       137 |       424 |       561 | 
##                                        |    190.57 |    370.43 |           | 
##                                        |     15.06 |      7.75 |           | 
##                                        |      0.24 |      0.76 |      0.02 | 
##                                        |      0.02 |      0.02 |           | 
##                                        |      0.01 |      0.02 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      J |         3 |         8 |        11 | 
##                                        |      3.74 |      7.26 |           | 
##                                        |      0.15 |      0.07 |           | 
##                                        |      0.27 |      0.73 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      M |         1 |         0 |         1 | 
##                                        |      0.34 |      0.66 |           | 
##                                        |      1.28 |      0.66 |           | 
##                                        |      1.00 |      0.00 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      O |        80 |        82 |       162 | 
##                                        |     55.03 |    106.97 |           | 
##                                        |     11.33 |      5.83 |           | 
##                                        |      0.49 |      0.51 |      0.01 | 
##                                        |      0.01 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      P |         4 |        22 |        26 | 
##                                        |      8.83 |     17.17 |           | 
##                                        |      2.64 |      1.36 |           | 
##                                        |      0.15 |      0.85 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      S |        73 |       191 |       264 | 
##                                        |     89.68 |    174.32 |           | 
##                                        |      3.10 |      1.60 |           | 
##                                        |      0.28 |      0.72 |      0.01 | 
##                                        |      0.01 |      0.01 |           | 
##                                        |      0.00 |      0.01 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      U |      3722 |      7096 |     10818 | 
##                                        |   3674.93 |   7143.07 |           | 
##                                        |      0.60 |      0.31 |           | 
##                                        |      0.34 |      0.66 |      0.42 | 
##                                        |      0.42 |      0.41 |           | 
##                                        |      0.14 |      0.27 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      V |       536 |      1381 |      1917 | 
##                                        |    651.21 |   1265.79 |           | 
##                                        |     20.38 |     10.49 |           | 
##                                        |      0.28 |      0.72 |      0.07 | 
##                                        |      0.06 |      0.08 |           | 
##                                        |      0.02 |      0.05 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                           Column Total |      8797 |     17099 |     25896 | 
##                                        |      0.34 |      0.66 |           | 
## ---------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  148     d.f. =  14     p =  1.7e-24 
## 
## 
## 
CrossTable(main_processed$Eligibility_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                   | main_processed$No.Cancels 
## main_processed$Eligibility_recode |         0 |         1 | Row Total | 
## ----------------------------------|-----------|-----------|-----------|
##                            15000+ |         0 |         2 |         2 | 
##                                   |      0.68 |      1.32 |           | 
##                                   |      0.68 |      0.35 |           | 
##                                   |      0.00 |      1.00 |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                ACUTE UNCLASSIFIED |       107 |       163 |       270 | 
##                                   |     91.72 |    178.28 |           | 
##                                   |      2.55 |      1.31 |           | 
##                                   |      0.40 |      0.60 |      0.01 | 
##                                   |      0.01 |      0.01 |           | 
##                                   |      0.00 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|
##               ELIGIBILITY UNKNOWN |       490 |       863 |      1353 | 
##                                   |    459.62 |    893.38 |           | 
##                                   |      2.01 |      1.03 |           | 
##                                   |      0.36 |      0.64 |      0.05 | 
##                                   |      0.06 |      0.05 |           | 
##                                   |      0.02 |      0.03 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                            EXEMPT |       272 |       686 |       958 | 
##                                   |    325.44 |    632.56 |           | 
##                                   |      8.77 |      4.51 |           | 
##                                   |      0.28 |      0.72 |      0.04 | 
##                                   |      0.03 |      0.04 |           | 
##                                   |      0.01 |      0.03 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      MEDICAL CARD |      4225 |      8438 |     12663 | 
##                                   |   4301.68 |   8361.32 |           | 
##                                   |      1.37 |      0.70 |           | 
##                                   |      0.33 |      0.67 |      0.49 | 
##                                   |      0.48 |      0.49 |           | 
##                                   |      0.16 |      0.33 |           | 
## ----------------------------------|-----------|-----------|-----------|
##            NON ACUTE UNCLASSIFIED |         3 |         9 |        12 | 
##                                   |      4.08 |      7.92 |           | 
##                                   |      0.28 |      0.15 |           | 
##                                   |      0.25 |      0.75 |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                  NON MEDICAL CARD |      3688 |      6888 |     10576 | 
##                                   |   3592.72 |   6983.28 |           | 
##                                   |      2.53 |      1.30 |           | 
##                                   |      0.35 |      0.65 |      0.41 | 
##                                   |      0.42 |      0.40 |           | 
##                                   |      0.14 |      0.27 |           | 
## ----------------------------------|-----------|-----------|-----------|
##           RESEARCH/NATIONAL PROG. |        12 |        50 |        62 | 
##                                   |     21.06 |     40.94 |           | 
##                                   |      3.90 |      2.01 |           | 
##                                   |      0.19 |      0.81 |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      Column Total |      8797 |     17099 |     25896 | 
##                                   |      0.34 |      0.66 |           | 
## ----------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  33     d.f. =  7     p =  2.2e-05 
## 
## 
## 
CrossTable(main_processed$Booking.Type_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                    | main_processed$No.Cancels 
## main_processed$Booking.Type_recode |         0 |         1 | Row Total | 
## -----------------------------------|-----------|-----------|-----------|
##             B : New  Virtual Video |        77 |        86 |       163 | 
##                                    |     55.37 |    107.63 |           | 
##                                    |      8.45 |      4.35 |           | 
##                                    |      0.47 |      0.53 |      0.01 | 
##                                    |      0.01 |      0.01 |           | 
##                                    |      0.00 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##             C : New  Virtual Phone |        77 |       202 |       279 | 
##                                    |     94.78 |    184.22 |           | 
##                                    |      3.33 |      1.72 |           | 
##                                    |      0.28 |      0.72 |      0.01 | 
##                                    |      0.01 |      0.01 |           | 
##                                    |      0.00 |      0.01 |           | 
## -----------------------------------|-----------|-----------|-----------|
##          D : Return  Virtual Video |         0 |         0 |         0 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |       NaN |       NaN |           | 
##                                    |       NaN |       NaN |      0.00 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |      0.00 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##          E : Return  Virtual Phone |         3 |         0 |         3 | 
##                                    |      1.02 |      1.98 |           | 
##                                    |      3.85 |      1.98 |           | 
##                                    |      1.00 |      0.00 |      0.00 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |      0.00 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                                NEW |      3351 |      6589 |      9940 | 
##                                    |   3376.67 |   6563.33 |           | 
##                                    |      0.20 |      0.10 |           | 
##                                    |      0.34 |      0.66 |      0.38 | 
##                                    |      0.38 |      0.39 |           | 
##                                    |      0.13 |      0.25 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                             RETURN |      4494 |      9125 |     13619 | 
##                                    |   4626.44 |   8992.56 |           | 
##                                    |      3.79 |      1.95 |           | 
##                                    |      0.33 |      0.67 |      0.53 | 
##                                    |      0.51 |      0.53 |           | 
##                                    |      0.17 |      0.35 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                         V : REVIEW |         0 |         1 |         1 | 
##                                    |      0.34 |      0.66 |           | 
##                                    |      0.34 |      0.17 |           | 
##                                    |      0.00 |      1.00 |      0.00 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |      0.00 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                               WARD |       795 |      1096 |      1891 | 
##                                    |    642.38 |   1248.62 |           | 
##                                    |     36.26 |     18.65 |           | 
##                                    |      0.42 |      0.58 |      0.07 | 
##                                    |      0.09 |      0.06 |           | 
##                                    |      0.03 |      0.04 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                       Column Total |      8797 |     17099 |     25896 | 
##                                    |      0.34 |      0.66 |           | 
## -----------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  7     p =  NaN 
## 
## 
## 
CrossTable(main_processed$Hospital.Catchment_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                          | main_processed$No.Cancels 
## main_processed$Hospital.Catchment_recode |         0 |         1 | Row Total | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Beaumont |       318 |       644 |       962 | 
##                                          |    326.80 |    635.20 |           | 
##                                          |      0.24 |      0.12 |           | 
##                                          |      0.33 |      0.67 |      0.04 | 
##                                          |      0.04 |      0.04 |           | 
##                                          |      0.01 |      0.02 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Connolly |       413 |       961 |      1374 | 
##                                          |    466.75 |    907.25 |           | 
##                                          |      6.19 |      3.18 |           | 
##                                          |      0.30 |      0.70 |      0.05 | 
##                                          |      0.05 |      0.06 |           | 
##                                          |      0.02 |      0.04 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                            International |        67 |        94 |       161 | 
##                                          |     54.69 |    106.31 |           | 
##                                          |      2.77 |      1.42 |           | 
##                                          |      0.42 |      0.58 |      0.01 | 
##                                          |      0.01 |      0.01 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    James |       653 |       885 |      1538 | 
##                                          |    522.47 |   1015.53 |           | 
##                                          |     32.61 |     16.78 |           | 
##                                          |      0.42 |      0.58 |      0.06 | 
##                                          |      0.07 |      0.05 |           | 
##                                          |      0.03 |      0.03 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    Mater |      4634 |      6791 |     11425 | 
##                                          |   3881.13 |   7543.87 |           | 
##                                          |    146.04 |     75.14 |           | 
##                                          |      0.41 |      0.59 |      0.44 | 
##                                          |      0.53 |      0.40 |           | 
##                                          |      0.18 |      0.26 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 National |      2117 |      6726 |      8843 | 
##                                          |   3004.01 |   5838.99 |           | 
##                                          |    261.91 |    134.75 |           | 
##                                          |      0.24 |      0.76 |      0.34 | 
##                                          |      0.24 |      0.39 |           | 
##                                          |      0.08 |      0.26 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Tallaght |       220 |       332 |       552 | 
##                                          |    187.52 |    364.48 |           | 
##                                          |      5.63 |      2.89 |           | 
##                                          |      0.40 |      0.60 |      0.02 | 
##                                          |      0.03 |      0.02 |           | 
##                                          |      0.01 |      0.01 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Vincents |       375 |       666 |      1041 | 
##                                          |    353.63 |    687.37 |           | 
##                                          |      1.29 |      0.66 |           | 
##                                          |      0.36 |      0.64 |      0.04 | 
##                                          |      0.04 |      0.04 |           | 
##                                          |      0.01 |      0.03 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                             Column Total |      8797 |     17099 |     25896 | 
##                                          |      0.34 |      0.66 |           | 
## -----------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  692     d.f. =  7     p =  4.4e-145 
## 
## 
## 
## date relevance
### difference between Booked and Appointment factors in Cancellation

CrossTable(main_processed$bookedDay, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                          | main_processed$No.Cancels 
## main_processed$bookedDay |         0 |         1 | Row Total | 
## -------------------------|-----------|-----------|-----------|
##                   Friday |       825 |      1624 |      2449 | 
##                          |    831.94 |   1617.06 |           | 
##                          |      0.06 |      0.03 |           | 
##                          |      0.34 |      0.66 |      0.09 | 
##                          |      0.09 |      0.09 |           | 
##                          |      0.03 |      0.06 |           | 
## -------------------------|-----------|-----------|-----------|
##                   Monday |      1843 |      3542 |      5385 | 
##                          |   1829.31 |   3555.69 |           | 
##                          |      0.10 |      0.05 |           | 
##                          |      0.34 |      0.66 |      0.21 | 
##                          |      0.21 |      0.21 |           | 
##                          |      0.07 |      0.14 |           | 
## -------------------------|-----------|-----------|-----------|
##                 Saturday |       935 |      1785 |      2720 | 
##                          |    924.00 |   1796.00 |           | 
##                          |      0.13 |      0.07 |           | 
##                          |      0.34 |      0.66 |      0.11 | 
##                          |      0.11 |      0.10 |           | 
##                          |      0.04 |      0.07 |           | 
## -------------------------|-----------|-----------|-----------|
##                   Sunday |      1403 |      2600 |      4003 | 
##                          |   1359.84 |   2643.16 |           | 
##                          |      1.37 |      0.70 |           | 
##                          |      0.35 |      0.65 |      0.15 | 
##                          |      0.16 |      0.15 |           | 
##                          |      0.05 |      0.10 |           | 
## -------------------------|-----------|-----------|-----------|
##                 Thursday |       821 |      1830 |      2651 | 
##                          |    900.56 |   1750.44 |           | 
##                          |      7.03 |      3.62 |           | 
##                          |      0.31 |      0.69 |      0.10 | 
##                          |      0.09 |      0.11 |           | 
##                          |      0.03 |      0.07 |           | 
## -------------------------|-----------|-----------|-----------|
##                  Tuesday |      1718 |      3259 |      4977 | 
##                          |   1690.71 |   3286.29 |           | 
##                          |      0.44 |      0.23 |           | 
##                          |      0.35 |      0.65 |      0.19 | 
##                          |      0.20 |      0.19 |           | 
##                          |      0.07 |      0.13 |           | 
## -------------------------|-----------|-----------|-----------|
##                Wednesday |      1252 |      2459 |      3711 | 
##                          |   1260.65 |   2450.35 |           | 
##                          |      0.06 |      0.03 |           | 
##                          |      0.34 |      0.66 |      0.14 | 
##                          |      0.14 |      0.14 |           | 
##                          |      0.05 |      0.09 |           | 
## -------------------------|-----------|-----------|-----------|
##             Column Total |      8797 |     17099 |     25896 | 
##                          |      0.34 |      0.66 |           | 
## -------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  14     d.f. =  6     p =  0.031 
## 
## 
## 
CrossTable(main_processed$bookedMonthYear, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                | main_processed$No.Cancels 
## main_processed$bookedMonthYear |         0 |         1 | Row Total | 
## -------------------------------|-----------|-----------|-----------|
##                       Apr 2020 |       636 |      1064 |      1700 | 
##                                |    577.50 |   1122.50 |           | 
##                                |      5.93 |      3.05 |           | 
##                                |      0.37 |      0.63 |      0.07 | 
##                                |      0.07 |      0.06 |           | 
##                                |      0.02 |      0.04 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Aug 2020 |       811 |      1319 |      2130 | 
##                                |    723.57 |   1406.43 |           | 
##                                |     10.56 |      5.43 |           | 
##                                |      0.38 |      0.62 |      0.08 | 
##                                |      0.09 |      0.08 |           | 
##                                |      0.03 |      0.05 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Dec 2020 |       503 |       935 |      1438 | 
##                                |    488.50 |    949.50 |           | 
##                                |      0.43 |      0.22 |           | 
##                                |      0.35 |      0.65 |      0.06 | 
##                                |      0.06 |      0.05 |           | 
##                                |      0.02 |      0.04 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Feb 2020 |       767 |      1933 |      2700 | 
##                                |    917.20 |   1782.80 |           | 
##                                |     24.60 |     12.65 |           | 
##                                |      0.28 |      0.72 |      0.10 | 
##                                |      0.09 |      0.11 |           | 
##                                |      0.03 |      0.07 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Jan 2020 |       770 |      2291 |      3061 | 
##                                |   1039.84 |   2021.16 |           | 
##                                |     70.02 |     36.02 |           | 
##                                |      0.25 |      0.75 |      0.12 | 
##                                |      0.09 |      0.13 |           | 
##                                |      0.03 |      0.09 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Jul 2020 |       790 |      1368 |      2158 | 
##                                |    733.08 |   1424.92 |           | 
##                                |      4.42 |      2.27 |           | 
##                                |      0.37 |      0.63 |      0.08 | 
##                                |      0.09 |      0.08 |           | 
##                                |      0.03 |      0.05 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Jun 2020 |       735 |      1080 |      1815 | 
##                                |    616.56 |   1198.44 |           | 
##                                |     22.75 |     11.70 |           | 
##                                |      0.40 |      0.60 |      0.07 | 
##                                |      0.08 |      0.06 |           | 
##                                |      0.03 |      0.04 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Mar 2020 |       782 |      1788 |      2570 | 
##                                |    873.04 |   1696.96 |           | 
##                                |      9.49 |      4.88 |           | 
##                                |      0.30 |      0.70 |      0.10 | 
##                                |      0.09 |      0.10 |           | 
##                                |      0.03 |      0.07 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       May 2020 |       782 |      1197 |      1979 | 
##                                |    672.28 |   1306.72 |           | 
##                                |     17.91 |      9.21 |           | 
##                                |      0.40 |      0.60 |      0.08 | 
##                                |      0.09 |      0.07 |           | 
##                                |      0.03 |      0.05 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Nov 2020 |       704 |      1306 |      2010 | 
##                                |    682.81 |   1327.19 |           | 
##                                |      0.66 |      0.34 |           | 
##                                |      0.35 |      0.65 |      0.08 | 
##                                |      0.08 |      0.08 |           | 
##                                |      0.03 |      0.05 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Oct 2020 |       712 |      1292 |      2004 | 
##                                |    680.77 |   1323.23 |           | 
##                                |      1.43 |      0.74 |           | 
##                                |      0.36 |      0.64 |      0.08 | 
##                                |      0.08 |      0.08 |           | 
##                                |      0.03 |      0.05 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Sep 2020 |       805 |      1526 |      2331 | 
##                                |    791.85 |   1539.15 |           | 
##                                |      0.22 |      0.11 |           | 
##                                |      0.35 |      0.65 |      0.09 | 
##                                |      0.09 |      0.09 |           | 
##                                |      0.03 |      0.06 |           | 
## -------------------------------|-----------|-----------|-----------|
##                   Column Total |      8797 |     17099 |     25896 | 
##                                |      0.34 |      0.66 |           | 
## -------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  255     d.f. =  11     p =  2.4e-48 
## 
## 
## 
CrossTable(main_processed$appointmentDay, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                               | main_processed$No.Cancels 
## main_processed$appointmentDay |         0 |         1 | Row Total | 
## ------------------------------|-----------|-----------|-----------|
##                        Friday |      1706 |      2215 |      3921 | 
##                               |   1331.98 |   2589.02 |           | 
##                               |    105.02 |     54.03 |           | 
##                               |      0.44 |      0.56 |      0.15 | 
##                               |      0.19 |      0.13 |           | 
##                               |      0.07 |      0.09 |           | 
## ------------------------------|-----------|-----------|-----------|
##                        Monday |      1772 |      3853 |      5625 | 
##                               |   1910.84 |   3714.16 |           | 
##                               |     10.09 |      5.19 |           | 
##                               |      0.32 |      0.68 |      0.22 | 
##                               |      0.20 |      0.23 |           | 
##                               |      0.07 |      0.15 |           | 
## ------------------------------|-----------|-----------|-----------|
##                        Sunday |         2 |         1 |         3 | 
##                               |      1.02 |      1.98 |           | 
##                               |      0.94 |      0.49 |           | 
##                               |      0.67 |      0.33 |      0.00 | 
##                               |      0.00 |      0.00 |           | 
##                               |      0.00 |      0.00 |           | 
## ------------------------------|-----------|-----------|-----------|
##                      Thursday |      1572 |      3756 |      5328 | 
##                               |   1809.95 |   3518.05 |           | 
##                               |     31.28 |     16.09 |           | 
##                               |      0.30 |      0.70 |      0.21 | 
##                               |      0.18 |      0.22 |           | 
##                               |      0.06 |      0.15 |           | 
## ------------------------------|-----------|-----------|-----------|
##                       Tuesday |      1863 |      2908 |      4771 | 
##                               |   1620.73 |   3150.27 |           | 
##                               |     36.21 |     18.63 |           | 
##                               |      0.39 |      0.61 |      0.18 | 
##                               |      0.21 |      0.17 |           | 
##                               |      0.07 |      0.11 |           | 
## ------------------------------|-----------|-----------|-----------|
##                     Wednesday |      1882 |      4366 |      6248 | 
##                               |   2122.48 |   4125.52 |           | 
##                               |     27.25 |     14.02 |           | 
##                               |      0.30 |      0.70 |      0.24 | 
##                               |      0.21 |      0.26 |           | 
##                               |      0.07 |      0.17 |           | 
## ------------------------------|-----------|-----------|-----------|
##                  Column Total |      8797 |     17099 |     25896 | 
##                               |      0.34 |      0.66 |           | 
## ------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  319     d.f. =  5     p =  7.3e-67 
## 
## 
## 
CrossTable(main_processed$appointmentMonthYear, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                     | main_processed$No.Cancels 
## main_processed$appointmentMonthYear |         0 |         1 | Row Total | 
## ------------------------------------|-----------|-----------|-----------|
##                            Apr 2020 |       103 |       591 |       694 | 
##                                     |    235.76 |    458.24 |           | 
##                                     |     74.76 |     38.46 |           | 
##                                     |      0.15 |      0.85 |      0.03 | 
##                                     |      0.01 |      0.03 |           | 
##                                     |      0.00 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Apr 2021 |       166 |       296 |       462 | 
##                                     |    156.94 |    305.06 |           | 
##                                     |      0.52 |      0.27 |           | 
##                                     |      0.36 |      0.64 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Apr 2022 |       206 |       419 |       625 | 
##                                     |    212.32 |    412.68 |           | 
##                                     |      0.19 |      0.10 |           | 
##                                     |      0.33 |      0.67 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Apr 2023 |       161 |       334 |       495 | 
##                                     |    168.15 |    326.85 |           | 
##                                     |      0.30 |      0.16 |           | 
##                                     |      0.33 |      0.67 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Aug 2020 |       127 |       324 |       451 | 
##                                     |    153.21 |    297.79 |           | 
##                                     |      4.48 |      2.31 |           | 
##                                     |      0.28 |      0.72 |      0.02 | 
##                                     |      0.01 |      0.02 |           | 
##                                     |      0.00 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Aug 2021 |       254 |       292 |       546 | 
##                                     |    185.48 |    360.52 |           | 
##                                     |     25.31 |     13.02 |           | 
##                                     |      0.47 |      0.53 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Aug 2022 |       188 |       432 |       620 | 
##                                     |    210.62 |    409.38 |           | 
##                                     |      2.43 |      1.25 |           | 
##                                     |      0.30 |      0.70 |      0.02 | 
##                                     |      0.02 |      0.03 |           | 
##                                     |      0.01 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Aug 2023 |       174 |       319 |       493 | 
##                                     |    167.47 |    325.53 |           | 
##                                     |      0.25 |      0.13 |           | 
##                                     |      0.35 |      0.65 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Dec 2020 |       188 |       251 |       439 | 
##                                     |    149.13 |    289.87 |           | 
##                                     |     10.13 |      5.21 |           | 
##                                     |      0.43 |      0.57 |      0.02 | 
##                                     |      0.02 |      0.01 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Dec 2021 |       205 |       371 |       576 | 
##                                     |    195.67 |    380.33 |           | 
##                                     |      0.44 |      0.23 |           | 
##                                     |      0.36 |      0.64 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Dec 2022 |       156 |       299 |       455 | 
##                                     |    154.57 |    300.43 |           | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.34 |      0.66 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Dec 2023 |       143 |       298 |       441 | 
##                                     |    149.81 |    291.19 |           | 
##                                     |      0.31 |      0.16 |           | 
##                                     |      0.32 |      0.68 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Feb 2020 |       205 |       300 |       505 | 
##                                     |    171.55 |    333.45 |           | 
##                                     |      6.52 |      3.36 |           | 
##                                     |      0.41 |      0.59 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Feb 2021 |        94 |       419 |       513 | 
##                                     |    174.27 |    338.73 |           | 
##                                     |     36.97 |     19.02 |           | 
##                                     |      0.18 |      0.82 |      0.02 | 
##                                     |      0.01 |      0.02 |           | 
##                                     |      0.00 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Feb 2022 |       203 |       376 |       579 | 
##                                     |    196.69 |    382.31 |           | 
##                                     |      0.20 |      0.10 |           | 
##                                     |      0.35 |      0.65 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Feb 2023 |       151 |       278 |       429 | 
##                                     |    145.73 |    283.27 |           | 
##                                     |      0.19 |      0.10 |           | 
##                                     |      0.35 |      0.65 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jan 2020 |        79 |       108 |       187 | 
##                                     |     63.52 |    123.48 |           | 
##                                     |      3.77 |      1.94 |           | 
##                                     |      0.42 |      0.58 |      0.01 | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.00 |      0.00 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jan 2021 |       159 |       545 |       704 | 
##                                     |    239.15 |    464.85 |           | 
##                                     |     26.86 |     13.82 |           | 
##                                     |      0.23 |      0.77 |      0.03 | 
##                                     |      0.02 |      0.03 |           | 
##                                     |      0.01 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jan 2022 |       230 |       380 |       610 | 
##                                     |    207.22 |    402.78 |           | 
##                                     |      2.50 |      1.29 |           | 
##                                     |      0.38 |      0.62 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jan 2023 |       175 |       378 |       553 | 
##                                     |    187.86 |    365.14 |           | 
##                                     |      0.88 |      0.45 |           | 
##                                     |      0.32 |      0.68 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jul 2020 |        99 |       275 |       374 | 
##                                     |    127.05 |    246.95 |           | 
##                                     |      6.19 |      3.19 |           | 
##                                     |      0.26 |      0.74 |      0.01 | 
##                                     |      0.01 |      0.02 |           | 
##                                     |      0.00 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jul 2021 |       264 |       302 |       566 | 
##                                     |    192.27 |    373.73 |           | 
##                                     |     26.76 |     13.77 |           | 
##                                     |      0.47 |      0.53 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jul 2022 |       279 |       326 |       605 | 
##                                     |    205.52 |    399.48 |           | 
##                                     |     26.27 |     13.52 |           | 
##                                     |      0.46 |      0.54 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jul 2023 |       165 |       315 |       480 | 
##                                     |    163.06 |    316.94 |           | 
##                                     |      0.02 |      0.01 |           | 
##                                     |      0.34 |      0.66 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jun 2020 |       123 |       329 |       452 | 
##                                     |    153.55 |    298.45 |           | 
##                                     |      6.08 |      3.13 |           | 
##                                     |      0.27 |      0.73 |      0.02 | 
##                                     |      0.01 |      0.02 |           | 
##                                     |      0.00 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jun 2021 |       208 |       313 |       521 | 
##                                     |    176.99 |    344.01 |           | 
##                                     |      5.43 |      2.80 |           | 
##                                     |      0.40 |      0.60 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jun 2022 |       233 |       377 |       610 | 
##                                     |    207.22 |    402.78 |           | 
##                                     |      3.21 |      1.65 |           | 
##                                     |      0.38 |      0.62 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Jun 2023 |       118 |       314 |       432 | 
##                                     |    146.75 |    285.25 |           | 
##                                     |      5.63 |      2.90 |           | 
##                                     |      0.27 |      0.73 |      0.02 | 
##                                     |      0.01 |      0.02 |           | 
##                                     |      0.00 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Mar 2020 |       247 |       735 |       982 | 
##                                     |    333.59 |    648.41 |           | 
##                                     |     22.48 |     11.56 |           | 
##                                     |      0.25 |      0.75 |      0.04 | 
##                                     |      0.03 |      0.04 |           | 
##                                     |      0.01 |      0.03 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Mar 2021 |       146 |       349 |       495 | 
##                                     |    168.15 |    326.85 |           | 
##                                     |      2.92 |      1.50 |           | 
##                                     |      0.29 |      0.71 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Mar 2022 |       220 |       476 |       696 | 
##                                     |    236.43 |    459.57 |           | 
##                                     |      1.14 |      0.59 |           | 
##                                     |      0.32 |      0.68 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.01 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Mar 2023 |       155 |       305 |       460 | 
##                                     |    156.26 |    303.74 |           | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.34 |      0.66 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            May 2020 |        82 |       359 |       441 | 
##                                     |    149.81 |    291.19 |           | 
##                                     |     30.69 |     15.79 |           | 
##                                     |      0.19 |      0.81 |      0.02 | 
##                                     |      0.01 |      0.02 |           | 
##                                     |      0.00 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            May 2021 |       193 |       334 |       527 | 
##                                     |    179.02 |    347.98 |           | 
##                                     |      1.09 |      0.56 |           | 
##                                     |      0.37 |      0.63 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            May 2022 |       260 |       418 |       678 | 
##                                     |    230.32 |    447.68 |           | 
##                                     |      3.82 |      1.97 |           | 
##                                     |      0.38 |      0.62 |      0.03 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            May 2023 |       156 |       373 |       529 | 
##                                     |    179.70 |    349.30 |           | 
##                                     |      3.13 |      1.61 |           | 
##                                     |      0.29 |      0.71 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Nov 2020 |       141 |       315 |       456 | 
##                                     |    154.91 |    301.09 |           | 
##                                     |      1.25 |      0.64 |           | 
##                                     |      0.31 |      0.69 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Nov 2021 |       285 |       384 |       669 | 
##                                     |    227.26 |    441.74 |           | 
##                                     |     14.67 |      7.55 |           | 
##                                     |      0.43 |      0.57 |      0.03 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Nov 2022 |       177 |       371 |       548 | 
##                                     |    186.16 |    361.84 |           | 
##                                     |      0.45 |      0.23 |           | 
##                                     |      0.32 |      0.68 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Nov 2023 |       173 |       349 |       522 | 
##                                     |    177.33 |    344.67 |           | 
##                                     |      0.11 |      0.05 |           | 
##                                     |      0.33 |      0.67 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Oct 2020 |       191 |       296 |       487 | 
##                                     |    165.44 |    321.56 |           | 
##                                     |      3.95 |      2.03 |           | 
##                                     |      0.39 |      0.61 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Oct 2021 |       232 |       325 |       557 | 
##                                     |    189.22 |    367.78 |           | 
##                                     |      9.67 |      4.98 |           | 
##                                     |      0.42 |      0.58 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Oct 2022 |       178 |       327 |       505 | 
##                                     |    171.55 |    333.45 |           | 
##                                     |      0.24 |      0.12 |           | 
##                                     |      0.35 |      0.65 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Oct 2023 |       176 |       347 |       523 | 
##                                     |    177.67 |    345.33 |           | 
##                                     |      0.02 |      0.01 |           | 
##                                     |      0.34 |      0.66 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Sep 2020 |       213 |       427 |       640 | 
##                                     |    217.41 |    422.59 |           | 
##                                     |      0.09 |      0.05 |           | 
##                                     |      0.33 |      0.67 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Sep 2021 |       293 |       330 |       623 | 
##                                     |    211.64 |    411.36 |           | 
##                                     |     31.28 |     16.09 |           | 
##                                     |      0.47 |      0.53 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Sep 2022 |       245 |       402 |       647 | 
##                                     |    219.79 |    427.21 |           | 
##                                     |      2.89 |      1.49 |           | 
##                                     |      0.38 |      0.62 |      0.02 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.01 |      0.02 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                            Sep 2023 |       178 |       316 |       494 | 
##                                     |    167.81 |    326.19 |           | 
##                                     |      0.62 |      0.32 |           | 
##                                     |      0.36 |      0.64 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                        Column Total |      8797 |     17099 |     25896 | 
##                                     |      0.34 |      0.66 |           | 
## ------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  617     d.f. =  47     p =  2.5e-100 
## 
## 
## 
CrossTable(main_processed$Rebooked.Indicator, main_processed$No.Cancels, digits=2, fisher=T, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                   | main_processed$No.Cancels 
## main_processed$Rebooked.Indicator |         0 |         1 | Row Total | 
## ----------------------------------|-----------|-----------|-----------|
##                                   |         0 |         0 |         0 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |       NaN |       NaN |           | 
##                                   |       NaN |       NaN |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                                No |      8797 |      7806 |     16603 | 
##                                   |   5640.12 |  10962.88 |           | 
##                                   |   1766.96 |    909.06 |           | 
##                                   |      0.53 |      0.47 |      0.64 | 
##                                   |      1.00 |      0.46 |           | 
##                                   |      0.34 |      0.30 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                               Yes |         0 |      9293 |      9293 | 
##                                   |   3156.88 |   6136.12 |           | 
##                                   |   3156.88 |   1624.13 |           | 
##                                   |      0.00 |      1.00 |      0.36 | 
##                                   |      0.00 |      0.54 |           | 
##                                   |      0.00 |      0.36 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      Column Total |      8797 |     17099 |     25896 | 
##                                   |      0.34 |      0.66 |           | 
## ----------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  2     p =  NaN 
## 
## 
##  
## Fisher's Exact Test for Count Data
## ------------------------------------------------------------
## Alternative hypothesis: two.sided
## p =  0 
## 
## 
leveneTest(daysDiff_AppointBooked ~ as.factor(No.Cancels), data=main_processed) #leveneTest is Ha
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value  Pr(>F)    
## group     1    60.8 6.6e-15 ***
##       25894                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t.test(daysDiff_AppointBooked ~ No.Cancels, var.equal=F, data=main_processed)
## 
##  Welch Two Sample t-test
## 
## data:  daysDiff_AppointBooked by No.Cancels
## t = -3, df = 18563, p-value = 0.001
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -26.8  -6.7
## sample estimates:
## mean in group 0 mean in group 1 
##            -568            -551
## patient characteristics relevance
CrossTable(main_processed$Gender, main_processed$No.Cancels, digits=2, fisher=TRUE, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                       | main_processed$No.Cancels 
## main_processed$Gender |         0 |         1 | Row Total | 
## ----------------------|-----------|-----------|-----------|
##                Female |      3739 |      9417 |     13156 | 
##                       |   4469.16 |   8686.84 |           | 
##                       |    119.29 |     61.37 |           | 
##                       |      0.28 |      0.72 |      0.51 | 
##                       |      0.43 |      0.55 |           | 
##                       |      0.14 |      0.36 |           | 
## ----------------------|-----------|-----------|-----------|
##                  Male |      5057 |      7682 |     12739 | 
##                       |   4327.50 |   8411.50 |           | 
##                       |    122.97 |     63.27 |           | 
##                       |      0.40 |      0.60 |      0.49 | 
##                       |      0.57 |      0.45 |           | 
##                       |      0.20 |      0.30 |           | 
## ----------------------|-----------|-----------|-----------|
##               Unknown |         1 |         0 |         1 | 
##                       |      0.34 |      0.66 |           | 
##                       |      1.28 |      0.66 |           | 
##                       |      1.00 |      0.00 |      0.00 | 
##                       |      0.00 |      0.00 |           | 
##                       |      0.00 |      0.00 |           | 
## ----------------------|-----------|-----------|-----------|
##          Column Total |      8797 |     17099 |     25896 | 
##                       |      0.34 |      0.66 |           | 
## ----------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  369     d.f. =  2     p =  8e-81 
## 
## 
##  
## Fisher's Exact Test for Count Data
## ------------------------------------------------------------
## Alternative hypothesis: two.sided
## p =  4.1e-82 
## 
## 
CrossTable(main_processed$Age.at.Attendance.Cat.HSE, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE) # age group
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                          | main_processed$No.Cancels 
## main_processed$Age.at.Attendance.Cat.HSE |         0 |         1 | Row Total | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    0 - 4 |         2 |         5 |         7 | 
##                                          |      2.38 |      4.62 |           | 
##                                          |      0.06 |      0.03 |           | 
##                                          |      0.29 |      0.71 |      0.00 | 
##                                          |      0.00 |      0.00 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                   05-Sep |         0 |         1 |         1 | 
##                                          |      0.34 |      0.66 |           | 
##                                          |      0.34 |      0.17 |           | 
##                                          |      0.00 |      1.00 |      0.00 | 
##                                          |      0.00 |      0.00 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  15 - 24 |      1162 |      1457 |      2619 | 
##                                          |    889.69 |   1729.31 |           | 
##                                          |     83.35 |     42.88 |           | 
##                                          |      0.44 |      0.56 |      0.10 | 
##                                          |      0.13 |      0.09 |           | 
##                                          |      0.04 |      0.06 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  25 - 34 |      1559 |      1824 |      3383 | 
##                                          |   1149.22 |   2233.78 |           | 
##                                          |    146.11 |     75.17 |           | 
##                                          |      0.46 |      0.54 |      0.13 | 
##                                          |      0.18 |      0.11 |           | 
##                                          |      0.06 |      0.07 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  35 - 44 |      1554 |      2530 |      4084 | 
##                                          |   1387.36 |   2696.64 |           | 
##                                          |     20.02 |     10.30 |           | 
##                                          |      0.38 |      0.62 |      0.16 | 
##                                          |      0.18 |      0.15 |           | 
##                                          |      0.06 |      0.10 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  45 - 54 |      1509 |      3109 |      4618 | 
##                                          |   1568.76 |   3049.24 |           | 
##                                          |      2.28 |      1.17 |           | 
##                                          |      0.33 |      0.67 |      0.18 | 
##                                          |      0.17 |      0.18 |           | 
##                                          |      0.06 |      0.12 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  55 - 64 |      1227 |      3319 |      4546 | 
##                                          |   1544.30 |   3001.70 |           | 
##                                          |     65.19 |     33.54 |           | 
##                                          |      0.27 |      0.73 |      0.18 | 
##                                          |      0.14 |      0.19 |           | 
##                                          |      0.05 |      0.13 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  65 - 74 |       914 |      2825 |      3739 | 
##                                          |   1270.16 |   2468.84 |           | 
##                                          |     99.87 |     51.38 |           | 
##                                          |      0.24 |      0.76 |      0.14 | 
##                                          |      0.10 |      0.17 |           | 
##                                          |      0.04 |      0.11 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  75 - 84 |       643 |      1584 |      2227 | 
##                                          |    756.52 |   1470.48 |           | 
##                                          |     17.04 |      8.76 |           | 
##                                          |      0.29 |      0.71 |      0.09 | 
##                                          |      0.07 |      0.09 |           | 
##                                          |      0.02 |      0.06 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    85 >= |       227 |       444 |       671 | 
##                                          |    227.94 |    443.06 |           | 
##                                          |      0.00 |      0.00 |           | 
##                                          |      0.34 |      0.66 |      0.03 | 
##                                          |      0.03 |      0.03 |           | 
##                                          |      0.01 |      0.02 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                   Oct-14 |         0 |         1 |         1 | 
##                                          |      0.34 |      0.66 |           | 
##                                          |      0.34 |      0.17 |           | 
##                                          |      0.00 |      1.00 |      0.00 | 
##                                          |      0.00 |      0.00 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                             Column Total |      8797 |     17099 |     25896 | 
##                                          |      0.34 |      0.66 |           | 
## -----------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  658     d.f. =  10     p =  5.9e-135 
## 
## 
## 
leveneTest(Age.at.Attendance ~ as.factor(No.Cancels), data=main_processed)
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value  Pr(>F)    
## group     1      22 2.7e-06 ***
##       25894                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t.test(Age.at.Attendance ~ No.Cancels, var.equal=FALSE, data=main_processed) #leveneTest is Ha
## 
##  Welch Two Sample t-test
## 
## data:  Age.at.Attendance by No.Cancels
## t = -22, df = 17195, p-value <2e-16
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -6 -5
## sample estimates:
## mean in group 0 mean in group 1 
##              47              52
CrossTable(main_processed$Area.of.Residence_recode, main_processed$No.Cancels, digits=2, fisher=F, chisq=TRUE, expected=TRUE) # remove Na or impute where no residence
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                                         | main_processed$No.Cancels 
## main_processed$Area.of.Residence_recode |         0 |         1 | Row Total | 
## ----------------------------------------|-----------|-----------|-----------|
##                              DUBLIN NTH |      5897 |      9639 |     15536 | 
##                                         |   5277.66 |  10258.34 |           | 
##                                         |     72.68 |     37.39 |           | 
##                                         |      0.38 |      0.62 |      0.60 | 
##                                         |      0.67 |      0.56 |           | 
##                                         |      0.23 |      0.37 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                              DUBLIN STH |      1254 |      1894 |      3148 | 
##                                         |   1069.39 |   2078.61 |           | 
##                                         |     31.87 |     16.40 |           | 
##                                         |      0.40 |      0.60 |      0.12 | 
##                                         |      0.14 |      0.11 |           | 
##                                         |      0.05 |      0.07 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##  EASTERN & MIDLAND REGION (excl.Dublin) |       981 |      3086 |      4067 | 
##                                         |   1381.58 |   2685.42 |           | 
##                                         |    116.15 |     59.75 |           | 
##                                         |      0.24 |      0.76 |      0.16 | 
##                                         |      0.11 |      0.18 |           | 
##                                         |      0.04 |      0.12 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                 NORTHERN WESTERN REGION |       229 |      1000 |      1229 | 
##                                         |    417.50 |    811.50 |           | 
##                                         |     85.11 |     43.78 |           | 
##                                         |      0.19 |      0.81 |      0.05 | 
##                                         |      0.03 |      0.06 |           | 
##                                         |      0.01 |      0.04 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                         OUTSIDE IRELAND |        20 |        24 |        44 | 
##                                         |     14.95 |     29.05 |           | 
##                                         |      1.71 |      0.88 |           | 
##                                         |      0.45 |      0.55 |      0.00 | 
##                                         |      0.00 |      0.00 |           | 
##                                         |      0.00 |      0.00 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                         SOUTHERN REGION |       365 |      1373 |      1738 | 
##                                         |    590.41 |   1147.59 |           | 
##                                         |     86.06 |     44.27 |           | 
##                                         |      0.21 |      0.79 |      0.07 | 
##                                         |      0.04 |      0.08 |           | 
##                                         |      0.01 |      0.05 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                                 UNKNOWN |        51 |        83 |       134 | 
##                                         |     45.52 |     88.48 |           | 
##                                         |      0.66 |      0.34 |           | 
##                                         |      0.38 |      0.62 |      0.01 | 
##                                         |      0.01 |      0.00 |           | 
##                                         |      0.00 |      0.00 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                            Column Total |      8797 |     17099 |     25896 | 
##                                         |      0.34 |      0.66 |           | 
## ----------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  597     d.f. =  6     p =  1e-125 
## 
## 
## 
CrossTable(main_processed$addressDiff, main_processed$No.Cancels, digits=2, fisher=TRUE, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  25896 
## 
##  
##                            | main_processed$No.Cancels 
## main_processed$addressDiff |         0 |         1 | Row Total | 
## ---------------------------|-----------|-----------|-----------|
##                          0 |      6754 |     14025 |     20779 | 
##                            |   7058.73 |  13720.27 |           | 
##                            |     13.16 |      6.77 |           | 
##                            |      0.33 |      0.67 |      0.80 | 
##                            |      0.77 |      0.82 |           | 
##                            |      0.26 |      0.54 |           | 
## ---------------------------|-----------|-----------|-----------|
##                          1 |      2043 |      3074 |      5117 | 
##                            |   1738.27 |   3378.73 |           | 
##                            |     53.42 |     27.48 |           | 
##                            |      0.40 |      0.60 |      0.20 | 
##                            |      0.23 |      0.18 |           | 
##                            |      0.08 |      0.12 |           | 
## ---------------------------|-----------|-----------|-----------|
##               Column Total |      8797 |     17099 |     25896 | 
##                            |      0.34 |      0.66 |           | 
## ---------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  101     d.f. =  1     p =  1e-23 
## 
## Pearson's Chi-squared test with Yates' continuity correction 
## ------------------------------------------------------------
## Chi^2 =  100     d.f. =  1     p =  1.2e-23 
## 
##  
## Fisher's Exact Test for Count Data
## ------------------------------------------------------------
## Sample estimate odds ratio:  0.72 
## 
## Alternative hypothesis: true odds ratio is not equal to 1
## p =  2.6e-23 
## 95% confidence interval:  0.68 0.77 
## 
## Alternative hypothesis: true odds ratio is less than 1
## p =  1.5e-23 
## 95% confidence interval:  0 0.76 
## 
## Alternative hypothesis: true odds ratio is greater than 1
## p =  1 
## 95% confidence interval:  0.69 Inf 
## 
## 
## 
CrossTable(main_processed$Reason.for.Cancellation_recode, main_processed$Cancellation.Group, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                               | main_processed$Cancellation.Group 
## main_processed$Reason.for.Cancellation_recode |        DNA |   Hospital |        N/A |    Patient | Validation |  Row Total | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                                               |          0 |          0 |      56647 |          0 |          0 |      56647 | 
##                                               |    6037.14 |    7040.47 |   38875.28 |    3922.73 |     771.37 |            | 
##                                               |    6037.14 |    7040.47 |    8124.28 |    3922.73 |     771.37 |            | 
##                                               |       0.00 |       0.00 |       1.00 |       0.00 |       0.00 |       0.69 | 
##                                               |       0.00 |       0.00 |       1.00 |       0.00 |       0.00 |            | 
##                                               |       0.00 |       0.00 |       0.69 |       0.00 |       0.00 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                                      By Covid |          0 |       2019 |          0 |        672 |          0 |       2691 | 
##                                               |     286.79 |     334.46 |    1846.76 |     186.35 |      36.64 |            | 
##                                               |     286.79 |    8484.50 |    1846.76 |    1265.68 |      36.64 |            | 
##                                               |       0.00 |       0.75 |       0.00 |       0.25 |       0.00 |       0.03 | 
##                                               |       0.00 |       0.20 |       0.00 |       0.12 |       0.00 |            | 
##                                               |       0.00 |       0.02 |       0.00 |       0.01 |       0.00 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                               By Cslt/AN/Tech |          0 |       4393 |          0 |          0 |          0 |       4393 | 
##                                               |     468.18 |     545.99 |    3014.80 |     304.21 |      59.82 |            | 
##                                               |     468.18 |   27105.68 |    3014.80 |     304.21 |      59.82 |            | 
##                                               |       0.00 |       1.00 |       0.00 |       0.00 |       0.00 |       0.05 | 
##                                               |       0.00 |       0.43 |       0.00 |       0.00 |       0.00 |            | 
##                                               |       0.00 |       0.05 |       0.00 |       0.00 |       0.00 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                                   By Hospital |          0 |       3696 |          0 |          0 |          0 |       3696 | 
##                                               |     393.90 |     459.36 |    2536.46 |     255.94 |      50.33 |            | 
##                                               |     393.90 |   22805.05 |    2536.46 |     255.94 |      50.33 |            | 
##                                               |       0.00 |       1.00 |       0.00 |       0.00 |       0.00 |       0.04 | 
##                                               |       0.00 |       0.36 |       0.00 |       0.00 |       0.00 |            | 
##                                               |       0.00 |       0.04 |       0.00 |       0.00 |       0.00 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                                    By Patient |          0 |        138 |          0 |       3764 |       1083 |       4985 | 
##                                               |     531.28 |     619.57 |    3421.07 |     345.21 |      67.88 |            | 
##                                               |     531.28 |     374.31 |    3421.07 |   33858.60 |   15180.37 |            | 
##                                               |       0.00 |       0.03 |       0.00 |       0.76 |       0.22 |       0.06 | 
##                                               |       0.00 |       0.01 |       0.00 |       0.66 |       0.96 |            | 
##                                               |       0.00 |       0.00 |       0.00 |       0.05 |       0.01 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                  By Patient-health conditions |          0 |         13 |          0 |       1280 |         41 |       1334 | 
##                                               |     142.17 |     165.80 |     915.49 |      92.38 |      18.17 |            | 
##                                               |     142.17 |     140.82 |     915.49 |   15268.23 |      28.70 |            | 
##                                               |       0.00 |       0.01 |       0.00 |       0.96 |       0.03 |       0.02 | 
##                                               |       0.00 |       0.00 |       0.00 |       0.22 |       0.04 |            | 
##                                               |       0.00 |       0.00 |       0.00 |       0.02 |       0.00 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                                       No show |       8797 |          0 |          0 |          0 |          0 |       8797 | 
##                                               |     937.54 |    1093.35 |    6037.14 |     609.18 |     119.79 |            | 
##                                               |   65886.54 |    1093.35 |    6037.14 |     609.18 |     119.79 |            | 
##                                               |       1.00 |       0.00 |       0.00 |       0.00 |       0.00 |       0.11 | 
##                                               |       1.00 |       0.00 |       0.00 |       0.00 |       0.00 |            | 
##                                               |       0.11 |       0.00 |       0.00 |       0.00 |       0.00 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
##                                  Column Total |       8797 |      10259 |      56647 |       5716 |       1124 |      82543 | 
##                                               |       0.11 |       0.12 |       0.69 |       0.07 |       0.01 |            | 
## ----------------------------------------------|------------|------------|------------|------------|------------|------------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  238418     d.f. =  24     p =  0 
## 
## 
## 
CrossTable(main_processed$Cancellation.Group, main_processed$Rebooked.Indicator, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                   | main_processed$Rebooked.Indicator 
## main_processed$Cancellation.Group |           |        No |       Yes | Row Total | 
## ----------------------------------|-----------|-----------|-----------|-----------|
##                               DNA |         0 |      8797 |         0 |      8797 | 
##                                   |   6037.14 |   1769.46 |    990.40 |           | 
##                                   |   6037.14 |  27910.37 |    990.40 |           | 
##                                   |      0.00 |      1.00 |      0.00 |      0.11 | 
##                                   |      0.00 |      0.53 |      0.00 |           | 
##                                   |      0.00 |      0.11 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|-----------|
##                          Hospital |         0 |      4291 |      5968 |     10259 | 
##                                   |   7040.47 |   2063.53 |   1155.00 |           | 
##                                   |   7040.47 |   2404.43 |  20056.34 |           | 
##                                   |      0.00 |      0.42 |      0.58 |      0.12 | 
##                                   |      0.00 |      0.26 |      0.64 |           | 
##                                   |      0.00 |      0.05 |      0.07 |           | 
## ----------------------------------|-----------|-----------|-----------|-----------|
##                               N/A |     56647 |         0 |         0 |     56647 | 
##                                   |  38875.28 |  11394.18 |   6377.53 |           | 
##                                   |   8124.28 |  11394.18 |   6377.53 |           | 
##                                   |      1.00 |      0.00 |      0.00 |      0.69 | 
##                                   |      1.00 |      0.00 |      0.00 |           | 
##                                   |      0.69 |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|-----------|
##                           Patient |         0 |      3051 |      2665 |      5716 | 
##                                   |   3922.73 |   1149.74 |    643.53 |           | 
##                                   |   3922.73 |   3144.02 |   6349.91 |           | 
##                                   |      0.00 |      0.53 |      0.47 |      0.07 | 
##                                   |      0.00 |      0.18 |      0.29 |           | 
##                                   |      0.00 |      0.04 |      0.03 |           | 
## ----------------------------------|-----------|-----------|-----------|-----------|
##                        Validation |         0 |       464 |       660 |      1124 | 
##                                   |    771.37 |    226.09 |    126.54 |           | 
##                                   |    771.37 |    250.36 |   2248.82 |           | 
##                                   |      0.00 |      0.41 |      0.59 |      0.01 | 
##                                   |      0.00 |      0.03 |      0.07 |           | 
##                                   |      0.00 |      0.01 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|-----------|
##                      Column Total |     56647 |     16603 |      9293 |     82543 | 
##                                   |      0.69 |      0.20 |      0.11 |           | 
## ----------------------------------|-----------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  107022     d.f. =  8     p =  0 
## 
## 
## 
CrossTable(main_processed$Reason.for.Cancellation_recode, main_processed$Rebooked.Indicator, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  82543 
## 
##  
##                                               | main_processed$Rebooked.Indicator 
## main_processed$Reason.for.Cancellation_recode |           |        No |       Yes | Row Total | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                                               |     56647 |         0 |         0 |     56647 | 
##                                               |  38875.28 |  11394.18 |   6377.53 |           | 
##                                               |   8124.28 |  11394.18 |   6377.53 |           | 
##                                               |      1.00 |      0.00 |      0.00 |      0.69 | 
##                                               |      1.00 |      0.00 |      0.00 |           | 
##                                               |      0.69 |      0.00 |      0.00 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                                      By Covid |         0 |      1268 |      1423 |      2691 | 
##                                               |   1846.76 |    541.28 |    302.96 |           | 
##                                               |   1846.76 |    975.70 |   4140.72 |           | 
##                                               |      0.00 |      0.47 |      0.53 |      0.03 | 
##                                               |      0.00 |      0.08 |      0.15 |           | 
##                                               |      0.00 |      0.02 |      0.02 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                               By Cslt/AN/Tech |         0 |      1480 |      2913 |      4393 | 
##                                               |   3014.80 |    883.62 |    494.58 |           | 
##                                               |   3014.80 |    402.51 |  11825.69 |           | 
##                                               |      0.00 |      0.34 |      0.66 |      0.05 | 
##                                               |      0.00 |      0.09 |      0.31 |           | 
##                                               |      0.00 |      0.02 |      0.04 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                                   By Hospital |         0 |      1664 |      2032 |      3696 | 
##                                               |   2536.46 |    743.43 |    416.11 |           | 
##                                               |   2536.46 |   1139.93 |   6275.04 |           | 
##                                               |      0.00 |      0.45 |      0.55 |      0.04 | 
##                                               |      0.00 |      0.10 |      0.22 |           | 
##                                               |      0.00 |      0.02 |      0.02 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                                    By Patient |         0 |      2679 |      2306 |      4985 | 
##                                               |   3421.07 |   1002.70 |    561.23 |           | 
##                                               |   3421.07 |   2802.41 |   5424.20 |           | 
##                                               |      0.00 |      0.54 |      0.46 |      0.06 | 
##                                               |      0.00 |      0.16 |      0.25 |           | 
##                                               |      0.00 |      0.03 |      0.03 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                  By Patient-health conditions |         0 |       715 |       619 |      1334 | 
##                                               |    915.49 |    268.33 |    150.19 |           | 
##                                               |    915.49 |    743.57 |   1463.42 |           | 
##                                               |      0.00 |      0.54 |      0.46 |      0.02 | 
##                                               |      0.00 |      0.04 |      0.07 |           | 
##                                               |      0.00 |      0.01 |      0.01 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                                       No show |         0 |      8797 |         0 |      8797 | 
##                                               |   6037.14 |   1769.46 |    990.40 |           | 
##                                               |   6037.14 |  27910.37 |    990.40 |           | 
##                                               |      0.00 |      1.00 |      0.00 |      0.11 | 
##                                               |      0.00 |      0.53 |      0.00 |           | 
##                                               |      0.00 |      0.11 |      0.00 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
##                                  Column Total |     56647 |     16603 |      9293 |     82543 | 
##                                               |      0.69 |      0.20 |      0.11 |           | 
## ----------------------------------------------|-----------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  107762     d.f. =  12     p =  0 
## 
## 
## 

New Attendance correlation

## clinic relevance
CrossTable(main_processed$Clinic.Type_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                   | main_processed$New.Attendances 
## main_processed$Clinic.Type_recode |         0 |         1 | Row Total | 
## ----------------------------------|-----------|-----------|-----------|
##                  BACK_PAINrelated |         3 |       185 |       188 | 
##                                   |    115.01 |     72.99 |           | 
##                                   |    109.09 |    171.91 |           | 
##                                   |      0.02 |      0.98 |      0.00 | 
##                                   |      0.00 |      0.01 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                           GENERAL |     29091 |     15867 |     44958 | 
##                                   |  27504.01 |  17453.99 |           | 
##                                   |     91.57 |    144.30 |           | 
##                                   |      0.65 |      0.35 |      0.79 | 
##                                   |      0.84 |      0.72 |           | 
##                                   |      0.51 |      0.28 |           | 
## ----------------------------------|-----------|-----------|-----------|
##            MUSCULOSKELETALrelated |       347 |      3499 |      3846 | 
##                                   |   2352.87 |   1493.13 |           | 
##                                   |   1710.05 |   2694.69 |           | 
##                                   |      0.09 |      0.91 |      0.07 | 
##                                   |      0.01 |      0.16 |           | 
##                                   |      0.01 |      0.06 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                 NotLocatedInMater |        14 |       511 |       525 | 
##                                   |    321.18 |    203.82 |           | 
##                                   |    293.79 |    462.95 |           | 
##                                   |      0.03 |      0.97 |      0.01 | 
##                                   |      0.00 |      0.02 |           | 
##                                   |      0.00 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                          NTPFfund |         1 |        96 |        97 | 
##                                   |     59.34 |     37.66 |           | 
##                                   |     57.36 |     90.39 |           | 
##                                   |      0.01 |      0.99 |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                          PODIATRY |      1288 |        24 |      1312 | 
##                                   |    802.64 |    509.36 |           | 
##                                   |    293.49 |    462.49 |           | 
##                                   |      0.98 |      0.02 |      0.02 | 
##                                   |      0.04 |      0.00 |           | 
##                                   |      0.02 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      SPINErelated |      3585 |      1476 |      5061 | 
##                                   |   3096.17 |   1964.83 |           | 
##                                   |     77.18 |    121.61 |           | 
##                                   |      0.71 |      0.29 |      0.09 | 
##                                   |      0.10 |      0.07 |           | 
##                                   |      0.06 |      0.03 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                 UPPER_LIMBrelated |       326 |       334 |       660 | 
##                                   |    403.77 |    256.23 |           | 
##                                   |     14.98 |     23.60 |           | 
##                                   |      0.49 |      0.51 |      0.01 | 
##                                   |      0.01 |      0.02 |           | 
##                                   |      0.01 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      Column Total |     34655 |     21992 |     56647 | 
##                                   |      0.61 |      0.39 |           | 
## ----------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  6819     d.f. =  7     p =  0 
## 
## 
## 
CrossTable(main_processed$Clinic.Code, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                            | main_processed$New.Attendances 
## main_processed$Clinic.Code |         0 |         1 | Row Total | 
## ---------------------------|-----------|-----------|-----------|
##                        184 |       124 |        43 |       167 | 
##                            |    102.17 |     64.83 |           | 
##                            |      4.67 |      7.35 |           | 
##                            |      0.74 |      0.26 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        211 |       213 |       157 |       370 | 
##                            |    226.36 |    143.64 |           | 
##                            |      0.79 |      1.24 |           | 
##                            |      0.58 |      0.42 |      0.01 | 
##                            |      0.01 |      0.01 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        416 |       503 |       190 |       693 | 
##                            |    423.96 |    269.04 |           | 
##                            |     14.74 |     23.22 |           | 
##                            |      0.73 |      0.27 |      0.01 | 
##                            |      0.01 |      0.01 |           | 
##                            |      0.01 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        444 |      1738 |       327 |      2065 | 
##                            |   1263.31 |    801.69 |           | 
##                            |    178.37 |    281.07 |           | 
##                            |      0.84 |      0.16 |      0.04 | 
##                            |      0.05 |      0.01 |           | 
##                            |      0.03 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        524 |        19 |        83 |       102 | 
##                            |     62.40 |     39.60 |           | 
##                            |     30.19 |     47.57 |           | 
##                            |      0.19 |      0.81 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        726 |      4159 |       907 |      5066 | 
##                            |   3099.23 |   1966.77 |           | 
##                            |    362.38 |    571.04 |           | 
##                            |      0.82 |      0.18 |      0.09 | 
##                            |      0.12 |      0.04 |           | 
##                            |      0.07 |      0.02 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        741 |         1 |         1 |         2 | 
##                            |      1.22 |      0.78 |           | 
##                            |      0.04 |      0.06 |           | 
##                            |      0.50 |      0.50 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        778 |        95 |        24 |       119 | 
##                            |     72.80 |     46.20 |           | 
##                            |      6.77 |     10.67 |           | 
##                            |      0.80 |      0.20 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        784 |        11 |        18 |        29 | 
##                            |     17.74 |     11.26 |           | 
##                            |      2.56 |      4.04 |           | 
##                            |      0.38 |      0.62 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        786 |      1889 |       912 |      2801 | 
##                            |   1713.57 |   1087.43 |           | 
##                            |     17.96 |     28.30 |           | 
##                            |      0.67 |      0.33 |      0.05 | 
##                            |      0.05 |      0.04 |           | 
##                            |      0.03 |      0.02 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        791 |         0 |         1 |         1 | 
##                            |      0.61 |      0.39 |           | 
##                            |      0.61 |      0.96 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        792 |         0 |         3 |         3 | 
##                            |      1.84 |      1.16 |           | 
##                            |      1.84 |      2.89 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        793 |         1 |         0 |         1 | 
##                            |      0.61 |      0.39 |           | 
##                            |      0.25 |      0.39 |           | 
##                            |      1.00 |      0.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        806 |      1226 |       475 |      1701 | 
##                            |   1040.62 |    660.38 |           | 
##                            |     33.02 |     52.04 |           | 
##                            |      0.72 |      0.28 |      0.03 | 
##                            |      0.04 |      0.02 |           | 
##                            |      0.02 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        846 |       136 |       120 |       256 | 
##                            |    156.61 |     99.39 |           | 
##                            |      2.71 |      4.28 |           | 
##                            |      0.53 |      0.47 |      0.00 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        847 |        42 |        55 |        97 | 
##                            |     59.34 |     37.66 |           | 
##                            |      5.07 |      7.99 |           | 
##                            |      0.43 |      0.57 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        849 |      1392 |       309 |      1701 | 
##                            |   1040.62 |    660.38 |           | 
##                            |    118.65 |    186.96 |           | 
##                            |      0.82 |      0.18 |      0.03 | 
##                            |      0.04 |      0.01 |           | 
##                            |      0.02 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        854 |         0 |         6 |         6 | 
##                            |      3.67 |      2.33 |           | 
##                            |      3.67 |      5.78 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                        921 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1031 |         1 |         1 |         2 | 
##                            |      1.22 |      0.78 |           | 
##                            |      0.04 |      0.06 |           | 
##                            |      0.50 |      0.50 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1038 |       375 |      9885 |     10260 | 
##                            |   6276.77 |   3983.23 |           | 
##                            |   5549.18 |   8744.39 |           | 
##                            |      0.04 |      0.96 |      0.18 | 
##                            |      0.01 |      0.45 |           | 
##                            |      0.01 |      0.17 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1059 |       246 |      3486 |      3732 | 
##                            |   2283.13 |   1448.87 |           | 
##                            |   1817.64 |   2864.23 |           | 
##                            |      0.07 |      0.93 |      0.07 | 
##                            |      0.01 |      0.16 |           | 
##                            |      0.00 |      0.06 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1065 |       874 |       481 |      1355 | 
##                            |    828.95 |    526.05 |           | 
##                            |      2.45 |      3.86 |           | 
##                            |      0.65 |      0.35 |      0.02 | 
##                            |      0.03 |      0.02 |           | 
##                            |      0.02 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1095 |      1288 |        24 |      1312 | 
##                            |    802.64 |    509.36 |           | 
##                            |    293.49 |    462.49 |           | 
##                            |      0.98 |      0.02 |      0.02 | 
##                            |      0.04 |      0.00 |           | 
##                            |      0.02 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1114 |       341 |        97 |       438 | 
##                            |    267.96 |    170.04 |           | 
##                            |     19.91 |     31.38 |           | 
##                            |      0.78 |      0.22 |      0.01 | 
##                            |      0.01 |      0.00 |           | 
##                            |      0.01 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1195 |      1051 |       378 |      1429 | 
##                            |    874.22 |    554.78 |           | 
##                            |     35.75 |     56.33 |           | 
##                            |      0.74 |      0.26 |      0.03 | 
##                            |      0.03 |      0.02 |           | 
##                            |      0.02 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1197 |         1 |        96 |        97 | 
##                            |     59.34 |     37.66 |           | 
##                            |     57.36 |     90.39 |           | 
##                            |      0.01 |      0.99 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1198 |         1 |        20 |        21 | 
##                            |     12.85 |      8.15 |           | 
##                            |     10.93 |     17.22 |           | 
##                            |      0.05 |      0.95 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1206 |      2445 |       551 |      2996 | 
##                            |   1832.87 |   1163.13 |           | 
##                            |    204.44 |    322.15 |           | 
##                            |      0.82 |      0.18 |      0.05 | 
##                            |      0.07 |      0.03 |           | 
##                            |      0.04 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1207 |        94 |        94 |       188 | 
##                            |    115.01 |     72.99 |           | 
##                            |      3.84 |      6.05 |           | 
##                            |      0.50 |      0.50 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1229 |      4733 |       651 |      5384 | 
##                            |   3293.78 |   2090.22 |           | 
##                            |    628.87 |    990.98 |           | 
##                            |      0.88 |      0.12 |      0.10 | 
##                            |      0.14 |      0.03 |           | 
##                            |      0.08 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1236 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1282 |      3669 |       450 |      4119 | 
##                            |   2519.89 |   1599.11 |           | 
##                            |    524.02 |    825.75 |           | 
##                            |      0.89 |      0.11 |      0.07 | 
##                            |      0.11 |      0.02 |           | 
##                            |      0.06 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1283 |       815 |       537 |      1352 | 
##                            |    827.11 |    524.89 |           | 
##                            |      0.18 |      0.28 |           | 
##                            |      0.60 |      0.40 |      0.02 | 
##                            |      0.02 |      0.02 |           | 
##                            |      0.01 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1284 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1341 |      2855 |       305 |      3160 | 
##                            |   1933.20 |   1226.80 |           | 
##                            |    439.54 |    692.63 |           | 
##                            |      0.90 |      0.10 |      0.06 | 
##                            |      0.08 |      0.01 |           | 
##                            |      0.05 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1362 |         0 |         0 |         0 | 
##                            |      0.00 |      0.00 |           | 
##                            |       NaN |       NaN |           | 
##                            |       NaN |       NaN |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1363 |        99 |         2 |       101 | 
##                            |     61.79 |     39.21 |           | 
##                            |     22.41 |     35.31 |           | 
##                            |      0.98 |      0.02 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1368 |         2 |        94 |        96 | 
##                            |     58.73 |     37.27 |           | 
##                            |     54.80 |     86.35 |           | 
##                            |      0.02 |      0.98 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1369 |      1746 |       334 |      2080 | 
##                            |   1272.48 |    807.52 |           | 
##                            |    176.20 |    277.66 |           | 
##                            |      0.84 |      0.16 |      0.04 | 
##                            |      0.05 |      0.02 |           | 
##                            |      0.03 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1371 |      2301 |       221 |      2522 | 
##                            |   1542.89 |    979.11 |           | 
##                            |    372.51 |    587.00 |           | 
##                            |      0.91 |      0.09 |      0.04 | 
##                            |      0.07 |      0.01 |           | 
##                            |      0.04 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1383 |         9 |       287 |       296 | 
##                            |    181.08 |    114.92 |           | 
##                            |    163.53 |    257.69 |           | 
##                            |      0.03 |      0.97 |      0.01 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.01 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1405 |         5 |       205 |       210 | 
##                            |    128.47 |     81.53 |           | 
##                            |    118.67 |    186.99 |           | 
##                            |      0.02 |      0.98 |      0.00 | 
##                            |      0.00 |      0.01 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1448 |        93 |        45 |       138 | 
##                            |     84.42 |     53.58 |           | 
##                            |      0.87 |      1.37 |           | 
##                            |      0.67 |      0.33 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1467 |         0 |        19 |        19 | 
##                            |     11.62 |      7.38 |           | 
##                            |     11.62 |     18.32 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1471 |         1 |        24 |        25 | 
##                            |     15.29 |      9.71 |           | 
##                            |     13.36 |     21.05 |           | 
##                            |      0.04 |      0.96 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1498 |        61 |         3 |        64 | 
##                            |     39.15 |     24.85 |           | 
##                            |     12.19 |     19.21 |           | 
##                            |      0.95 |      0.05 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##                       1505 |         0 |        71 |        71 | 
##                            |     43.44 |     27.56 |           | 
##                            |     43.44 |     68.45 |           | 
##                            |      0.00 |      1.00 |      0.00 | 
##                            |      0.00 |      0.00 |           | 
##                            |      0.00 |      0.00 |           | 
## ---------------------------|-----------|-----------|-----------|
##               Column Total |     34655 |     21992 |     56647 | 
##                            |      0.61 |      0.39 |           | 
## ---------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  47     p =  NaN 
## 
## 
## 
CrossTable(main_processed$NurseFlag, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                          | main_processed$New.Attendances 
## main_processed$NurseFlag |         0 |         1 | Row Total | 
## -------------------------|-----------|-----------|-----------|
##                        N |     33120 |     18474 |     51594 | 
##                          |  31563.72 |  20030.28 |           | 
##                          |     76.73 |    120.92 |           | 
##                          |      0.64 |      0.36 |      0.91 | 
##                          |      0.96 |      0.84 |           | 
##                          |      0.58 |      0.33 |           | 
## -------------------------|-----------|-----------|-----------|
##                        Y |      1535 |      3518 |      5053 | 
##                          |   3091.28 |   1961.72 |           | 
##                          |    783.50 |   1234.63 |           | 
##                          |      0.30 |      0.70 |      0.09 | 
##                          |      0.04 |      0.16 |           | 
##                          |      0.03 |      0.06 |           | 
## -------------------------|-----------|-----------|-----------|
##             Column Total |     34655 |     21992 |     56647 | 
##                          |      0.61 |      0.39 |           | 
## -------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  2216     d.f. =  1     p =  0 
## 
## Pearson's Chi-squared test with Yates' continuity correction 
## ------------------------------------------------------------
## Chi^2 =  2214     d.f. =  1     p =  0 
## 
## 
CrossTable(main_processed$Referral.Source_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                       | main_processed$New.Attendances 
## main_processed$Referral.Source_recode |         0 |         1 | Row Total | 
## --------------------------------------|-----------|-----------|-----------|
##                                CLINIC |     23200 |      1069 |     24269 | 
##                                       |  14847.07 |   9421.93 |           | 
##                                       |   4699.34 |   7405.21 |           | 
##                                       |      0.96 |      0.04 |      0.43 | 
##                                       |      0.67 |      0.05 |           | 
##                                       |      0.41 |      0.02 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                        Elsew of Mater |       271 |      1387 |      1658 | 
##                                       |   1014.32 |    643.68 |           | 
##                                       |    544.72 |    858.37 |           | 
##                                       |      0.16 |      0.84 |      0.03 | 
##                                       |      0.01 |      0.06 |           | 
##                                       |      0.00 |      0.02 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                   Elsew outside Mater |      3244 |      1768 |      5012 | 
##                                       |   3066.20 |   1945.80 |           | 
##                                       |     10.31 |     16.25 |           | 
##                                       |      0.65 |      0.35 |      0.09 | 
##                                       |      0.09 |      0.08 |           | 
##                                       |      0.06 |      0.03 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                        EMERGENCY DEPT |      2230 |     10534 |     12764 | 
##                                       |   7808.65 |   4955.35 |           | 
##                                       |   3985.49 |   6280.34 |           | 
##                                       |      0.17 |      0.83 |      0.23 | 
##                                       |      0.06 |      0.48 |           | 
##                                       |      0.04 |      0.19 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                                    GP |       982 |      6405 |      7387 | 
##                                       |   4519.15 |   2867.85 |           | 
##                                       |   2768.54 |   4362.67 |           | 
##                                       |      0.13 |      0.87 |      0.13 | 
##                                       |      0.03 |      0.29 |           | 
##                                       |      0.02 |      0.11 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                      OTHER CONSULTANT |       374 |       617 |       991 | 
##                                       |    606.27 |    384.73 |           | 
##                                       |     88.98 |    140.22 |           | 
##                                       |      0.38 |      0.62 |      0.02 | 
##                                       |      0.01 |      0.03 |           | 
##                                       |      0.01 |      0.01 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                                  WARD |      4354 |       212 |      4566 | 
##                                       |   2793.35 |   1772.65 |           | 
##                                       |    871.94 |   1374.01 |           | 
##                                       |      0.95 |      0.05 |      0.08 | 
##                                       |      0.13 |      0.01 |           | 
##                                       |      0.08 |      0.00 |           | 
## --------------------------------------|-----------|-----------|-----------|
##                          Column Total |     34655 |     21992 |     56647 | 
##                                       |      0.61 |      0.39 |           | 
## --------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  33406     d.f. =  6     p =  0 
## 
## 
## 
#CrossTable(main_processed$Referring.Hospital, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
CrossTable(main_processed$Consultant_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                  | main_processed$New.Attendances 
## main_processed$Consultant_recode |         0 |         1 | Row Total | 
## ---------------------------------|-----------|-----------|-----------|
##                           BRIAIN |      2549 |      1119 |      3668 | 
##                                  |   2243.98 |   1424.02 |           | 
##                                  |     41.46 |     65.34 |           | 
##                                  |      0.69 |      0.31 |      0.06 | 
##                                  |      0.07 |      0.05 |           | 
##                                  |      0.04 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           BUTLER |      1074 |       990 |      2064 | 
##                                  |   1262.70 |    801.30 |           | 
##                                  |     28.20 |     44.44 |           | 
##                                  |      0.52 |      0.48 |      0.04 | 
##                                  |      0.03 |      0.05 |           | 
##                                  |      0.02 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           CARMOO |         0 |         1 |         1 | 
##                                  |      0.61 |      0.39 |           | 
##                                  |      0.61 |      0.96 |           | 
##                                  |      0.00 |      1.00 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           CASHMA |       188 |       334 |       522 | 
##                                  |    319.34 |    202.66 |           | 
##                                  |     54.02 |     85.13 |           | 
##                                  |      0.36 |      0.64 |      0.01 | 
##                                  |      0.01 |      0.02 |           | 
##                                  |      0.00 |      0.01 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           CASSID |       897 |      1054 |      1951 | 
##                                  |   1193.57 |    757.43 |           | 
##                                  |     73.69 |    116.12 |           | 
##                                  |      0.46 |      0.54 |      0.03 | 
##                                  |      0.03 |      0.05 |           | 
##                                  |      0.02 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           COLGAN |      4823 |      2248 |      7071 | 
##                                  |   4325.83 |   2745.17 |           | 
##                                  |     57.14 |     90.04 |           | 
##                                  |      0.68 |      0.32 |      0.12 | 
##                                  |      0.14 |      0.10 |           | 
##                                  |      0.09 |      0.04 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           DODDSM |       875 |       484 |      1359 | 
##                                  |    831.40 |    527.60 |           | 
##                                  |      2.29 |      3.60 |           | 
##                                  |      0.64 |      0.36 |      0.02 | 
##                                  |      0.03 |      0.02 |           | 
##                                  |      0.02 |      0.01 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                              FRA |         0 |         1 |         1 | 
##                                  |      0.61 |      0.39 |           | 
##                                  |      0.61 |      0.96 |           | 
##                                  |      0.00 |      1.00 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           HYNESD |       360 |       381 |       741 | 
##                                  |    453.32 |    287.68 |           | 
##                                  |     19.21 |     30.27 |           | 
##                                  |      0.49 |      0.51 |      0.01 | 
##                                  |      0.01 |      0.02 |           | 
##                                  |      0.01 |      0.01 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           LYNCSA |        93 |        46 |       139 | 
##                                  |     85.04 |     53.96 |           | 
##                                  |      0.75 |      1.18 |           | 
##                                  |      0.67 |      0.33 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           LYONSF |      2419 |      1968 |      4387 | 
##                                  |   2683.84 |   1703.16 |           | 
##                                  |     26.13 |     41.18 |           | 
##                                  |      0.55 |      0.45 |      0.08 | 
##                                  |      0.07 |      0.09 |           | 
##                                  |      0.04 |      0.03 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                             MARA |      2868 |       973 |      3841 | 
##                                  |   2349.81 |   1491.19 |           | 
##                                  |    114.27 |    180.07 |           | 
##                                  |      0.75 |      0.25 |      0.07 | 
##                                  |      0.08 |      0.04 |           | 
##                                  |      0.05 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           MCSORK |        61 |        89 |       150 | 
##                                  |     91.77 |     58.23 |           | 
##                                  |     10.31 |     16.25 |           | 
##                                  |      0.41 |      0.59 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                            MOROP |      5515 |      2539 |      8054 | 
##                                  |   4927.20 |   3126.80 |           | 
##                                  |     70.12 |    110.50 |           | 
##                                  |      0.68 |      0.32 |      0.14 | 
##                                  |      0.16 |      0.12 |           | 
##                                  |      0.10 |      0.04 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                            MORRI |      1937 |      1551 |      3488 | 
##                                  |   2133.86 |   1354.14 |           | 
##                                  |     18.16 |     28.62 |           | 
##                                  |      0.56 |      0.44 |      0.06 | 
##                                  |      0.06 |      0.07 |           | 
##                                  |      0.03 |      0.03 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           MURMAR |        96 |        61 |       157 | 
##                                  |     96.05 |     60.95 |           | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.61 |      0.39 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           OHEIRE |      4692 |      3819 |      8511 | 
##                                  |   5206.78 |   3304.22 |           | 
##                                  |     50.90 |     80.20 |           | 
##                                  |      0.55 |      0.45 |      0.15 | 
##                                  |      0.14 |      0.17 |           | 
##                                  |      0.08 |      0.07 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           ONEISH |      1758 |      1365 |      3123 | 
##                                  |   1910.56 |   1212.44 |           | 
##                                  |     12.18 |     19.20 |           | 
##                                  |      0.56 |      0.44 |      0.06 | 
##                                  |      0.05 |      0.06 |           | 
##                                  |      0.03 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           ORTCON |         0 |         1 |         1 | 
##                                  |      0.61 |      0.39 |           | 
##                                  |      0.61 |      0.96 |           | 
##                                  |      0.00 |      1.00 |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           SYNNOT |      2986 |      1676 |      4662 | 
##                                  |   2852.08 |   1809.92 |           | 
##                                  |      6.29 |      9.91 |           | 
##                                  |      0.64 |      0.36 |      0.08 | 
##                                  |      0.09 |      0.08 |           | 
##                                  |      0.05 |      0.03 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                           TIMLIN |      1464 |      1292 |      2756 | 
##                                  |   1686.04 |   1069.96 |           | 
##                                  |     29.24 |     46.08 |           | 
##                                  |      0.53 |      0.47 |      0.05 | 
##                                  |      0.04 |      0.06 |           | 
##                                  |      0.03 |      0.02 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                               XX |         0 |         0 |         0 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |       NaN |       NaN |           | 
##                                  |       NaN |       NaN |      0.00 | 
##                                  |      0.00 |      0.00 |           | 
##                                  |      0.00 |      0.00 |           | 
## ---------------------------------|-----------|-----------|-----------|
##                     Column Total |     34655 |     21992 |     56647 | 
##                                  |      0.61 |      0.39 |           | 
## ---------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  21     p =  NaN 
## 
## 
## 
CrossTable(main_processed$Insurance.Scheme_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                        | main_processed$New.Attendances 
## main_processed$Insurance.Scheme_recode |         0 |         1 | Row Total | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      A |        85 |        52 |       137 | 
##                                        |     83.81 |     53.19 |           | 
##                                        |      0.02 |      0.03 |           | 
##                                        |      0.62 |      0.38 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      B |      1280 |       500 |      1780 | 
##                                        |   1088.95 |    691.05 |           | 
##                                        |     33.52 |     52.82 |           | 
##                                        |      0.72 |      0.28 |      0.03 | 
##                                        |      0.04 |      0.02 |           | 
##                                        |      0.02 |      0.01 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      C |         2 |         4 |         6 | 
##                                        |      3.67 |      2.33 |           | 
##                                        |      0.76 |      1.20 |           | 
##                                        |      0.33 |      0.67 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      D |     14038 |      7358 |     21396 | 
##                                        |  13089.46 |   8306.54 |           | 
##                                        |     68.74 |    108.32 |           | 
##                                        |      0.66 |      0.34 |      0.38 | 
##                                        |      0.41 |      0.33 |           | 
##                                        |      0.25 |      0.13 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      E |        52 |        31 |        83 | 
##                                        |     50.78 |     32.22 |           | 
##                                        |      0.03 |      0.05 |           | 
##                                        |      0.63 |      0.37 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      G |       216 |       120 |       336 | 
##                                        |    205.56 |    130.44 |           | 
##                                        |      0.53 |      0.84 |           | 
##                                        |      0.64 |      0.36 |      0.01 | 
##                                        |      0.01 |      0.01 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      H |        48 |        22 |        70 | 
##                                        |     42.82 |     27.18 |           | 
##                                        |      0.63 |      0.99 |           | 
##                                        |      0.69 |      0.31 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      I |      1103 |       459 |      1562 | 
##                                        |    955.59 |    606.41 |           | 
##                                        |     22.74 |     35.83 |           | 
##                                        |      0.71 |      0.29 |      0.03 | 
##                                        |      0.03 |      0.02 |           | 
##                                        |      0.02 |      0.01 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      J |        32 |        10 |        42 | 
##                                        |     25.69 |     16.31 |           | 
##                                        |      1.55 |      2.44 |           | 
##                                        |      0.76 |      0.24 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      M |         2 |         3 |         5 | 
##                                        |      3.06 |      1.94 |           | 
##                                        |      0.37 |      0.58 |           | 
##                                        |      0.40 |      0.60 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      O |       191 |       177 |       368 | 
##                                        |    225.13 |    142.87 |           | 
##                                        |      5.17 |      8.15 |           | 
##                                        |      0.52 |      0.48 |      0.01 | 
##                                        |      0.01 |      0.01 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      P |        68 |        36 |       104 | 
##                                        |     63.62 |     40.38 |           | 
##                                        |      0.30 |      0.47 |           | 
##                                        |      0.65 |      0.35 |      0.00 | 
##                                        |      0.00 |      0.00 |           | 
##                                        |      0.00 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      S |       605 |       276 |       881 | 
##                                        |    538.97 |    342.03 |           | 
##                                        |      8.09 |     12.75 |           | 
##                                        |      0.69 |      0.31 |      0.02 | 
##                                        |      0.02 |      0.01 |           | 
##                                        |      0.01 |      0.00 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      U |     13418 |     11320 |     24738 | 
##                                        |  15133.99 |   9604.01 |           | 
##                                        |    194.57 |    306.61 |           | 
##                                        |      0.54 |      0.46 |      0.44 | 
##                                        |      0.39 |      0.51 |           | 
##                                        |      0.24 |      0.20 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                                      V |      3515 |      1624 |      5139 | 
##                                        |   3143.89 |   1995.11 |           | 
##                                        |     43.81 |     69.03 |           | 
##                                        |      0.68 |      0.32 |      0.09 | 
##                                        |      0.10 |      0.07 |           | 
##                                        |      0.06 |      0.03 |           | 
## ---------------------------------------|-----------|-----------|-----------|
##                           Column Total |     34655 |     21992 |     56647 | 
##                                        |      0.61 |      0.39 |           | 
## ---------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  981     d.f. =  14     p =  2e-200 
## 
## 
## 
CrossTable(main_processed$Eligibility_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                   | main_processed$New.Attendances 
## main_processed$Eligibility_recode |         0 |         1 | Row Total | 
## ----------------------------------|-----------|-----------|-----------|
##                            15000+ |         0 |         0 |         0 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |       NaN |       NaN |           | 
##                                   |       NaN |       NaN |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                ACUTE UNCLASSIFIED |       398 |       162 |       560 | 
##                                   |    342.59 |    217.41 |           | 
##                                   |      8.96 |     14.12 |           | 
##                                   |      0.71 |      0.29 |      0.01 | 
##                                   |      0.01 |      0.01 |           | 
##                                   |      0.01 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##               ELIGIBILITY UNKNOWN |       144 |       444 |       588 | 
##                                   |    359.72 |    228.28 |           | 
##                                   |    129.37 |    203.86 |           | 
##                                   |      0.24 |      0.76 |      0.01 | 
##                                   |      0.00 |      0.02 |           | 
##                                   |      0.00 |      0.01 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                            EXEMPT |      1586 |       974 |      2560 | 
##                                   |   1566.13 |    993.87 |           | 
##                                   |      0.25 |      0.40 |           | 
##                                   |      0.62 |      0.38 |      0.05 | 
##                                   |      0.05 |      0.04 |           | 
##                                   |      0.03 |      0.02 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      MEDICAL CARD |     15132 |      9036 |     24168 | 
##                                   |  14785.29 |   9382.71 |           | 
##                                   |      8.13 |     12.81 |           | 
##                                   |      0.63 |      0.37 |      0.43 | 
##                                   |      0.44 |      0.41 |           | 
##                                   |      0.27 |      0.16 |           | 
## ----------------------------------|-----------|-----------|-----------|
##            NON ACUTE UNCLASSIFIED |        19 |        10 |        29 | 
##                                   |     17.74 |     11.26 |           | 
##                                   |      0.09 |      0.14 |           | 
##                                   |      0.66 |      0.34 |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                  NON MEDICAL CARD |     17307 |     11325 |     28632 | 
##                                   |  17516.23 |  11115.77 |           | 
##                                   |      2.50 |      3.94 |           | 
##                                   |      0.60 |      0.40 |      0.51 | 
##                                   |      0.50 |      0.51 |           | 
##                                   |      0.31 |      0.20 |           | 
## ----------------------------------|-----------|-----------|-----------|
##           RESEARCH/NATIONAL PROG. |        69 |        41 |       110 | 
##                                   |     67.29 |     42.71 |           | 
##                                   |      0.04 |      0.07 |           | 
##                                   |      0.63 |      0.37 |      0.00 | 
##                                   |      0.00 |      0.00 |           | 
##                                   |      0.00 |      0.00 |           | 
## ----------------------------------|-----------|-----------|-----------|
##                      Column Total |     34655 |     21992 |     56647 | 
##                                   |      0.61 |      0.39 |           | 
## ----------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  7     p =  NaN 
## 
## 
## 
CrossTable(main_processed$Booking.Type_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                    | main_processed$New.Attendances 
## main_processed$Booking.Type_recode |         0 |         1 | Row Total | 
## -----------------------------------|-----------|-----------|-----------|
##             B : New  Virtual Video |         3 |       486 |       489 | 
##                                    |    299.16 |    189.84 |           | 
##                                    |    293.19 |    462.00 |           | 
##                                    |      0.01 |      0.99 |      0.01 | 
##                                    |      0.00 |      0.02 |           | 
##                                    |      0.00 |      0.01 |           | 
## -----------------------------------|-----------|-----------|-----------|
##             C : New  Virtual Phone |       178 |      4389 |      4567 | 
##                                    |   2793.96 |   1773.04 |           | 
##                                    |   2449.30 |   3859.61 |           | 
##                                    |      0.04 |      0.96 |      0.08 | 
##                                    |      0.01 |      0.20 |           | 
##                                    |      0.00 |      0.08 |           | 
## -----------------------------------|-----------|-----------|-----------|
##          D : Return  Virtual Video |         2 |         1 |         3 | 
##                                    |      1.84 |      1.16 |           | 
##                                    |      0.01 |      0.02 |           | 
##                                    |      0.67 |      0.33 |      0.00 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |      0.00 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##          E : Return  Virtual Phone |        12 |         0 |        12 | 
##                                    |      7.34 |      4.66 |           | 
##                                    |      2.96 |      4.66 |           | 
##                                    |      1.00 |      0.00 |      0.00 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |      0.00 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                                NEW |      1407 |     14757 |     16164 | 
##                                    |   9888.67 |   6275.33 |           | 
##                                    |   7274.86 |  11463.73 |           | 
##                                    |      0.09 |      0.91 |      0.29 | 
##                                    |      0.04 |      0.67 |           | 
##                                    |      0.02 |      0.26 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                             RETURN |     29477 |      2191 |     31668 | 
##                                    |  19373.57 |  12294.43 |           | 
##                                    |   5269.00 |   8302.89 |           | 
##                                    |      0.93 |      0.07 |      0.56 | 
##                                    |      0.85 |      0.10 |           | 
##                                    |      0.52 |      0.04 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                         V : REVIEW |         0 |         0 |         0 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |       NaN |       NaN |           | 
##                                    |       NaN |       NaN |      0.00 | 
##                                    |      0.00 |      0.00 |           | 
##                                    |      0.00 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                               WARD |      3576 |       168 |      3744 | 
##                                    |   2290.47 |   1453.53 |           | 
##                                    |    721.50 |   1136.95 |           | 
##                                    |      0.96 |      0.04 |      0.07 | 
##                                    |      0.10 |      0.01 |           | 
##                                    |      0.06 |      0.00 |           | 
## -----------------------------------|-----------|-----------|-----------|
##                       Column Total |     34655 |     21992 |     56647 | 
##                                    |      0.61 |      0.39 |           | 
## -----------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  7     p =  NaN 
## 
## 
## 
CrossTable(main_processed$Hospital.Catchment_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                          | main_processed$New.Attendances 
## main_processed$Hospital.Catchment_recode |         0 |         1 | Row Total | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Beaumont |      1590 |      1117 |      2707 | 
##                                          |   1656.06 |   1050.94 |           | 
##                                          |      2.64 |      4.15 |           | 
##                                          |      0.59 |      0.41 |      0.05 | 
##                                          |      0.05 |      0.05 |           | 
##                                          |      0.03 |      0.02 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Connolly |      1667 |      1319 |      2986 | 
##                                          |   1826.75 |   1159.25 |           | 
##                                          |     13.97 |     22.01 |           | 
##                                          |      0.56 |      0.44 |      0.05 | 
##                                          |      0.05 |      0.06 |           | 
##                                          |      0.03 |      0.02 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                            International |       137 |       119 |       256 | 
##                                          |    156.61 |     99.39 |           | 
##                                          |      2.46 |      3.87 |           | 
##                                          |      0.54 |      0.46 |      0.00 | 
##                                          |      0.00 |      0.01 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    James |      2194 |      1690 |      3884 | 
##                                          |   2376.12 |   1507.88 |           | 
##                                          |     13.96 |     22.00 |           | 
##                                          |      0.56 |      0.44 |      0.07 | 
##                                          |      0.06 |      0.08 |           | 
##                                          |      0.04 |      0.03 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    Mater |     17022 |     10541 |     27563 | 
##                                          |  16862.25 |  10700.75 |           | 
##                                          |      1.51 |      2.38 |           | 
##                                          |      0.62 |      0.38 |      0.49 | 
##                                          |      0.49 |      0.48 |           | 
##                                          |      0.30 |      0.19 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 National |      9720 |      5682 |     15402 | 
##                                          |   9422.50 |   5979.50 |           | 
##                                          |      9.39 |     14.80 |           | 
##                                          |      0.63 |      0.37 |      0.27 | 
##                                          |      0.28 |      0.26 |           | 
##                                          |      0.17 |      0.10 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Tallaght |       742 |       559 |      1301 | 
##                                          |    795.91 |    505.09 |           | 
##                                          |      3.65 |      5.75 |           | 
##                                          |      0.57 |      0.43 |      0.02 | 
##                                          |      0.02 |      0.03 |           | 
##                                          |      0.01 |      0.01 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                 Vincents |      1583 |       965 |      2548 | 
##                                          |   1558.79 |    989.21 |           | 
##                                          |      0.38 |      0.59 |           | 
##                                          |      0.62 |      0.38 |      0.04 | 
##                                          |      0.05 |      0.04 |           | 
##                                          |      0.03 |      0.02 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                             Column Total |     34655 |     21992 |     56647 | 
##                                          |      0.61 |      0.39 |           | 
## -----------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  124     d.f. =  7     p =  1.4e-23 
## 
## 
## 
## date relevance
CrossTable(main_processed$bookedDay, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  50967 
## 
##  
##                          | main_processed$New.Attendances 
## main_processed$bookedDay |         0 |         1 | Row Total | 
## -------------------------|-----------|-----------|-----------|
##                   Friday |      3346 |      2747 |      6093 | 
##                          |   3783.81 |   2309.19 |           | 
##                          |     50.66 |     83.01 |           | 
##                          |      0.55 |      0.45 |      0.12 | 
##                          |      0.11 |      0.14 |           | 
##                          |      0.07 |      0.05 |           | 
## -------------------------|-----------|-----------|-----------|
##                   Monday |      6399 |      3648 |     10047 | 
##                          |   6239.28 |   3807.72 |           | 
##                          |      4.09 |      6.70 |           | 
##                          |      0.64 |      0.36 |      0.20 | 
##                          |      0.20 |      0.19 |           | 
##                          |      0.13 |      0.07 |           | 
## -------------------------|-----------|-----------|-----------|
##                 Saturday |      3717 |      2719 |      6436 | 
##                          |   3996.82 |   2439.18 |           | 
##                          |     19.59 |     32.10 |           | 
##                          |      0.58 |      0.42 |      0.13 | 
##                          |      0.12 |      0.14 |           | 
##                          |      0.07 |      0.05 |           | 
## -------------------------|-----------|-----------|-----------|
##                   Sunday |      5155 |      3364 |      8519 | 
##                          |   5290.38 |   3228.62 |           | 
##                          |      3.46 |      5.68 |           | 
##                          |      0.61 |      0.39 |      0.17 | 
##                          |      0.16 |      0.17 |           | 
##                          |      0.10 |      0.07 |           | 
## -------------------------|-----------|-----------|-----------|
##                 Thursday |      2846 |      1728 |      4574 | 
##                          |   2840.50 |   1733.50 |           | 
##                          |      0.01 |      0.02 |           | 
##                          |      0.62 |      0.38 |      0.09 | 
##                          |      0.09 |      0.09 |           | 
##                          |      0.06 |      0.03 |           | 
## -------------------------|-----------|-----------|-----------|
##                  Tuesday |      6056 |      2957 |      9013 | 
##                          |   5597.16 |   3415.84 |           | 
##                          |     37.61 |     61.63 |           | 
##                          |      0.67 |      0.33 |      0.18 | 
##                          |      0.19 |      0.15 |           | 
##                          |      0.12 |      0.06 |           | 
## -------------------------|-----------|-----------|-----------|
##                Wednesday |      4132 |      2153 |      6285 | 
##                          |   3903.05 |   2381.95 |           | 
##                          |     13.43 |     22.01 |           | 
##                          |      0.66 |      0.34 |      0.12 | 
##                          |      0.13 |      0.11 |           | 
##                          |      0.08 |      0.04 |           | 
## -------------------------|-----------|-----------|-----------|
##             Column Total |     31651 |     19316 |     50967 | 
##                          |      0.62 |      0.38 |           | 
## -------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  340     d.f. =  6     p =  2.2e-70 
## 
## 
## 
CrossTable(main_processed$bookedMonthYear, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  50967 
## 
##  
##                                | main_processed$New.Attendances 
## main_processed$bookedMonthYear |         0 |         1 | Row Total | 
## -------------------------------|-----------|-----------|-----------|
##                       Apr 2020 |      2217 |      1320 |      3537 | 
##                                |   2196.51 |   1340.49 |           | 
##                                |      0.19 |      0.31 |           | 
##                                |      0.63 |      0.37 |      0.07 | 
##                                |      0.07 |      0.07 |           | 
##                                |      0.04 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Aug 2020 |      2707 |      1749 |      4456 | 
##                                |   2767.22 |   1688.78 |           | 
##                                |      1.31 |      2.15 |           | 
##                                |      0.61 |      0.39 |      0.09 | 
##                                |      0.09 |      0.09 |           | 
##                                |      0.05 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Dec 2020 |      2279 |      1372 |      3651 | 
##                                |   2267.31 |   1383.69 |           | 
##                                |      0.06 |      0.10 |           | 
##                                |      0.62 |      0.38 |      0.07 | 
##                                |      0.07 |      0.07 |           | 
##                                |      0.04 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Feb 2020 |      2533 |      1660 |      4193 | 
##                                |   2603.89 |   1589.11 |           | 
##                                |      1.93 |      3.16 |           | 
##                                |      0.60 |      0.40 |      0.08 | 
##                                |      0.08 |      0.09 |           | 
##                                |      0.05 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Jan 2020 |      2886 |      1796 |      4682 | 
##                                |   2907.57 |   1774.43 |           | 
##                                |      0.16 |      0.26 |           | 
##                                |      0.62 |      0.38 |      0.09 | 
##                                |      0.09 |      0.09 |           | 
##                                |      0.06 |      0.04 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Jul 2020 |      2858 |      1572 |      4430 | 
##                                |   2751.07 |   1678.93 |           | 
##                                |      4.16 |      6.81 |           | 
##                                |      0.65 |      0.35 |      0.09 | 
##                                |      0.09 |      0.08 |           | 
##                                |      0.06 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Jun 2020 |      2689 |      1645 |      4334 | 
##                                |   2691.46 |   1642.54 |           | 
##                                |      0.00 |      0.00 |           | 
##                                |      0.62 |      0.38 |      0.09 | 
##                                |      0.08 |      0.09 |           | 
##                                |      0.05 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Mar 2020 |      2555 |      1479 |      4034 | 
##                                |   2505.15 |   1528.85 |           | 
##                                |      0.99 |      1.63 |           | 
##                                |      0.63 |      0.37 |      0.08 | 
##                                |      0.08 |      0.08 |           | 
##                                |      0.05 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       May 2020 |      2644 |      1473 |      4117 | 
##                                |   2556.70 |   1560.30 |           | 
##                                |      2.98 |      4.88 |           | 
##                                |      0.64 |      0.36 |      0.08 | 
##                                |      0.08 |      0.08 |           | 
##                                |      0.05 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Nov 2020 |      2724 |      1800 |      4524 | 
##                                |   2809.45 |   1714.55 |           | 
##                                |      2.60 |      4.26 |           | 
##                                |      0.60 |      0.40 |      0.09 | 
##                                |      0.09 |      0.09 |           | 
##                                |      0.05 |      0.04 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Oct 2020 |      2785 |      1770 |      4555 | 
##                                |   2828.70 |   1726.30 |           | 
##                                |      0.68 |      1.11 |           | 
##                                |      0.61 |      0.39 |      0.09 | 
##                                |      0.09 |      0.09 |           | 
##                                |      0.05 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                       Sep 2020 |      2774 |      1680 |      4454 | 
##                                |   2765.98 |   1688.02 |           | 
##                                |      0.02 |      0.04 |           | 
##                                |      0.62 |      0.38 |      0.09 | 
##                                |      0.09 |      0.09 |           | 
##                                |      0.05 |      0.03 |           | 
## -------------------------------|-----------|-----------|-----------|
##                   Column Total |     31651 |     19316 |     50967 | 
##                                |      0.62 |      0.38 |           | 
## -------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  40     d.f. =  11     p =  3.9e-05 
## 
## 
## 
CrossTable(main_processed$Attendance.Day, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                               | main_processed$New.Attendances 
## main_processed$Attendance.Day |         0 |         1 | Row Total | 
## ------------------------------|-----------|-----------|-----------|
##                        Friday |      8399 |      3769 |     12168 | 
##                               |   7444.03 |   4723.97 |           | 
##                               |    122.51 |    193.05 |           | 
##                               |      0.69 |      0.31 |      0.21 | 
##                               |      0.24 |      0.17 |           | 
##                               |      0.15 |      0.07 |           | 
## ------------------------------|-----------|-----------|-----------|
##                        Monday |      6851 |      4631 |     11482 | 
##                               |   7024.36 |   4457.64 |           | 
##                               |      4.28 |      6.74 |           | 
##                               |      0.60 |      0.40 |      0.20 | 
##                               |      0.20 |      0.21 |           | 
##                               |      0.12 |      0.08 |           | 
## ------------------------------|-----------|-----------|-----------|
##                      Saturday |         0 |         1 |         1 | 
##                               |      0.61 |      0.39 |           | 
##                               |      0.61 |      0.96 |           | 
##                               |      0.00 |      1.00 |      0.00 | 
##                               |      0.00 |      0.00 |           | 
##                               |      0.00 |      0.00 |           | 
## ------------------------------|-----------|-----------|-----------|
##                        Sunday |         7 |         0 |         7 | 
##                               |      4.28 |      2.72 |           | 
##                               |      1.72 |      2.72 |           | 
##                               |      1.00 |      0.00 |      0.00 | 
##                               |      0.00 |      0.00 |           | 
##                               |      0.00 |      0.00 |           | 
## ------------------------------|-----------|-----------|-----------|
##                      Thursday |      6083 |      4131 |     10214 | 
##                               |   6248.63 |   3965.37 |           | 
##                               |      4.39 |      6.92 |           | 
##                               |      0.60 |      0.40 |      0.18 | 
##                               |      0.18 |      0.19 |           | 
##                               |      0.11 |      0.07 |           | 
## ------------------------------|-----------|-----------|-----------|
##                       Tuesday |      6496 |      4198 |     10694 | 
##                               |   6542.28 |   4151.72 |           | 
##                               |      0.33 |      0.52 |           | 
##                               |      0.61 |      0.39 |      0.19 | 
##                               |      0.19 |      0.19 |           | 
##                               |      0.11 |      0.07 |           | 
## ------------------------------|-----------|-----------|-----------|
##                     Wednesday |      6819 |      5262 |     12081 | 
##                               |   7390.81 |   4690.19 |           | 
##                               |     44.24 |     69.71 |           | 
##                               |      0.56 |      0.44 |      0.21 | 
##                               |      0.20 |      0.24 |           | 
##                               |      0.12 |      0.09 |           | 
## ------------------------------|-----------|-----------|-----------|
##                  Column Total |     34655 |     21992 |     56647 | 
##                               |      0.61 |      0.39 |           | 
## ------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  459     d.f. =  6     p =  6.6e-96 
## 
## 
## 
CrossTable(main_processed$Attendance.MonthYear, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                     | main_processed$New.Attendances 
## main_processed$Attendance.MonthYear |         0 |         1 | Row Total | 
## ------------------------------------|-----------|-----------|-----------|
##                              Apr-20 |       300 |       135 |       435 | 
##                                     |    266.12 |    168.88 |           | 
##                                     |      4.31 |      6.80 |           | 
##                                     |      0.69 |      0.31 |      0.01 | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.01 |      0.00 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Apr-21 |       609 |       390 |       999 | 
##                                     |    611.16 |    387.84 |           | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.61 |      0.39 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Apr-22 |       689 |       463 |      1152 | 
##                                     |    704.76 |    447.24 |           | 
##                                     |      0.35 |      0.56 |           | 
##                                     |      0.60 |      0.40 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Apr-23 |       800 |       440 |      1240 | 
##                                     |    758.60 |    481.40 |           | 
##                                     |      2.26 |      3.56 |           | 
##                                     |      0.65 |      0.35 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Aug-20 |       550 |       343 |       893 | 
##                                     |    546.31 |    346.69 |           | 
##                                     |      0.02 |      0.04 |           | 
##                                     |      0.62 |      0.38 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Aug-21 |       735 |       396 |      1131 | 
##                                     |    691.91 |    439.09 |           | 
##                                     |      2.68 |      4.23 |           | 
##                                     |      0.65 |      0.35 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Aug-22 |       737 |       452 |      1189 | 
##                                     |    727.40 |    461.60 |           | 
##                                     |      0.13 |      0.20 |           | 
##                                     |      0.62 |      0.38 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Aug-23 |       948 |       566 |      1514 | 
##                                     |    926.22 |    587.78 |           | 
##                                     |      0.51 |      0.81 |           | 
##                                     |      0.63 |      0.37 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Dec-20 |       554 |       384 |       938 | 
##                                     |    573.84 |    364.16 |           | 
##                                     |      0.69 |      1.08 |           | 
##                                     |      0.59 |      0.41 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Dec-21 |       565 |       424 |       989 | 
##                                     |    605.04 |    383.96 |           | 
##                                     |      2.65 |      4.18 |           | 
##                                     |      0.57 |      0.43 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Dec-22 |       796 |       527 |      1323 | 
##                                     |    809.37 |    513.63 |           | 
##                                     |      0.22 |      0.35 |           | 
##                                     |      0.60 |      0.40 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Dec-23 |       765 |       413 |      1178 | 
##                                     |    720.67 |    457.33 |           | 
##                                     |      2.73 |      4.30 |           | 
##                                     |      0.65 |      0.35 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Feb-20 |       718 |       554 |      1272 | 
##                                     |    778.17 |    493.83 |           | 
##                                     |      4.65 |      7.33 |           | 
##                                     |      0.56 |      0.44 |      0.02 | 
##                                     |      0.02 |      0.03 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Feb-21 |       480 |       368 |       848 | 
##                                     |    518.78 |    329.22 |           | 
##                                     |      2.90 |      4.57 |           | 
##                                     |      0.57 |      0.43 |      0.01 | 
##                                     |      0.01 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Feb-22 |       684 |       449 |      1133 | 
##                                     |    693.14 |    439.86 |           | 
##                                     |      0.12 |      0.19 |           | 
##                                     |      0.60 |      0.40 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Feb-23 |       986 |       466 |      1452 | 
##                                     |    888.29 |    563.71 |           | 
##                                     |     10.75 |     16.94 |           | 
##                                     |      0.68 |      0.32 |      0.03 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jan-20 |       778 |       569 |      1347 | 
##                                     |    824.06 |    522.94 |           | 
##                                     |      2.57 |      4.06 |           | 
##                                     |      0.58 |      0.42 |      0.02 | 
##                                     |      0.02 |      0.03 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jan-21 |       533 |       313 |       846 | 
##                                     |    517.56 |    328.44 |           | 
##                                     |      0.46 |      0.73 |           | 
##                                     |      0.63 |      0.37 |      0.01 | 
##                                     |      0.02 |      0.01 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jan-22 |       641 |       428 |      1069 | 
##                                     |    653.98 |    415.02 |           | 
##                                     |      0.26 |      0.41 |           | 
##                                     |      0.60 |      0.40 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jan-23 |      1005 |       579 |      1584 | 
##                                     |    969.05 |    614.95 |           | 
##                                     |      1.33 |      2.10 |           | 
##                                     |      0.63 |      0.37 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jul-20 |       595 |       342 |       937 | 
##                                     |    573.23 |    363.77 |           | 
##                                     |      0.83 |      1.30 |           | 
##                                     |      0.64 |      0.36 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jul-21 |       732 |       429 |      1161 | 
##                                     |    710.27 |    450.73 |           | 
##                                     |      0.67 |      1.05 |           | 
##                                     |      0.63 |      0.37 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jul-22 |       786 |       407 |      1193 | 
##                                     |    729.84 |    463.16 |           | 
##                                     |      4.32 |      6.81 |           | 
##                                     |      0.66 |      0.34 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jul-23 |       962 |       532 |      1494 | 
##                                     |    913.99 |    580.01 |           | 
##                                     |      2.52 |      3.97 |           | 
##                                     |      0.64 |      0.36 |      0.03 | 
##                                     |      0.03 |      0.02 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jun-20 |       406 |       283 |       689 | 
##                                     |    421.51 |    267.49 |           | 
##                                     |      0.57 |      0.90 |           | 
##                                     |      0.59 |      0.41 |      0.01 | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.01 |      0.00 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jun-21 |       677 |       437 |      1114 | 
##                                     |    681.51 |    432.49 |           | 
##                                     |      0.03 |      0.05 |           | 
##                                     |      0.61 |      0.39 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jun-22 |       729 |       447 |      1176 | 
##                                     |    719.44 |    456.56 |           | 
##                                     |      0.13 |      0.20 |           | 
##                                     |      0.62 |      0.38 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Jun-23 |       936 |       565 |      1501 | 
##                                     |    918.27 |    582.73 |           | 
##                                     |      0.34 |      0.54 |           | 
##                                     |      0.62 |      0.38 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Mar-20 |       514 |       265 |       779 | 
##                                     |    476.57 |    302.43 |           | 
##                                     |      2.94 |      4.63 |           | 
##                                     |      0.66 |      0.34 |      0.01 | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.01 |      0.00 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Mar-21 |       617 |       519 |      1136 | 
##                                     |    694.97 |    441.03 |           | 
##                                     |      8.75 |     13.79 |           | 
##                                     |      0.54 |      0.46 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Mar-22 |       660 |       484 |      1144 | 
##                                     |    699.87 |    444.13 |           | 
##                                     |      2.27 |      3.58 |           | 
##                                     |      0.58 |      0.42 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Mar-23 |      1021 |       611 |      1632 | 
##                                     |    998.41 |    633.59 |           | 
##                                     |      0.51 |      0.81 |           | 
##                                     |      0.63 |      0.37 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              May-20 |       297 |       216 |       513 | 
##                                     |    313.84 |    199.16 |           | 
##                                     |      0.90 |      1.42 |           | 
##                                     |      0.58 |      0.42 |      0.01 | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.01 |      0.00 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              May-21 |       628 |       432 |      1060 | 
##                                     |    648.48 |    411.52 |           | 
##                                     |      0.65 |      1.02 |           | 
##                                     |      0.59 |      0.41 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              May-22 |       808 |       531 |      1339 | 
##                                     |    819.16 |    519.84 |           | 
##                                     |      0.15 |      0.24 |           | 
##                                     |      0.60 |      0.40 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              May-23 |       963 |       616 |      1579 | 
##                                     |    965.99 |    613.01 |           | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.61 |      0.39 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Nov-20 |       663 |       335 |       998 | 
##                                     |    610.55 |    387.45 |           | 
##                                     |      4.51 |      7.10 |           | 
##                                     |      0.66 |      0.34 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Nov-21 |       626 |       595 |      1221 | 
##                                     |    746.97 |    474.03 |           | 
##                                     |     19.59 |     30.87 |           | 
##                                     |      0.51 |      0.49 |      0.02 | 
##                                     |      0.02 |      0.03 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Nov-22 |       991 |       630 |      1621 | 
##                                     |    991.68 |    629.32 |           | 
##                                     |      0.00 |      0.00 |           | 
##                                     |      0.61 |      0.39 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Nov-23 |       962 |       617 |      1579 | 
##                                     |    965.99 |    613.01 |           | 
##                                     |      0.02 |      0.03 |           | 
##                                     |      0.61 |      0.39 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Oct-20 |       658 |       344 |      1002 | 
##                                     |    612.99 |    389.01 |           | 
##                                     |      3.30 |      5.21 |           | 
##                                     |      0.66 |      0.34 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Oct-21 |       600 |       529 |      1129 | 
##                                     |    690.69 |    438.31 |           | 
##                                     |     11.91 |     18.76 |           | 
##                                     |      0.53 |      0.47 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Oct-22 |       795 |       632 |      1427 | 
##                                     |    873.00 |    554.00 |           | 
##                                     |      6.97 |     10.98 |           | 
##                                     |      0.56 |      0.44 |      0.03 | 
##                                     |      0.02 |      0.03 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Oct-23 |       934 |       592 |      1526 | 
##                                     |    933.56 |    592.44 |           | 
##                                     |      0.00 |      0.00 |           | 
##                                     |      0.61 |      0.39 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Sep-20 |       645 |       416 |      1061 | 
##                                     |    649.09 |    411.91 |           | 
##                                     |      0.03 |      0.04 |           | 
##                                     |      0.61 |      0.39 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Sep-21 |       722 |       396 |      1118 | 
##                                     |    683.96 |    434.04 |           | 
##                                     |      2.12 |      3.33 |           | 
##                                     |      0.65 |      0.35 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.01 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Sep-22 |       852 |       545 |      1397 | 
##                                     |    854.64 |    542.36 |           | 
##                                     |      0.01 |      0.01 |           | 
##                                     |      0.61 |      0.39 |      0.02 | 
##                                     |      0.02 |      0.02 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                              Sep-23 |      1003 |       586 |      1589 | 
##                                     |    972.10 |    616.90 |           | 
##                                     |      0.98 |      1.55 |           | 
##                                     |      0.63 |      0.37 |      0.03 | 
##                                     |      0.03 |      0.03 |           | 
##                                     |      0.02 |      0.01 |           | 
## ------------------------------------|-----------|-----------|-----------|
##                        Column Total |     34655 |     21992 |     56647 | 
##                                     |      0.61 |      0.39 |           | 
## ------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  295     d.f. =  47     p =  1.1e-37 
## 
## 
## 
leveneTest(daysDiff_attendanceBooked ~ as.factor(New.Attendances), data=main_processed) #leveneTest is Ha
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value Pr(>F)    
## group     1     210 <2e-16 ***
##       50965                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t.test(daysDiff_attendanceBooked ~ New.Attendances, var.equal=F, data=main_processed)
## 
##  Welch Two Sample t-test
## 
## data:  daysDiff_attendanceBooked by New.Attendances
## t = 0.4, df = 46373, p-value = 0.7
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -1.2  1.7
## sample estimates:
## mean in group 0 mean in group 1 
##            -3.1            -3.4
## patient characteristics relevance
CrossTable(main_processed$Gender, main_processed$New.Attendances, digits=2, fisher=TRUE, chisq=TRUE, expected=TRUE)
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                       | main_processed$New.Attendances 
## main_processed$Gender |         0 |         1 | Row Total | 
## ----------------------|-----------|-----------|-----------|
##                Female |     17114 |     11211 |     28325 | 
##                       |  17328.42 |  10996.58 |           | 
##                       |      2.65 |      4.18 |           | 
##                       |      0.60 |      0.40 |      0.50 | 
##                       |      0.49 |      0.51 |           | 
##                       |      0.30 |      0.20 |           | 
## ----------------------|-----------|-----------|-----------|
##                  Male |     17538 |     10779 |     28317 | 
##                       |  17323.52 |  10993.48 |           | 
##                       |      2.66 |      4.18 |           | 
##                       |      0.62 |      0.38 |      0.50 | 
##                       |      0.51 |      0.49 |           | 
##                       |      0.31 |      0.19 |           | 
## ----------------------|-----------|-----------|-----------|
##               Unknown |         3 |         2 |         5 | 
##                       |      3.06 |      1.94 |           | 
##                       |      0.00 |      0.00 |           | 
##                       |      0.60 |      0.40 |      0.00 | 
##                       |      0.00 |      0.00 |           | 
##                       |      0.00 |      0.00 |           | 
## ----------------------|-----------|-----------|-----------|
##          Column Total |     34655 |     21992 |     56647 | 
##                       |      0.61 |      0.39 |           | 
## ----------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  14     d.f. =  2     p =  0.0011 
## 
## 
##  
## Fisher's Exact Test for Count Data
## ------------------------------------------------------------
## Alternative hypothesis: two.sided
## p =  5e-04 
## 
## 
CrossTable(main_processed$Age.at.Attendance.Cat.HSE, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE) # age group
## Warning in chisq.test(t, correct = FALSE, ...): Chi-squared approximation may
## be incorrect
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                          | main_processed$New.Attendances 
## main_processed$Age.at.Attendance.Cat.HSE |         0 |         1 | Row Total | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    0 - 4 |         0 |         2 |         2 | 
##                                          |      1.22 |      0.78 |           | 
##                                          |      1.22 |      1.93 |           | 
##                                          |      0.00 |      1.00 |      0.00 | 
##                                          |      0.00 |      0.00 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                   05-Sep |         0 |         0 |         0 | 
##                                          |      0.00 |      0.00 |           | 
##                                          |       NaN |       NaN |           | 
##                                          |       NaN |       NaN |      0.00 | 
##                                          |      0.00 |      0.00 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  15 - 24 |      3564 |      2849 |      6413 | 
##                                          |   3923.29 |   2489.71 |           | 
##                                          |     32.90 |     51.85 |           | 
##                                          |      0.56 |      0.44 |      0.11 | 
##                                          |      0.10 |      0.13 |           | 
##                                          |      0.06 |      0.05 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  25 - 34 |      4729 |      3473 |      8202 | 
##                                          |   5017.75 |   3184.25 |           | 
##                                          |     16.62 |     26.18 |           | 
##                                          |      0.58 |      0.42 |      0.14 | 
##                                          |      0.14 |      0.16 |           | 
##                                          |      0.08 |      0.06 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  35 - 44 |      5072 |      3455 |      8527 | 
##                                          |   5216.57 |   3310.43 |           | 
##                                          |      4.01 |      6.31 |           | 
##                                          |      0.59 |      0.41 |      0.15 | 
##                                          |      0.15 |      0.16 |           | 
##                                          |      0.09 |      0.06 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  45 - 54 |      5986 |      3904 |      9890 | 
##                                          |   6050.42 |   3839.58 |           | 
##                                          |      0.69 |      1.08 |           | 
##                                          |      0.61 |      0.39 |      0.17 | 
##                                          |      0.17 |      0.18 |           | 
##                                          |      0.11 |      0.07 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  55 - 64 |      6711 |      3691 |     10402 | 
##                                          |   6363.64 |   4038.36 |           | 
##                                          |     18.96 |     29.88 |           | 
##                                          |      0.65 |      0.35 |      0.18 | 
##                                          |      0.19 |      0.17 |           | 
##                                          |      0.12 |      0.07 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  65 - 74 |      5368 |      2806 |      8174 | 
##                                          |   5000.62 |   3173.38 |           | 
##                                          |     26.99 |     42.53 |           | 
##                                          |      0.66 |      0.34 |      0.14 | 
##                                          |      0.15 |      0.13 |           | 
##                                          |      0.09 |      0.05 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                  75 - 84 |      2574 |      1435 |      4009 | 
##                                          |   2452.59 |   1556.41 |           | 
##                                          |      6.01 |      9.47 |           | 
##                                          |      0.64 |      0.36 |      0.07 | 
##                                          |      0.07 |      0.07 |           | 
##                                          |      0.05 |      0.03 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                    85 >= |       646 |       369 |      1015 | 
##                                          |    620.95 |    394.05 |           | 
##                                          |      1.01 |      1.59 |           | 
##                                          |      0.64 |      0.36 |      0.02 | 
##                                          |      0.02 |      0.02 |           | 
##                                          |      0.01 |      0.01 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                                   Oct-14 |         5 |         8 |        13 | 
##                                          |      7.95 |      5.05 |           | 
##                                          |      1.10 |      1.73 |           | 
##                                          |      0.38 |      0.62 |      0.00 | 
##                                          |      0.00 |      0.00 |           | 
##                                          |      0.00 |      0.00 |           | 
## -----------------------------------------|-----------|-----------|-----------|
##                             Column Total |     34655 |     21992 |     56647 | 
##                                          |      0.61 |      0.39 |           | 
## -----------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  NaN     d.f. =  10     p =  NaN 
## 
## 
## 
leveneTest(Age.at.Attendance ~ as.factor(New.Attendances), data=main_processed)
## Levene's Test for Homogeneity of Variance (center = median)
##          Df F value  Pr(>F)    
## group     1    11.6 0.00065 ***
##       56645                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
t.test(Age.at.Attendance ~ New.Attendances, var.equal=FALSE, data=main_processed) #leveneTest is Ha
## 
##  Welch Two Sample t-test
## 
## data:  Age.at.Attendance by New.Attendances
## t = 16, df = 46266, p-value <2e-16
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  2.2 2.8
## sample estimates:
## mean in group 0 mean in group 1 
##              50              48
wilcox.test(main_processed$Age.at.Attendance ~ main_processed$New.Attendances)
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  main_processed$Age.at.Attendance by main_processed$New.Attendances
## W = 4e+08, p-value <2e-16
## alternative hypothesis: true location shift is not equal to 0
CrossTable(main_processed$Area.of.Residence_recode, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE) # remove Na or impute where no residence
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                                         | main_processed$New.Attendances 
## main_processed$Area.of.Residence_recode |         0 |         1 | Row Total | 
## ----------------------------------------|-----------|-----------|-----------|
##                              DUBLIN NTH |     22938 |     14675 |     37613 | 
##                                         |  23010.55 |  14602.45 |           | 
##                                         |      0.23 |      0.36 |           | 
##                                         |      0.61 |      0.39 |      0.66 | 
##                                         |      0.66 |      0.67 |           | 
##                                         |      0.40 |      0.26 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                              DUBLIN STH |      4545 |      3225 |      7770 | 
##                                         |   4753.46 |   3016.54 |           | 
##                                         |      9.14 |     14.41 |           | 
##                                         |      0.58 |      0.42 |      0.14 | 
##                                         |      0.13 |      0.15 |           | 
##                                         |      0.08 |      0.06 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##  EASTERN & MIDLAND REGION (excl.Dublin) |      4373 |      2651 |      7024 | 
##                                         |   4297.08 |   2726.92 |           | 
##                                         |      1.34 |      2.11 |           | 
##                                         |      0.62 |      0.38 |      0.12 | 
##                                         |      0.13 |      0.12 |           | 
##                                         |      0.08 |      0.05 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                 NORTHERN WESTERN REGION |      1104 |       585 |      1689 | 
##                                         |   1033.28 |    655.72 |           | 
##                                         |      4.84 |      7.63 |           | 
##                                         |      0.65 |      0.35 |      0.03 | 
##                                         |      0.03 |      0.03 |           | 
##                                         |      0.02 |      0.01 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                         OUTSIDE IRELAND |        40 |        53 |        93 | 
##                                         |     56.89 |     36.11 |           | 
##                                         |      5.02 |      7.91 |           | 
##                                         |      0.43 |      0.57 |      0.00 | 
##                                         |      0.00 |      0.00 |           | 
##                                         |      0.00 |      0.00 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                         SOUTHERN REGION |      1539 |       722 |      2261 | 
##                                         |   1383.21 |    877.79 |           | 
##                                         |     17.55 |     27.65 |           | 
##                                         |      0.68 |      0.32 |      0.04 | 
##                                         |      0.04 |      0.03 |           | 
##                                         |      0.03 |      0.01 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                                 UNKNOWN |       116 |        81 |       197 | 
##                                         |    120.52 |     76.48 |           | 
##                                         |      0.17 |      0.27 |           | 
##                                         |      0.59 |      0.41 |      0.00 | 
##                                         |      0.00 |      0.00 |           | 
##                                         |      0.00 |      0.00 |           | 
## ----------------------------------------|-----------|-----------|-----------|
##                            Column Total |     34655 |     21992 |     56647 | 
##                                         |      0.61 |      0.39 |           | 
## ----------------------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  99     d.f. =  6     p =  4.9e-19 
## 
## 
## 
CrossTable(main_processed$addressDiff, main_processed$New.Attendances, digits=2, fisher=F, chisq=TRUE, expected=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## |              Expected N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  56647 
## 
##  
##                            | main_processed$New.Attendances 
## main_processed$addressDiff |         0 |         1 | Row Total | 
## ---------------------------|-----------|-----------|-----------|
##                          0 |     30550 |     18791 |     49341 | 
##                            |  30185.40 |  19155.60 |           | 
##                            |      4.40 |      6.94 |           | 
##                            |      0.62 |      0.38 |      0.87 | 
##                            |      0.88 |      0.85 |           | 
##                            |      0.54 |      0.33 |           | 
## ---------------------------|-----------|-----------|-----------|
##                          1 |      4105 |      3201 |      7306 | 
##                            |   4469.60 |   2836.40 |           | 
##                            |     29.74 |     46.87 |           | 
##                            |      0.56 |      0.44 |      0.13 | 
##                            |      0.12 |      0.15 |           | 
##                            |      0.07 |      0.06 |           | 
## ---------------------------|-----------|-----------|-----------|
##               Column Total |     34655 |     21992 |     56647 | 
##                            |      0.61 |      0.39 |           | 
## ---------------------------|-----------|-----------|-----------|
## 
##  
## Statistics for All Table Factors
## 
## 
## Pearson's Chi-squared test 
## ------------------------------------------------------------
## Chi^2 =  88     d.f. =  1     p =  6.7e-21 
## 
## Pearson's Chi-squared test with Yates' continuity correction 
## ------------------------------------------------------------
## Chi^2 =  88     d.f. =  1     p =  7.6e-21 
## 
## 

Cancellation

# convert the non-numeric variables to numeric values (the lower the number, the higher frequency)
main_processed$Referral.Source_numeric <- mapvalues(main_processed$Referral.Source_recode, from = c("CLINIC","EMERGENCY DEPT","GP","Elsew outside Mater","WARD","Elsew of Mater","OTHER CONSULTANT"), to = c(1:7))
main_processed$Clinic.Type_numeric <- mapvalues(main_processed$Clinic.Type_recode, from = c("GENERAL","SPINErelated","MUSCULOSKELETALrelated","PODIATRY","UPPER_LIMBrelated","NotLocatedInMater","BACK_PAINrelated","NTPFfund"), to = c(1:8))
main_processed$Consultant_numeric <- mapvalues(main_processed$Consultant_recode, from = c("OHEIRE","MOROP","COLGAN","SYNNOT","XX","MORRI","LYONSF","BRIAIN","MARA","TIMLIN","ONEISH","BUTLER","CASSID","DODDSM","HYNESD","CASHMA","MURMAR","LYNCSA","MCSORK","ORTCON","CARMOO","FRA"), to = c(1:22))
main_processed$Insurance.Scheme_numeric <- mapvalues(main_processed$Insurance.Scheme_recode, from = c("U","D","V","B","I","S","G","O","E","P","J","H","A","C","M"), to = c(1:15))
main_processed$Eligibility_numeric <- mapvalues(main_processed$Eligibility_recode, from = c("NON MEDICAL CARD","MEDICAL CARD","ELIGIBILITY UNKNOWN","EXEMPT","RESEARCH/NATIONAL PROG.","ACUTE UNCLASSIFIED","NON ACUTE UNCLASSIFIED"), to = c(1:7))
main_processed$Booking.Type_numeric <- mapvalues(main_processed$Booking.Type_recode, from = c("RETURN","NEW","WARD"), to = c(1:3))
main_processed$Hospital.Catchment_numeric <- mapvalues(main_processed$Hospital.Catchment_recode, from = c("National","Mater","Connolly","Beaumont","James","Vincents","Tallaght","International"), to = c(1:8))
main_processed$appointmentDay_numeric <- mapvalues(main_processed$appointmentDay, from = c("Wednesday","Monday","Thursday","Tuesday","Friday","Sunday"), to = c(1:6))
main_processed$appointmentMonthYear_numeric <- mapvalues(main_processed$appointmentMonthYear, from = c("Mar 2020","Jan 2021","Mar 2022","Apr 2020","May 2022","Nov 2021","Sep 2022","Sep 2020","Apr 2022","Sep 2021","Aug 2022","Jan 2022","Jun 2022","Jul 2022","Feb 2022","Dec 2021","Jul 2021","Oct 2021","Jan 2023","Nov 2022","Aug 2021","May 2023","May 2021","Oct 2023","Nov 2023","Jun 2021","Feb 2021","Feb 2020","Oct 2022","Mar 2021","Apr 2023","Sep 2023","Aug 2023","Oct 2020","Jul 2023","Apr 2021","Mar 2023","Nov 2020","Dec 2022","Jun 2020","Aug 2020","May 2020","Dec 2023","Dec 2020","Jun 2023","Feb 2023","Jul 2020","Jan 2020"), to = c(1:48))
main_processed$bookedDay_numeric <- mapvalues(main_processed$bookedDay, from = c("Monday","Tuesday","Sunday","Wednesday","Saturday","Friday","Thursday"), to = c(1:7))
main_processed$bookedMonthYear_numeric <- mapvalues(main_processed$bookedMonthYear, from = c("Jan 2020","Feb 2020","Sep 2020","Mar 2020","Jul 2020","Aug 2020","Oct 2020","Nov 2020","Jun 2020","May 2020","Apr 2020","Dec 2020"), to = c(1:12))
main_processed$Gender_numeric <- mapvalues(main_processed$Gender, from = c("Male","Female","Unknown"), to = c(1:3))
main_processed$Area.of.Residence_numeric <- mapvalues(main_processed$Area.of.Residence_recode, from = c("DUBLIN NTH","EASTERN & MIDLAND REGION (excl.Dublin)","DUBLIN STH","SOUTHERN REGION","NORTHERN WESTERN REGION","UNKNOWN","OUTSIDE IRELAND"), to = c(1:7))
main_processed$Rebooked.Indicator_numeric <- mapvalues(main_processed$Rebooked.Indicator, from = c("Yes","No"), to = c(1,0))
main_processed$Cancellation.Group_numeric <- mapvalues(main_processed$Cancellation.Group, from = c("Hospital","Patient","DNA","Validation"), to = c(1:4))
main_processed$Reason.for.Cancellation_numeric <- mapvalues(main_processed$Reason.for.Cancellation_recode, from = c("No show","By Patient","By Cslt/AN/Tech","By Hospital","By Covid","By Patient-health conditions"), to = c(1:6))

write.csv(main_processed[,c("Gender_numeric","Age.at.Attendance","Area.of.Residence_numeric","addressDiff","No.Cancels","Referral.Source_numeric","Clinic.Type_numeric","Consultant_numeric","Insurance.Scheme_numeric","Eligibility_numeric","Hospital.Catchment_numeric","Booking.Type_numeric","Rebooked.Indicator_numeric","Cancellation.Group_numeric","Reason.for.Cancellation_numeric","appointmentDay_numeric","appointmentMonthYear_numeric","bookedDay_numeric","bookedMonthYear_numeric","daysDiff_AppointBooked")],"spineDetails_cancel.csv")

main_processed_cancel <- read.csv("spineDetails_cancel.csv")
main_processed_cancel <- subset(main_processed_cancel, is.na(main_processed_cancel$No.Cancels)==F)

main_processed_cancel <- main_processed_cancel %>% mutate_if(is.character,as.numeric)
## Warning: There were 2 warnings in `mutate()`.
## The first warning was:
## ℹ In argument: `Eligibility_numeric =
##   .Primitive("as.double")(Eligibility_numeric)`.
## Caused by warning:
## ! NAs introduced by coercion
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning.
cor(main_processed_cancel, method = "spearman")
##                                       X Gender_numeric Age.at.Attendance
## X                                1.0000        -0.0838           -0.4424
## Gender_numeric                  -0.0838         1.0000            0.1693
## Age.at.Attendance               -0.4424         0.1693            1.0000
## Area.of.Residence_numeric        0.3719        -0.0238           -0.0672
## addressDiff                      0.0572        -0.0097           -0.0490
## No.Cancels                      -0.0224         0.1189            0.1450
## Referral.Source_numeric          0.0283         0.0305            0.1150
## Clinic.Type_numeric              0.0358         0.0701            0.0353
## Consultant_numeric               0.1317         0.0245           -0.0454
## Insurance.Scheme_numeric        -0.3470         0.0766            0.2576
## Eligibility_numeric                  NA             NA                NA
## Hospital.Catchment_numeric      -0.1315        -0.0163           -0.0535
## Booking.Type_numeric                 NA             NA                NA
## Rebooked.Indicator_numeric      -0.0065         0.0551            0.0474
## Cancellation.Group_numeric       0.0277        -0.0769           -0.1149
## Reason.for.Cancellation_numeric -0.0580         0.1000            0.1583
## appointmentDay_numeric           0.0362        -0.0534           -0.1608
## appointmentMonthYear_numeric     0.0305         0.0025           -0.0093
## bookedDay_numeric               -0.0061        -0.0171           -0.0081
## bookedMonthYear_numeric          0.0445        -0.0156           -0.0292
## daysDiff_AppointBooked          -0.1603        -0.0261           -0.0141
##                                 Area.of.Residence_numeric addressDiff
## X                                                  0.3719     0.05720
## Gender_numeric                                    -0.0238    -0.00968
## Age.at.Attendance                                 -0.0672    -0.04896
## Area.of.Residence_numeric                          1.0000    -0.02017
## addressDiff                                       -0.0202     1.00000
## No.Cancels                                         0.1002    -0.06240
## Referral.Source_numeric                            0.0502     0.07966
## Clinic.Type_numeric                                0.0576     0.09294
## Consultant_numeric                                 0.2068     0.01614
## Insurance.Scheme_numeric                          -0.1020    -0.06630
## Eligibility_numeric                                    NA          NA
## Hospital.Catchment_numeric                        -0.2117     0.00883
## Booking.Type_numeric                                   NA          NA
## Rebooked.Indicator_numeric                         0.0766    -0.06516
## Cancellation.Group_numeric                        -0.0832     0.05127
## Reason.for.Cancellation_numeric                    0.0782    -0.05704
## appointmentDay_numeric                            -0.0667     0.01199
## appointmentMonthYear_numeric                      -0.0014    -0.00053
## bookedDay_numeric                                 -0.0211    -0.00145
## bookedMonthYear_numeric                           -0.0090    -0.01691
## daysDiff_AppointBooked                            -0.0449     0.02599
##                                 No.Cancels Referral.Source_numeric
## X                                  -0.0224                 2.8e-02
## Gender_numeric                      0.1189                 3.0e-02
## Age.at.Attendance                   0.1450                 1.1e-01
## Area.of.Residence_numeric           0.1002                 5.0e-02
## addressDiff                        -0.0624                 8.0e-02
## No.Cancels                          1.0000                 3.2e-02
## Referral.Source_numeric             0.0316                 1.0e+00
## Clinic.Type_numeric                 0.1300                 2.3e-01
## Consultant_numeric                  0.1291                 5.3e-02
## Insurance.Scheme_numeric            0.0285                -1.4e-02
## Eligibility_numeric                     NA                      NA
## Hospital.Catchment_numeric         -0.1218                -6.3e-02
## Booking.Type_numeric                    NA                      NA
## Rebooked.Indicator_numeric          0.5366                -9.3e-02
## Cancellation.Group_numeric         -0.7562                -4.3e-02
## Reason.for.Cancellation_numeric     0.8440                 4.1e-02
## appointmentDay_numeric             -0.0920                -1.3e-01
## appointmentMonthYear_numeric       -0.0025                 7.4e-06
## bookedDay_numeric                   0.0138                -2.9e-02
## bookedMonthYear_numeric            -0.0812                -1.5e-02
## daysDiff_AppointBooked             -0.0177                -3.2e-02
##                                 Clinic.Type_numeric Consultant_numeric
## X                                            0.0358             0.1317
## Gender_numeric                               0.0701             0.0245
## Age.at.Attendance                            0.0353            -0.0454
## Area.of.Residence_numeric                    0.0576             0.2068
## addressDiff                                  0.0929             0.0161
## No.Cancels                                   0.1300             0.1291
## Referral.Source_numeric                      0.2255             0.0531
## Clinic.Type_numeric                          1.0000             0.2137
## Consultant_numeric                           0.2137             1.0000
## Insurance.Scheme_numeric                    -0.0439            -0.0252
## Eligibility_numeric                              NA                 NA
## Hospital.Catchment_numeric                  -0.0958            -0.1450
## Booking.Type_numeric                             NA                 NA
## Rebooked.Indicator_numeric                  -0.0803             0.1232
## Cancellation.Group_numeric                  -0.1088            -0.1455
## Reason.for.Cancellation_numeric              0.1173             0.1261
## appointmentDay_numeric                       0.0851             0.0803
## appointmentMonthYear_numeric                -0.0433            -0.0045
## bookedDay_numeric                           -0.0125             0.0144
## bookedMonthYear_numeric                     -0.0640            -0.0981
## daysDiff_AppointBooked                      -0.0068            -0.0093
##                                 Insurance.Scheme_numeric Eligibility_numeric
## X                                                -0.3470                  NA
## Gender_numeric                                    0.0766                  NA
## Age.at.Attendance                                 0.2576                  NA
## Area.of.Residence_numeric                        -0.1020                  NA
## addressDiff                                      -0.0663                  NA
## No.Cancels                                        0.0285                  NA
## Referral.Source_numeric                          -0.0138                  NA
## Clinic.Type_numeric                              -0.0439                  NA
## Consultant_numeric                               -0.0252                  NA
## Insurance.Scheme_numeric                          1.0000                  NA
## Eligibility_numeric                                   NA                   1
## Hospital.Catchment_numeric                       -0.0086                  NA
## Booking.Type_numeric                                  NA                  NA
## Rebooked.Indicator_numeric                        0.0353                  NA
## Cancellation.Group_numeric                       -0.0161                  NA
## Reason.for.Cancellation_numeric                   0.0428                  NA
## appointmentDay_numeric                           -0.0166                  NA
## appointmentMonthYear_numeric                      0.0021                  NA
## bookedDay_numeric                                -0.0045                  NA
## bookedMonthYear_numeric                          -0.0116                  NA
## daysDiff_AppointBooked                            0.0523                  NA
##                                 Hospital.Catchment_numeric Booking.Type_numeric
## X                                                  -0.1315                   NA
## Gender_numeric                                     -0.0163                   NA
## Age.at.Attendance                                  -0.0535                   NA
## Area.of.Residence_numeric                          -0.2117                   NA
## addressDiff                                         0.0088                   NA
## No.Cancels                                         -0.1218                   NA
## Referral.Source_numeric                            -0.0632                   NA
## Clinic.Type_numeric                                -0.0958                   NA
## Consultant_numeric                                 -0.1450                   NA
## Insurance.Scheme_numeric                           -0.0086                   NA
## Eligibility_numeric                                     NA                   NA
## Hospital.Catchment_numeric                          1.0000                   NA
## Booking.Type_numeric                                    NA                    1
## Rebooked.Indicator_numeric                         -0.0763                   NA
## Cancellation.Group_numeric                          0.0944                   NA
## Reason.for.Cancellation_numeric                    -0.0987                   NA
## appointmentDay_numeric                              0.0848                   NA
## appointmentMonthYear_numeric                        0.0077                   NA
## bookedDay_numeric                                   0.0079                   NA
## bookedMonthYear_numeric                             0.0391                   NA
## daysDiff_AppointBooked                              0.0207                   NA
##                                 Rebooked.Indicator_numeric
## X                                                  -0.0065
## Gender_numeric                                      0.0551
## Age.at.Attendance                                   0.0474
## Area.of.Residence_numeric                           0.0766
## addressDiff                                        -0.0652
## No.Cancels                                          0.5366
## Referral.Source_numeric                            -0.0930
## Clinic.Type_numeric                                -0.0803
## Consultant_numeric                                  0.1232
## Insurance.Scheme_numeric                            0.0353
## Eligibility_numeric                                     NA
## Hospital.Catchment_numeric                         -0.0763
## Booking.Type_numeric                                    NA
## Rebooked.Indicator_numeric                          1.0000
## Cancellation.Group_numeric                         -0.4347
## Reason.for.Cancellation_numeric                     0.4609
## appointmentDay_numeric                             -0.0037
## appointmentMonthYear_numeric                        0.0222
## bookedDay_numeric                                   0.0042
## bookedMonthYear_numeric                            -0.0372
## daysDiff_AppointBooked                             -0.0790
##                                 Cancellation.Group_numeric
## X                                                   0.0277
## Gender_numeric                                     -0.0769
## Age.at.Attendance                                  -0.1149
## Area.of.Residence_numeric                          -0.0832
## addressDiff                                         0.0513
## No.Cancels                                         -0.7562
## Referral.Source_numeric                            -0.0431
## Clinic.Type_numeric                                -0.1088
## Consultant_numeric                                 -0.1455
## Insurance.Scheme_numeric                           -0.0161
## Eligibility_numeric                                     NA
## Hospital.Catchment_numeric                          0.0944
## Booking.Type_numeric                                    NA
## Rebooked.Indicator_numeric                         -0.4347
## Cancellation.Group_numeric                          1.0000
## Reason.for.Cancellation_numeric                    -0.7861
## appointmentDay_numeric                              0.1197
## appointmentMonthYear_numeric                        0.0284
## bookedDay_numeric                                  -0.0073
## bookedMonthYear_numeric                             0.0745
## daysDiff_AppointBooked                              0.0149
##                                 Reason.for.Cancellation_numeric
## X                                                        -0.058
## Gender_numeric                                            0.100
## Age.at.Attendance                                         0.158
## Area.of.Residence_numeric                                 0.078
## addressDiff                                              -0.057
## No.Cancels                                                0.844
## Referral.Source_numeric                                   0.041
## Clinic.Type_numeric                                       0.117
## Consultant_numeric                                        0.126
## Insurance.Scheme_numeric                                  0.043
## Eligibility_numeric                                          NA
## Hospital.Catchment_numeric                               -0.099
## Booking.Type_numeric                                         NA
## Rebooked.Indicator_numeric                                0.461
## Cancellation.Group_numeric                               -0.786
## Reason.for.Cancellation_numeric                           1.000
## appointmentDay_numeric                                   -0.083
## appointmentMonthYear_numeric                             -0.036
## bookedDay_numeric                                         0.020
## bookedMonthYear_numeric                                  -0.087
## daysDiff_AppointBooked                                    0.049
##                                 appointmentDay_numeric
## X                                               0.0362
## Gender_numeric                                 -0.0534
## Age.at.Attendance                              -0.1608
## Area.of.Residence_numeric                      -0.0667
## addressDiff                                     0.0120
## No.Cancels                                     -0.0920
## Referral.Source_numeric                        -0.1269
## Clinic.Type_numeric                             0.0851
## Consultant_numeric                              0.0803
## Insurance.Scheme_numeric                       -0.0166
## Eligibility_numeric                                 NA
## Hospital.Catchment_numeric                      0.0848
## Booking.Type_numeric                                NA
## Rebooked.Indicator_numeric                     -0.0037
## Cancellation.Group_numeric                      0.1197
## Reason.for.Cancellation_numeric                -0.0827
## appointmentDay_numeric                          1.0000
## appointmentMonthYear_numeric                    0.0115
## bookedDay_numeric                               0.0458
## bookedMonthYear_numeric                         0.0226
## daysDiff_AppointBooked                          0.0359
##                                 appointmentMonthYear_numeric bookedDay_numeric
## X                                                    3.0e-02           -0.0061
## Gender_numeric                                       2.5e-03           -0.0171
## Age.at.Attendance                                   -9.3e-03           -0.0081
## Area.of.Residence_numeric                           -1.4e-03           -0.0211
## addressDiff                                         -5.3e-04           -0.0015
## No.Cancels                                          -2.5e-03            0.0138
## Referral.Source_numeric                              7.4e-06           -0.0289
## Clinic.Type_numeric                                 -4.3e-02           -0.0125
## Consultant_numeric                                  -4.5e-03            0.0144
## Insurance.Scheme_numeric                             2.1e-03           -0.0045
## Eligibility_numeric                                       NA                NA
## Hospital.Catchment_numeric                           7.7e-03            0.0079
## Booking.Type_numeric                                      NA                NA
## Rebooked.Indicator_numeric                           2.2e-02            0.0042
## Cancellation.Group_numeric                           2.8e-02           -0.0073
## Reason.for.Cancellation_numeric                     -3.6e-02            0.0199
## appointmentDay_numeric                               1.1e-02            0.0458
## appointmentMonthYear_numeric                         1.0e+00            0.0149
## bookedDay_numeric                                    1.5e-02            1.0000
## bookedMonthYear_numeric                              8.5e-02           -0.0759
## daysDiff_AppointBooked                              -1.3e-01            0.0524
##                                 bookedMonthYear_numeric daysDiff_AppointBooked
## X                                                 0.044                -0.1603
## Gender_numeric                                   -0.016                -0.0261
## Age.at.Attendance                                -0.029                -0.0141
## Area.of.Residence_numeric                        -0.009                -0.0449
## addressDiff                                      -0.017                 0.0260
## No.Cancels                                       -0.081                -0.0177
## Referral.Source_numeric                          -0.015                -0.0320
## Clinic.Type_numeric                              -0.064                -0.0068
## Consultant_numeric                               -0.098                -0.0093
## Insurance.Scheme_numeric                         -0.012                 0.0523
## Eligibility_numeric                                  NA                     NA
## Hospital.Catchment_numeric                        0.039                 0.0207
## Booking.Type_numeric                                 NA                     NA
## Rebooked.Indicator_numeric                       -0.037                -0.0790
## Cancellation.Group_numeric                        0.075                 0.0149
## Reason.for.Cancellation_numeric                  -0.087                 0.0492
## appointmentDay_numeric                            0.023                 0.0359
## appointmentMonthYear_numeric                      0.085                -0.1298
## bookedDay_numeric                                -0.076                 0.0524
## bookedMonthYear_numeric                           1.000                -0.0675
## daysDiff_AppointBooked                           -0.067                 1.0000
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.3.2
## corrplot 0.92 loaded
corrplot(cor(main_processed_cancel))

gg_cancellationGroup <- ggplot(main_processed,aes(x=Cancellation.Group)) +
  labs(x = "Cancellation Group") +
  scale_x_discrete(limits=c("Hospital","Patient","DNA","Validation")) +
  geom_bar(colour="blue", fill="lightblue")
gg_cancellationGroup
## Warning: Removed 56647 rows containing non-finite values (`stat_count()`).

gg_cancelReason <- ggplot(main_processed,aes(x=Reason.for.Cancellation_recode)) +
  labs(x = "Reason for Cancellation") +
  scale_x_discrete(limits=c("No show","By Patient","By Cslt/AN/Tech","By Hospital","By Covid","By Patient-health conditions"), guide = guide_axis(n.dodge = 2)) +
  geom_bar(colour="blue", fill="lightblue")
gg_cancelReason
## Warning: Removed 56647 rows containing non-finite values (`stat_count()`).

Logistic Regression model

Build baseline model of cancellations with predictors

  • strong correlation between (Referral source and Booking type), (Clinic type and Booking type), (Consultant and Appointment day), (Consultant and Clinic code)
  • moderate correlation between (Appointment day and Clinic code), (Clinic type and Clinic code), (Clinic type and Referral source), (Clinic type and No.Cancels), (Clinic type and Age)
  • weak correlation between (Booking type and Age), (Booking type and Clinic code)
  1. Model 1: No.Cancels ~ Clinic.Type_numeric + Referral.Source_numeric + Consultant_numeric + Insurance.Scheme_numeric + Eligibility_numeric + Booking.Type_numeric + Hospital.Catchment_numeric + Rebooked.Indicator_numeric + Reason.for.Cancellation_numeric
  • AIC: 14333
  • AUC: 0.91
  • nagelkerke R squared: 0.6
  • Confusion matrix: accuracy (0.84), precision (0.32), recall (0.1), prevalence (0.23), detection rate (0.18)
  1. Model 2: No.Cancels ~ appointmentDay_numeric + appointmentMonthYear_numeric + bookedDay_numeric + bookedMonthYear_numeric + daysDiff_AppointBooked
  • AIC: 26316
  • AUC: 0.61
  • nagelkerke R squared: 0.04
  • Confusion matrix: accuracy (0.5), precision (0.77), recall (1), prevalence (0.23), detection rate (0)
  1. Model 3: No.Cancels ~ Gender_numeric + Age.at.Attendance + Area.of.Residence_numeric + addressDiff
  • AIC: 26518
  • AUC: 0.59
  • nagelkerke R squared: 0.028
  • Confusion matrix: accuracy (0.5), precision (0.997), recall (0.77), prevalence (0.23), detection rate (0.002)
  1. Model: No.Cancels ~ Gender_numeric + Age.at.Attendance + Area.of.Residence_numeric + addressDiff + Referral.Source_numeric + Clinic.Type_numeric + Consultant_numeric + Insurance.Scheme_numeric + Eligibility_numeric + Hospital.Catchment_numeric + Booking.Type_numeric + appointmentDay_numeric + appointmentMonthYear_numeric + bookedDay_numeric + bookedMonthYear_numeric
  • AIC: 14031
  • AUC: 0.91
  • nagelkerke R squared: 0.61
  • Confusion matrix: accuracy (0.81), precision (0.92), recall (0.88), prevalence (0.23), detection rate (0.17)

  • AIC the smallest AIC provides the best model
  • AUC (area under the ROC curve) the closer to 1 the more correct predictions
  • predict: predict the values based on the previous data behaviors and thus by fitting that data to the model
  • plogis: Logistic Cumulative Distribution Function
  • Cox and Snell R square: Analysis_Survival_Cox Regression. The coefficients in a Cox regression relate to hazard; a positive coefficient indicates a worse prognosis and a negative coefficient indicates a protective effect of the variable with which it is associated
  • nagelkerke: a measure of goodness of fit in logistic regression analysis, a modification of the Cox and Snell R Square. Ranges [0,1], a common rule of thumb (<= 0.2: weak relationship, 0.2-0.4: moderate, >= 0.4: strong relationship).
  • confusionMatrix: matrix between actual and predicted values
  • vif = 1/(1-Ri^2) = 1/tolerance. Vif >4 or tolearance <0.25: multicollinearity might exist; vif >10 or tolerance <0.1: signigicant multicollinearity that needs to be corrected. Vif interpret if model has problems estimating the coefficient

variables need to be recoded as numeric to run any regression

Build baseline model of new attendances with predictors

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.