Class providing the HospiNet object with its methods
Class providing the HospiNet object with its methods
R6Class
object.
Object of R6Class
with methods for accessing facility networks.
new(edgelist,
window_threshold,
nmoves_threshold,
noloops)
This method is used to create an object of this class with edgelist
as the necessary information to create the network.
The other arguments window_threshold
, nmoves_threshold
, and noloops
are specific to the edgelist
and need to be provided.
For ease of use, it is preferable to use the function hospinet_from_subject_database
print()
This method prints basic information about the object.
plot(type = "matrix")
This method plots the network matrix by default.
The argument type
can take the following values:
plot the network matrix,
identify and plot cluster(s) in the matrix using the infomap algorithm (from igraph),
plot the histogram of the number of neighbors by facility,
plot the network by clusters using a "spaghetti-like" layout. Only works when there are at least 2 clusters.
edgelist
(data.table) the list of edges (origin, target) and their associated number of movements (N) (read-only)
edgelist_long
(data.table) edgelist with additional information (read-only)
matrix
(matrix) the transfer matrix (active binding, read-only)
igraph
(igraph) the igraph object corresponding to the network (active binding, read-only)
n_facilities
the number of facilities in the network (read-only)
n_movements
the total number of subject movements in the network (read-only)
window_threshold
the window threshold used to compute the network (read-only)
nmoves_threshold
the nmoves threshold used to compute the network (read-only)
noloops
TRUE if loops have been removed (read-only)
hist_degrees
histogram data of the number of connections per facility
LOSPerHosp
the mean length of stay for each facility (read-only)
admissionsPerHosp
the number of admissions to each facility (read-only)
subjectsPerHosp
the number of unique subjects admitted to each facility (read-only)
degrees
number of connections for each facilities (total, in, and out)(read-only)
closenesss
the closeness centrality of each facility (read-only)
betweennesss
the betweenness centrality of each facility (read-only)
cluster_infomap
the assigned community for each facility, based on the infomap algorithm (read-only)
cluster_fast_greedy
the assigned community for each facility, based on the greedy modularity optimization algorithm (read-only)
hubs_global
Kleinberg's hub centrality scores, based on the entire network (read-only)
hubs_infomap
same as hubs_global, but computed per community based on the infomap algorithm (read-only)
hubs_fast_greedy
same as hubs_global, but computed per community based on the infomap algorithm (read-only)
metricsTable
(data.table) all of the above metrics for each facility (read-only)
new()
Create a new HospiNet object.
HospiNet$new(
edgelist,
edgelist_long,
window_threshold,
nmoves_threshold,
noloops,
prob_params,
fsummary = NULL,
create_MetricsTable = FALSE
)
edgelist
Short format edgelist
edgelist_long
Long format edgelist
window_threshold
The window threshold used to compute the network
nmoves_threshold
The nmoves threshold used to compute the network
noloops
TRUE if loops have been removed
prob_params
Currently unused
fsummary
A pre-built data.table with the LOSPerHosp, subjectsPerHosp and admissionsPerHosp that don't need to be recomputed.
create_MetricsTable
all of the metrics for each facility
print()
Prints a basic description of the number of facilities and movements of a HospiNet object.
plot()
Plots various representations of the HospiNet network
mydbsmall <- create_fake_subjectDB(n_subjects = 100, n_facilities = 10)
hn <- hospinet_from_subject_database(
base = checkBase(mydbsmall),
window_threshold = 10,
count_option = "successive",
condition = "dates"
)
#> Checking for missing values...
#> Checking for duplicated records...
#> Removed 0 duplicates
#> Done.
hn
#> 5 facilities and 3 movements.
#> Movement window is 10 days.
#> Constructing full matrix
#> f02 f04 f06 f07 f09
#> f02 0 0 0 1 0
#> f04 0 0 0 0 0
#> f06 0 0 0 0 0
#> f07 0 1 0 0 0
#> f09 0 0 1 0 0
plot(hn)
plot(hn, type = "clustered_matrix")