susanathey / causalTree

Working repository for Causal Tree and extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in causalTree : The treatment status should be 1 or 0 only

piyushakhot opened this issue · comments

library(readstata13)
library(causalTree)

mydata<-read.dta13("C:/Users/piyusha/Downloads/xyz.dta")

private_school1<-ifelse(mydata$private_school== "public",0,1)
newdata<-cbind(mydata,private_school1)

train.data<-newdata[1:127,]
test.data<-newdata[128:142,]

linear.causTree<-causalTree(exam_perc_pass0~preprim_tuitionfee+prim_tuitionfee+lowsec_tuitionfee+upsec_tuitionfee+registration_fee+feeding_fee+transport_fee+exam_fee+textbook_fee+uniform_fee+extraclass_fee+extracurricular_fee+other_fee+private_school,data=train.data, treatment = train.data$private_school1,method="anova",split.Rule = "CT", cv.option = "CT", split.Honest = T, cv.Honest = T, split.Bucket = F,
xval = 5, cp = 0, minsize = 20, propensity = 0.5)

**Error in causalTree(exam_perc_pass0 ~ preprim_tuitionfee + prim_tuitionfee + :
** The treatment status should be 1 or 0 only: 1 represent treated and 0 represent controlled.

I have tried adding a new column with 0 or 1 values to avoid this error but nothing is working. Data has a lot of missing values. Could it be the same issue as #7 ?

#12 should fix this.