1
0
Fork 0
mirror of https://github.com/prise6/aVirtualTwins.git synced 2024-05-01 19:52:43 +02:00

Fix issue trt/outcome

This commit is contained in:
prise6 2015-06-14 17:36:35 +02:00
parent 39b1757fb5
commit 131599a3d5

View file

@ -47,12 +47,14 @@ formatRCTDataset <- function(dataset, outcome.field, treatment.field, interactio
outcome <- d[, outcome.field.which]
if(!is.factor(outcome)) outcome <- as.factor(outcome)
if(!length(levels(outcome)) == 2L) stop(sprintf("outcome %s must be binary", outcome.field))
cat(sprintf("\"%s\" will be the favorable outcome \n", levels(outcome)[2]))
cat(sprintf("\"%s\" will be the favorable outcome \n", levels(outcome)[2]))
d[, outcome.field.which] <- outcome
treatment <- d[, treatment.field.which]
if(!is.numeric(treatment) & !is.integer(treatment)) treatment <- as.numeric(treatment)
if(!( length(unique(treatment)) == 2L & all(c(0,1) %in% unique(treatment)) ))
stop(sprintf("%s, response must be numeric:\n 0 = no treatment \n 1 = treatment \n", treatment.field))
d[, treatment.field.wich] <- treatment
predictors <- colnames(dataset)[-c(outcome.field.which, treatment.field.which)]