CompareSuccessRatesBySplit.RdCompareSuccessRatesBySplit compares one factor variable by a split variable with prop.test and glm. For two groups confidence intervals for difference in success rate, odds ratio, and risk ratio are provided.
CompareSuccessRatesBySplit(DFR, FAC, SPLIT, SUCCESS = 2, DIGITS = 3, CONF.LEVEL = 0.95)
| DFR | is a dataframe |
|---|---|
| FAC | name of factor in DFR. Will be converted to a factor if not a factor. |
| SPLIT | name of split factor (grouping variable) in DFR |
| SUCCESS | =2 factor level that defines success. If numeric, the respective level of FAC is assumed. |
| DIGITS | =3 Number of digits for estimates |
| CONF.LEVEL | =0.95 Confidence Level for confidence interval |
a data.frame: two groups: proabability difference, odds ration and relative risk with CI; more than two groups: chisqr.test and likelihood ratio test of glm
CompareSuccessRatesBySplit
if (FALSE) { require(MASS) DAT<-survey colnames(DAT)<-toupper(colnames(DAT)) CrossTabs(DAT$SMOKE,DAT$SEX,TYPE="COL") DAT$Smoker<-DAT$SMOKE levels(DAT$Smoker)<-c("Smoker","NonSmoker","Smoker","Smoker") CrossTabs(DAT$Smoker,DAT$SEX,TYPE="COL") CompareSuccessRatesBySplit(DAT,FAC="SMOKE",SUCCESS="Never",SPLIT="SEX") CrossTabs(DAT$SMOKE,DAT$FOLD) CompareSuccessRatesBySplit(DAT,FAC="SMOKE",SUCCESS="Never",SPLIT="FOLD") }