Summarize and provide p-value after association test of 2 or more variables. Percentages are reported for discrete variables. Users can choose the type of test they want. For continuous variable median and range are reported if the test specified is non parametric, mean and standard deviation are reported for a parametric test. For discrete categories we perform Fisher's Exact Test, for continuous following options are available - parametric - Students' T-Test or one way ANNOVA, for non-parametric Wilcoxon Rank sum test or Kruskal Wallis test.

get.summary2(fac,var,type,test.type="np",skip.test=FALSE, var.n=NULL)

Arguments

fac

vector, a discrete vector of interest for which association is to be tested against other categorical or continuous variables

var

vector, can be discrete or continuous

type

type=1 - meaning both fac and var are categorical, and Fisher's Exact test will be performed

type=2 - var is continuous and you can choose from available parametric (Students' T-Test or one way ANNOVA) and non parametric tests. (Wilcoxon Rank sum test or Kruskal Wallis test.)

test.type

possible values - "np" or "p", Default is "np" (non parametric). Use "p" for parametric tests

skip.test

logical, Default is "TRUE". A association test is always performed. However, if there are too many categories in fac, it might slow down computation required for Fishers Exact test, one can decide to skip test by skip.test=FALSE to prevent limbo.

var.n

character, If a variable name is provided, it will add this to output.

Details

Summary statistics are rounded to nearest 2 decimal points. Note that length of fac and var should be the same. For Wilcoxon Rank sum test ties are handled through wilcox.test function in coin package. workspace parameter in Fisher's Exact test is set to workspace=2e8. All p-values < 0.0001 are replaced with a character string P<0.0001 or otherwise rounded to three decimal points.

Value

fmat

returns a character matrix summarizing fac and var. See examples

See also

get.summary

Examples

#two categorical variables set.seed(100) fac<-sample(1:2, 50, replace=TRUE) var<-sample(1:3, 50, replace=TRUE) get.summary2(fac,var, type=1,var.n="Example, Type=1" )
#> Performing Fisher's Exact test
#> 1(n=21;42%) 2(n=29;58%) RowTotal pval #> Example, Type=1 "" "" "" "0.0055" #> 1 "7(33%)" "10(34%)" "17(34%)" "" #> 2 "10(48%)" "3(10%)" "13(26%)" "" #> 3 "4(19%)" "16(55%)" "20(40%)" ""
#continuous with two categories of fac var<-rnorm(50) get.summary2(fac, var, type=2, test.type="p", var.n="2-Way, test.type=p")
#> Performing T-Test
#> 1 2 RowTotal pval #> 2-Way, test.type=p "-0.16(1)" "0.24(1.04)" "" "0.176" #> NA "0" "0" "" ""
get.summary2(fac, var, type=2, test.type="np", var.n="2-Way, test.type=np")
#> Performing Wilcoxon Rank Sum test
#> 1 2 RowTotal pval #> 2-Way, test.type=np "-0.21[-1.78-1.8]" "0.55[-2.14-1.72]" "" "0.123" #> NA "0" "0" "" ""
#continuous with three categories of fac fac<-sample(1:3, 50, replace=TRUE) get.summary2(fac, var, type=2, test.type="p",var.n="Example, test.type=p")
#> Performing one way ANOVA
#> 1 2 3 RowTotal pval #> Example, test.type=p "-0.06(0.87)" "0.17(0.99)" "0.09(1.25)" "" "0.82" #> NA "0" "0" "0" "" ""
get.summary2(fac, var, type=2, test.type="np",var.n="Example, test.type=np")
#> Performing Kruskal-Wallis test
#> 1 2 3 #> Example, test.type=np "-0.16[-1.78-1.16]" "0.21[-1.71-1.72]" "0.5[-2.14-1.8]" #> NA "0" "0" "0" #> RowTotal pval #> Example, test.type=np "" "0.711" #> NA "" ""