I am using a r package named 'causal weight', more specifically 'duntreatDML'
The example is available here( https://github.com/cran/causalweight/blob/master/R/JC.R)
I am using a different dataset but using the same package:
a demo version of my data:
id <- c('1', '2', '3')
ac <- c(23, 41, 32)
ff <- c(1,0,1)
ac1 <- c(34, 21, 11)
air <- c(10,20,20)
d1 <- c(1,0,1)
d2 <- c(1,1,0)
y2 <- c(100,200,300)
mydata <- data.frame(id, ac,ff,ac1,air,d1,d2,y2)
x0 = mydata[,3:4];x1 = mydata[,5:6]
d1 = mydata[,7];d2 = mydata[,8]
y2=mydata[,9]
output=dyntreatDML(y2=y2,d1=d1,d2=d2,x0=x0,x1=x1,
d1treat=1,d2treat=1,d1control=0,d2control=0)
I am getting the following error:
Error in split.default(sample(1:N), rep(1:V, length = N)) :
group length is 0 but data length > 0
I can't understand the meaning of the above error, so that I can fix it.
my actual dataset : https://github.com/juisen/dyntreat/blob/main/for_dyn.csv
mydata4<- read.csv(file = "D:/New folder (2)/for_dyn.csv")
head(mydata4)
x0 = mydata4[,5:8];x1 = mydata4[,11:13]
d1 = mydata4[,19];d2 = mydata4[,20]
y2=mydata4[,14]
output4 =dyntreatDML(
y2=y2,
d1=d1,
d2=d1,
x0=x0,
x1=x1,
fewsplits = TRUE,
normalized = TRUE
)
cat("dynamic ATE: ",round(c(output4$effect),3),", standard error: ",
round(c(output4$se),3), ", p-value: ",round(c(output4$pval),3)) ```