title: Using causalweight package in R
body: <p>I am using a r package named 'causal weight', more specifically 'duntreatDML'</p>
  <p>The example is available here( <a href="https://github.com/cran/causalweight/blob/master/R/JC.R" rel="nofollow noreferrer">https://github.com/cran/causalweight/blob/master/R/JC.R</a>)</p>
  <p>I am using a different dataset  but using the same package:</p>
  <p>a demo version of my data:</p>
  <pre><code>id &lt;- c('1', '2', '3')
  ac &lt;- c(23, 41, 32)
  ff &lt;- c(1,0,1)
  ac1 &lt;- c(34, 21, 11)
  air &lt;- c(10,20,20)
  d1 &lt;- c(1,0,1)
  d2 &lt;- c(1,1,0)
  y2 &lt;- c(100,200,300)
  
  mydata &lt;- data.frame(id, ac,ff,ac1,air,d1,d2,y2)
  </code></pre>
  <pre><code>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)
  </code></pre>
  <p>I am getting the following error:</p>
  <pre><code>Error in split.default(sample(1:N), rep(1:V, length = N)) : 
    group length is 0 but data length &gt; 0
  
  </code></pre>
  <p>I can't understand the meaning of the above error, so that I can fix it.</p>
  <pre><code>my actual dataset : https://github.com/juisen/dyntreat/blob/main/for_dyn.csv                                                               
                                                                                                                                               
  </code></pre>
  <pre><code>mydata4&lt;- read.csv(file = &quot;D:/New folder (2)/for_dyn.csv&quot;)
  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(&quot;dynamic ATE: &quot;,round(c(output4$effect),3),&quot;, standard error: &quot;,
      round(c(output4$se),3), &quot;, p-value: &quot;,round(c(output4$pval),3))                                                ```
  
  
  </code></pre>