generated from nhsengland/analyticsunit-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuture_demand_modelling.R
81 lines (63 loc) · 2.75 KB
/
future_demand_modelling.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
library(dplyr)
library(readxl)
# Import data
# endoscopy_stocktake <- read_excel("C:/Users/martin.bloyce/OneDrive - NHS England/Restricted Library/SE/Analysis/Diagnostics/Endoscopy Stocktake/Endoscopy Stocktake Database with pivot table.xlsx",
# sheet = "Backing Data", skip = 2)
endoscopy_stocktake <- read_excel("C:/Users/GeorginaCable/OneDrive - NHS/Analysis/Diagnostics/Endoscopy Stocktake/240916 Endoscopy Stocktake Analysis.xlsx",
sheet = "Backing Data", skip = 2)
# Rename columns for ease
colnames(endoscopy_stocktake) <- c('ICB', 'Trust', 'Directorate', 'UnitName', 'QuestionKey','Question', 'Value', 'ValueType', 'SetResponseAnswer', 'FreeText', 'blank1', 'blank2', 'blank3')
# Create unit level data
lists_per_week <- subset(endoscopy_stocktake,
endoscopy_stocktake$QuestionKey == '27',
select = c('UnitName', 'Value')
)
colnames(lists_per_week) <- c("Loc", "lists_per_week") # Rename columns
# Create region level data
lists_per_week_region <- endoscopy_stocktake %>%
subset(.,
QuestionKey == '27',
select = c('ICB','Trust', 'UnitName', 'Value'))
lists_per_week_region <- lists_per_week_region %>%
mutate(Value = as.numeric(Value))
lists_per_week_region <- lists_per_week_region %>%
group_by(ICB) %>%
summarise(Value = sum(Value))
# Create ICB level data
lists_per_week_ICB <- endoscopy_stocktake %>%
subset(.,
QuestionKey == '27',
select = c('ICB', 'Value'))
lists_per_week_ICB <- lists_per_week_ICB %>%
mutate(Value = as.numeric(Value))
lists_per_week_ICB <- lists_per_week_ICB %>%
group_by(ICB) %>%
summarise(Value = sum(Value))
colnames(lists_per_week_ICB) <- c("Loc", "lists_per_week") # Rename columns
# Bring tables together
lists_per_week <- rbind(lists_per_week_ICB, lists_per_week)
# Create 120% activity calculation
lists_per_week <- lists_per_week %>%
mutate(lists_per_week = as.numeric(lists_per_week),
ModelA = round(lists_per_week * 1.2))
# Create 5% increase models
#2024-25
lists_per_week <- lists_per_week %>%
mutate(
ModelB = round(lists_per_week * 1.05)
)
#2025-26
lists_per_week <- lists_per_week %>%
mutate(
ModelC = round(ModelB * 1.05)
)
#2026-27
lists_per_week <- lists_per_week %>%
mutate(
ModelD = round(ModelC * 1.05)
)
# Gap baseline to 2026-27
lists_per_week <- lists_per_week %>%
mutate(
Gap = round(ModelD - lists_per_week)
)