jtextor / dagitty

Graphical analysis of structural causal models / graphical causal models.
GNU General Public License v2.0
282 stars 46 forks source link

Is solution to Study question 2.4.1 (d) is broken? #44

Closed hsm207 closed 2 years ago

hsm207 commented 3 years ago

I am following the Causal Inference In Statistics: A Companion for R Users notebook. The code for study question 2.4.1 part (d) is throwing this error:

image

This is the code to reproduce it:

library(dagitty)

fig2.9 <- dagitty("dag { 
X <- Z1 -> Z3 <- Z2 -> Y
X <- Z3 -> Y
X -> W -> Y
}")

coordinates(fig2.9) <- list(x=c(X=1,W=2,Y=3,Z1=1,Z3=2,Z2=3),
    y=c(X=0,W=0,Y=0,Z2=-2,Z1=-2,Z3=-1))

for( v in names( fig2.9 ) ){
    cat( "Variable", v, ":", markovBlanket( fig2.9, v ), "\n" )
}

This is the output of sessioninfo():

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dagitty_0.3-0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5      V8_3.2.0        digest_0.6.25   crayon_1.3.4   
 [5] MASS_7.3-51.5   IRdisplay_0.7.0 repr_1.1.0      lifecycle_0.2.0
 [9] jsonlite_1.7.1  evaluate_0.14   pillar_1.4.6    rlang_0.4.8    
[13] curl_4.3        uuid_0.1-4      ellipsis_0.3.1  boot_1.3-24    
[17] IRkernel_1.1.1  tools_3.6.3     compiler_3.6.3  base64enc_0.1-3
[21] htmltools_0.5.0 pbdZMQ_0.3-3.1 
jtextor commented 2 years ago

Yes, there was a change in the package due to which empty arguments to "parents", "children" etc were no longer accepted. I now changed these functions to allow empty arguments again (so for example the child of "no node" in a DAG is "no node").