Epi.jl Documentation

# Epi.chisquaretestMethod.

chisquaretest(A, adjusted=false)

calculate chi-square statistic and the p-value of a two-way Row x Colums. A is a matrix return from crossTable (which conveniently includes row total and column total).

The following statistics are reported

Examples

julia> using Epi

julia> gender = ["Female", "Male"][rand(1:2, 100)];

julia> age = ["0-5", "6-10", "11-15"][rand(1:3, 100)];

julia> tm_ = crossTable(age, gender);

julia> chisquaretest(tm_)
Chi-square: 0.247 with 2 degrees of freedom
    p-value: 0.8837
Likelihood-ratio Chi-square: 0.2466 with 2 degrees of freedom
    p-value: 0.8839
===================================
Expectation values table
Frequency (expected value)

-----------------------------------
3×2 Named Array{Text{String},2}
A  B        Male      Female
──────┼───────────────────────
11-15   16 (14.7)   14 (15.3)
0-5    15 (17.14)  20 (17.85)
6-10   18 (17.14)  17 (17.85)

source

# Epi.crossTableMethod.

crossTable(x, y; row=true)

Make cross-tabulation table between arrays x and y.

Optional row report row percentage where row=false report column percentage, digits specifies the digits use in round function.

Return table of complete cases only, i.e., missing values are removed. This table can be used as the input to chisquaretest, oddsratio, and riskratio functions.

Examples

julia> using Epi

julia> gender = ["Female", "Male"][rand(1:2, 100)];

julia> age = ["0-5", "6-10", "11-15"][rand(1:3, 100)];

julia> tm_ = crossTable(age, gender);
Frequency (row percentage)
4×3 Named Array{Text{String},2}
A  B       Male     Female      Total
──────┼────────────────────────────────
11-15  16 (0.53)  14 (0.47)   30 (1.0)
0-5    15 (0.43)  20 (0.57)   35 (1.0)
6-10   18 (0.51)  17 (0.49)   35 (1.0)
Total  49 (0.49)  51 (0.51)  100 (1.0)

julia> tm_ = crossTable(age, gender, row=false);
Frequency (column percentage)
4×3 Named Array{Text{String},2}
A  B       Male     Female      Total
──────┼────────────────────────────────
11-15  16 (0.33)  14 (0.27)   30 (0.3)
0-5    15 (0.31)  20 (0.39)  35 (0.35)
6-10   18 (0.37)  17 (0.33)  35 (0.35)
Total   49 (1.0)   51 (1.0)  100 (1.0)

source

# Epi.oddsratioMethod.

oddsratio(a, b, c, d; alpha=.05, exact=false)   
oddsratio(A, B; alpha=.05, exact=false) # todo

Calculate odds ratio of 2x2 table (Case-Control Studies). If A, B are vectors, a two-way table is generated using crossTable and OR is calculated.

Exact method is not implemented.

| | case | non-cases | | |:––––––|:––-|:–––––|:––––| | exposed | a | b | a+b | | non-exposed | c | d | c+d | | | a+c | b+d | a+b+c+d |

Example outputs

B = 2×2 Named Array{Int64,2}
Exposed  Case   +   -
───────────────┼───────
+               25  12
-                9  69
1×3 Named Array{Float64,2}
              OR    lower    upper
─────────┼──────────────────────────
OR 95%CI  15.9722  6.00717  42.4679

source

# Epi.removeMissingMethod.

removeMissing(A; cols=missing)

Removing missing values in an array A. By default remove all rows with missing values in any of the columns. Otherwise removing only missing data only in those columns specified by cols. A can be R x 1 as well.

Return the modified A.

source

# Epi.removeNaNMethod.

removeNaN(A; cols=missing)

Removing non number values (NaN) in an array A. By default remove all rows with missing values in any of the columns. Otherwise removing only missing data only in those columns specified by cols. A can be R x 1 as well

Return the modified A.

source

# Epi.riskratioMethod.

riskratio(a, b, c, d; alpha=.05)    
riskratio(A, B; alpha=.05, exact=false) # todo

Calculate risk ratio (RR) of 2x2 table; this can also be used for calculating prevalence ratio (PR).

If A, B are vectors, a two-way table is generated using crossTable and RR is calculated.

| | case | non-cases | | |:––––––|:––-|:–––––|:––––| | exposed | a | b | a+b | | non-exposed | c | d | c+d | | | a+c | b+d | a+b+c+d |

Example outputs

julia> riskratio(122,355,22,965, alpha=0.01)
B = 2×2 Named Array{Int64,2}
Exposed  Case    +    -
───────────────┼─────────
+               122  355
-                22  965
1×3 Named Array{Float64,2}
                RR    lower    upper
───────────┼──────────────────────────
RR 99.0%CI  11.4746  6.43047  20.4752

source

# Epi.unlistMethod.

unlist(A; unify=false)

R's style 'unlist''. A can be a 1-dimensional array of arrays (the motivation of this function), or a 2-dimensional array (not tested exhaustively).

unify=true wraps the result in the unique() function before return.

source

# Epi.crossCountMethod.

Function to count for a cross-table for Epi package.

Internal

source