adjust_visits: Adjust the number of shared visits

Description Usage Arguments Value Examples

Description

The function adjusts the total number of shared visits per pair.

Usage

1
adjust_visits(unadjusted_pairs, ids, prob = 1/75)

Arguments

unadjusted_pairs

a "table" object containing the pairs and the number of shared visits

ids

a "data.table" object containing columns "ids" and "N_visits". The "ids" column represents patient identifiers and is the reference (see setkey from package data.table for more details). The "N_visits" contains the number of visits for each patient.

prob

probability of sharing a single visit, depending on the frequency of visits. Default 1/75~visit every three months.

Value

a data frame with the columns:

"allPairs"

pair identifiers

"Freq"

unadjusted number of shared visits

"id_1"

first member of the pair's id

"id_2"

second member of the pair's id

"N_visits.x"

first member of the pair's number of visits

"N_visits.y"

second member of the pair's number of visits

"Corrected"

the adjusted number of shared visits per pair

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# load data
data("simulated_data")
db_dates <- prepare_db(your_database = simulated_data,
                       ids_column = "subject",
                       dates_column = "sim_dates")

# first get unadjusted pairs
unadjusted_observed_pairs <- get_observed_pairs(db_dates)
ids <- data.table(ids = as.character(names(table(db_dates$subject))), 
                  N_visits = as.character(as.numeric(table(db_dates$subject)))) 
setkey(ids, "ids") 

# now adjust the pairs
adjusted_observed <- adjust_visits(unadjusted_pairs = unadjusted_observed_pairs,
                                   ids = ids, 
                                   prob = 1/75)
head(adjusted_observed)

alexmarzel/svisits documentation built on May 12, 2019, 1:36 a.m.