Bonferroni_m: Detecting the pairs using Bonferroni correction

Description Usage Arguments Value Examples

Description

This method is much faster than the shuffling method, but less precise.

Usage

1
2
3
4
5
Bonferroni_m(unadjusted_pairs, 
             ids=ids, 
             prob = 1/75, 
             alpha = 0.01, 
             only_significant = TRUE)

Arguments

unadjusted_pairs

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

ids

a "data.table" object with 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. Default 1/75.

alpha

type I error

only_significant

returns only significant pairs above the threshold (default) or all the pairs

Value

a data frame with

"allPairs"

pair identifier

"Freq"

the unadjusted number of shared visits

"id_1"

identifier of the first pair member

"id_2"

identifier of the second pair member

"N_visits.x"

total number of visits of the first pair member

"N_visits.y"

total number of visits of the second pair member

"Prob_for_Bonferr"

probability of sharing the given number of shared visits

"BP"

row number

"ltp"

the minus log10-transformed probablity of sharing the given number shared visits

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# 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)
# prepare ids
ids <- data.table(ids = as.character(names(table(db_dates$subject))), 
                  N_visits = as.character(as.numeric(table(db_dates$subject)))) 
setkey(ids, "ids")

# run
Bonferroni_m_output <- Bonferroni_m(unadjusted_observed_pairs,
                                    ids = ids, prob = 1/75, alpha = 0.01)
# number of significant pairs
nrow(Bonferroni_m_output)

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