Giter Club home page Giter Club logo

dagitty's Introduction

dagitty

This is a collection of algorithms, a GUI frontend and an R package for analyzing graphical causal models (DAGs).

The main components of the repository are:

  • jslib: a JavaScript library implementing many DAG algorithms. This library underpins both the web interface and the R package, but could also be used independently, like in node.js.
  • gui: HTML interface for a GUI that exposes most of the functions in the JavaScript library.
  • r: R package that exposes most of the functions in the JavaScript library.
  • website: The current content of dagitty.net, including a version of the GUI (which may be older than the one in gui.
  • doc: LaTeX source of the dagitty PDF documentation.

Running the web interface locally

Clone the repository and open the file gui/dags.html in your web browser. Currently most functionality should work locally, but you will need an internet connection if you want to load or save DAG models on dagitty.net.

Running the R package

The R package can be installed from CRAN, but this version is not updated very frequently. If you want to install the most recent version of the dagitty R package, you can:

install.packages("remotes") # unless you have it already
remotes::install_github("jtextor/dagitty/r")

If you encounter any problems installing the R package, it is probably not due to dagitty itself, but due to the package "V8" that it depends on. I may try to remove this dependency in a future version.

More information

You can get more information on dagitty at dagitty.net and dagitty.net/learn. The R package is documented through the standard R help interface. There are also a few papers available:

  1. Textor, J., van der Zander, B., Gilthorpe, M. S., Liśkiewicz, M., & Ellison, G. T. H. (2017). Robust causal inference using directed acyclic graphs: the R package ‘dagitty.’ In International Journal of Epidemiology (p. dyw341). Oxford University Press (OUP). https://doi.org/10.1093/ije/dyw341

  2. Ankan, A., Wortel, I. M. N., & Textor, J. (2021). Testing Graphical Causal Models Using the R Package “dagitty.” In Current Protocols (Vol. 1, Issue 2). Wiley. https://doi.org/10.1002/cpz1.45

dagitty's People

Contributors

ankurankan avatar benibela avatar dmurdoch avatar jtextor avatar jttoivon avatar malcolmbarrett avatar nickch-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dagitty's Issues

Unclear error message when variable name not in graph

Hi Johannes,

I've found myself occasionally entering an incorrect variable name into the analysis functions. When one does that, dagitty produces a bit of a mysterious error message, e.g.

library(dagitty)
g <- dagitty("dag{x <- z -> y}")

#  accidentally capitalize "x"
ancestors(g, "X")
#> Error in context_eval(join(src), private$context): TypeError: Cannot read property 'traversal_info' of undefined

I think it would be nice if it were clearer, e.g. in ancestors, do something like

check_dag_names <- function(x, v) {
  if (!(v %in% names(x))) 
    stop(paste(v, "is not a variable in `x`"))
}

check_dag_names(g, "X")
#> Error in check_dag_names(g, "X"): X is not a variable in `x`

ancestors <- function(x, v) {
  check_dag_names(x, v)
  .kins(x, v, "ancestors")
}

What do you think? I could send a PR for the functions that accept variable names, if you'd like.

typo in dsep section

In section two it currently reads: "if there is a collider-tree path "

I think this should be collider-free path.

Variable in backdoor path openend by controlling for cofounder

I have made the following model in DAGitty:

enter image description here

Where X2 is controlled for.

DAGitty says:

The total effect cannot be estimated due to adjustment for an intermediate or a descendant of an intermediate.

My understanding is that I can estimate the total effect if I control also for X1, other than X2, as that would block the backdoor path opened by controlling for X2.

Is that wrong?

Protect against malicious input

All the usages of innerHTML are rather insecure. For example, when an exposure variable is named <a href="javascript:alert(123)">xyz</a>, it creates a link that runs javascript on the side panels:

grafik

set.seed for simulateSEM function

To increase reproducibility, it would be good to have a set.seed() function for simulateSEM, like

dat1 <- simulateSEM(dag1,b.default = .3,N=500,set.seed=1234)

That way, one could always generate the same (simulated) data, across different runs of R code.

Problem with localTests function

Hello,
I am new in dagitty, and I am trying to use localTests function, but I get some errors.

I appreciate your cooperation.

This is my code:

`
library(dagitty)
library(lavaan)
library(CondIndTests)
library(dplyr)

data <- read.csv("D:/clases/UDES/articulo leishmaniasis/causal_inference/dowhy/Data_SD.csv")

data_temp <- select(data, incidence100k, zscore_Temperature,
zscore_SST12, zscore_epac850, zscore_soi, zscore_Forest)

dag_temp <- dagitty('dag {
Temperature [pos="0,0"]
Forest [pos="0.99, 1"]
epac850 [pos="0.66, 1"]
soi [pos="0, 1"]
SST12 [pos="0.33, 1"]
incidence100k [pos="1, 0"]
SST12 -> Temperature
SST12 -> incidence100k
soi -> Temperature
soi -> incidence100k
epac850 -> Temperature
epac850 -> incidence100k
Forest -> Temperature
Forest -> incidence100k
Temperature -> incidence100k }')

plot(dag_temp)

impliedConditionalIndependencies(dag_temp)
corr <- lavCor(data_temp)

plotLocalTestResults(localTests(dag_temp, sample.cov=corr, sample.nobs=nrow(data_temp)))
#HERE THIS ERROR: Error in sample.cov[vars, vars] : subscript out of bounds

plotLocalTestResults(localTests(dag_temp, data, R=100, sample.nobs=nrow(data_temp)))
#HERE THIS ERROR: Error in [.data.frame(x, , ind$X) : undefined columns selected

plotLocalTestResults(localTests(dag_temp, data, R=100, type="cis.loess", sample.nobs=nrow(data_temp)))
#HERE THIS ERROR: Error in [.data.frame(x, , ind$X) : undefined columns selected
`
and here is my dataset:
[Data_SD.csv]

Error: $ operator is invalid for atomic vectors

When I run the dagitty function, I get the following error code:

Error: $ operator is invalid for atomic vectors

For example, the following is taken from the dagitty documentation::

g <- dagitty("dag{ 
  a -> b ;
  b -> c ;
  d -> c
 }")

Error: $ operator is invalid for atomic vectors

Traceback:

  1. stop(e)
  2. value[3L]
  3. tryCatchOne(expr, names, parentenv, handlers[[1L]])
  4. tryCatchList(expr, classes, parentenv, handlers)
  5. tryCatch({ .jsassign(xv, as.character(x)) .jsassign(xv, .jsp("GraphParser.parseGuess(global.", xv, ").toString()")) ...
  6. dagitty("dag{ \n a -> b ;\n b -> c ;\n d -> c\n }")

Any thoughts? Thanks!

issue with lavaanToGraph with parameters fixed to 0

If a parameter is fixed to zero in lavaan by specifying the parameter and fixing it with 0*, lavaanToGraph reads that as though the parameter is estimated, and the independence is not coded. Example:

Sigma <- matrix(c(1, .5, .5, .5, 1, .5, .5, .5, 1), 3, 3)
colnames(Sigma) <- c("X", "M", "Y")
Model <- 'Y ~ M
          M ~ X
          X ~ 0*Y'

fitModel <- sem(model = Model, sample.cov = Sigma, sample.nobs = 100)
param <- parameterEstimates(fitModel)
dag <- lavaanToGraph(param)
plot(dag)

X should (always?) be a parent of Y?

Love this package, and the web interface! Thank you so much. I’ve shared it with colleagues.

While clicking around, I was presented with this challenge.

image

It is solvable as far as the question being asked goes. However, it seemed unintuitive to me that X was not depicted an ancestor of Y. Perhaps that relationship should be enforced when a graph is generated? Or, perhaps this is intentional in some way?

Additional information on "adjusted" variables

Thank you for the great DAG tool!

I tried to find some more information about "adjusted" variables. Manual only says the following: "for variables that have been adjusted for in a statistical analysis"

Maybe you could add some more information about the need to mark variables as "adjusted".

For example: when should we mark variables as "adjusted"? Is this option for a case when we do have some prior knowledge that a variable certainly needs to be adjusted in analysis?

paths are not listed when there are more than one exposures.

For the path function, paths(), paths are returned null when there is more than one exposures. like the following shows:

$paths
[1] "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
[40] "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
[79] "" "" "" "" "" ""

It works well if I set the exposure to only one of them.

Any idea how I can get around with this issue?

Finding libplatform.h on Gentoo

Hi,
Not sure if this belongs with you or with jeroen. In any event thank you both for very useful software! I suspect the difficulty is not in either package, but you may be able to advise on how to resolve it.

I'm installing dagitty on Gentoo, and there is a working Node.js installation which contains V8. The output is as follows -

`also installing the dependency ‘V8’

trying URL 'https://ftp.heanet.ie/mirrors/cran.r-project.org/src/contrib/V8_2.3.tar.gz'
Content type 'application/x-gzip' length 304765 bytes (297 KB)

downloaded 297 KB

trying URL 'https://ftp.heanet.ie/mirrors/cran.r-project.org/src/contrib/dagitty_0.2-2.tar.gz'
Content type 'application/x-gzip' length 168082 bytes (164 KB)

downloaded 164 KB

  • installing source package ‘V8’ ...
    ** package ‘V8’ successfully unpacked and MD5 sums checked
    ** using staged installation
    Using PKG_CFLAGS=-I/usr/include/v8 -I/usr/include/v8-3.14
    Using PKG_LIBS=-lv8 -lv8_libplatform
    ** libs
    rm -f V8.so RcppExports.o bindings.o
    x86_64-pc-linux-gnu-g++ -std=gnu++11 -I"/usr/lib64/R/include" -DNDEBUG -I/usr/include/v8 -I/usr/include/v8-3.14 -I"/usr/lib64/R/library/Rcpp/include" -fvisibility=hidden -fpic -O2 -pipe -c RcppExports.cpp -o RcppExports.o
    x86_64-pc-linux-gnu-g++ -std=gnu++11 -I"/usr/lib64/R/include" -DNDEBUG -I/usr/include/v8 -I/usr/include/v8-3.14 -I"/usr/lib64/R/library/Rcpp/include" -fvisibility=hidden -fpic -O2 -pipe -c bindings.cpp -o bindings.o
    bindings.cpp:1:10: fatal error: libplatform/libplatform.h: No such file or directory
    1 | #include <libplatform/libplatform.h>
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [/usr/lib64/R/etc/Makeconf:174: bindings.o] Error 1
    ERROR: compilation failed for package ‘V8’
  • removing ‘/usr/lib64/R/library/V8’
    ERROR: dependency ‘V8’ is not available for package ‘dagitty’
  • removing ‘/usr/lib64/R/library/dagitty’

The downloaded source packages are in
‘/tmp/RtmpaOhK2w/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning messages:
1: In install.packages("dagitty") :
installation of package ‘V8’ had non-zero exit status
2: In install.packages("dagitty") :
installation of package ‘dagitty’ had non-zero exit status
`

Now, libplatform.h is installed at /usr/include/node/libplatform/libplatform.h but the R installation can't find it. There are a bunch of other libraries in the same tree.
R does not seem to have a specific configuration for Javascript libraries.

Any suggestions on how to tell R (or gcc) where to find these libraries? I guess it's likely to be the PKG_CFLAGS, but I don't know how to set or alter these.

Any help gratefully received.
Thanks,
Anthony Staines

GUI edge toggling

dragging edge is now only possible if edge is directed.
anchoring of edges at nodes gets messed up when cycling through edge types.

markovBlanket() bugs with fix

Below is some code using dagitty version 0.3-1 and the graph from this example code.

library(dagitty)

fig_2.9 <- 
  dagitty(
    'dag{
      W -> Y
      X -> W
      Z_1 -> {X Z_3}
      Z_2 -> {Y Z_3}
      Z_3 -> {X Y}
    }'
  )

markovBlanket(fig_2.9, "Z_1")
#> Warning in if (!(v %in% names(x))) stop(paste(v, "is not a variable in `x`")):
#> the condition has length > 1 and only the first element will be used
#> [1] "X"   "Z_3" "Z_2"

markovBlanket(fig_2.9, "Y")
#> Error in if (!(v %in% names(x))) stop(paste(v, "is not a variable in `x`")): argument is of length zero

Created on 2022-03-04 by the reprex package (v2.0.1)

The warning and error come from dagitty:::.checkName(). The warning is because Z_1 has more than on child. The error is because Y has no children.

The following code fixes these problems.

library(dagitty)
library(purrr)

fig_2.9 <- 
  dagitty(
    'dag{
      W -> Y
      X -> W
      Z_1 -> {X Z_3}
      Z_2 -> {Y Z_3}
      Z_3 -> {X Y}
    }'
  )

markov_blanket <- function(graph, nodes) {
  map_nodes <- function(nodes, .f) {
    nodes %>% 
      map(.f, x = graph) %>% 
      unlist()
  }
  nodes %>% 
    map_nodes(children) %>% 
    map_nodes(parents) %>% 
    union(nodes %>% map_nodes(parents)) %>% 
    union(nodes %>% map_nodes(children)) %>% 
    setdiff(nodes) %>% 
    sort()
}

markov_blanket(fig_2.9, list())
#> NULL

markov_blanket(fig_2.9, "Z_1")
#> [1] "X"   "Z_2" "Z_3"

markov_blanket(fig_2.9, "Y")
#> [1] "W"   "Z_2" "Z_3"

markov_blanket(fig_2.9, c("W", "Y"))
#> [1] "X"   "Z_2" "Z_3"

Created on 2022-03-04 by the reprex package (v2.0.1)

Problem with installation, stacksmashing

Hi, I'm not able to install either the CRAN or the development package on my system. I get the below warning about stack smashing:

install_github("jtextor/dagitty/r", lib='~/R/x86_64-pc-linux-gnu-library/')
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo jtextor/dagitty@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All
2: CRAN packages only
3: None
4: jsonlite (1.7.3 -> 1.8.0) [CRAN]
5: V8       (4.0.0 -> 4.1.0) [CRAN]

Enter one or more numbers, or an empty line to skip updates:
✔  checking for file ‘/tmp/RtmpIAi4xs/remotes128e77fe0e382/jtextor-dagitty-465782d/r/DESCRIPTION’ ...
─  preparing ‘dagitty’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Omitted ‘LazyData’ from DESCRIPTION
─  building ‘dagitty_0.3-2.tar.gz’

* installing *source* package ‘dagitty’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
*** stack smashing detected ***: terminated
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** stack smashing detected ***: terminated
** testing if installed package can be loaded from final location
*** stack smashing detected ***: terminated
** testing if installed package keeps a record of temporary installation path
Warning in file(con, "rb") :
  cannot open file '/tmp/Rtmp5a5wQ4/file128f824fc32fea': No such file or directory
Error in file(con, "rb") : cannot open the connection
* removing ‘/home/japhir/R/x86_64-pc-linux-gnu-library/dagitty’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/RtmpIAi4xs/file128e776d035b6/dagitty_0.3-2.tar.gz’ had non-zero exit status
sessionInfo()
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libopenblasp-r0.3.20.so
LAPACK: /usr/lib/liblapack.so.3.10.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] devtools_2.4.3 usethis_2.1.5

loaded via a namespace (and not attached):
 [1] magrittr_2.0.1    pkgload_1.2.4     R6_2.5.1          rlang_0.4.12
 [5] fastmap_1.1.0     fansi_1.0.2       tools_4.1.2       pkgbuild_1.3.1
 [9] sessioninfo_1.2.2 utf8_1.2.2        cli_3.1.1         withr_2.4.3
[13] ellipsis_0.3.2    remotes_2.4.2     rprojroot_2.0.2   tibble_3.1.6
[17] lifecycle_1.0.1   crayon_1.4.2      brio_1.1.3        processx_3.5.2
[21] purrr_0.3.4       callr_3.7.0       vctrs_0.3.8       fs_1.5.2
[25] ps_1.6.0          curl_4.3.2        testthat_3.1.2    memoise_2.0.1
[29] glue_1.6.1        cachem_1.0.6      compiler_4.1.2    pillar_1.6.4
[33] desc_1.4.0        prettyunits_1.1.1 pkgconfig_2.0.3

DAGitty in python?

Excuse the possible blasphemy,
but is there any initiative to export code to other languages like python, or even create python modules?

In any case, I'm looking forward to brushing up on my R for the sake of using DAGitty!

Pan and zoom?

When working on jupyterlab-dagitty I coded pan & zoom, mostly using dagitty's public API (see here). I configured it to only kick in for Ctrl + mouse wheel/drag so that we can still move nodes/edges around as before, but another hotkey could be used too. Please let me know if you are interested in adding this to dagitty itself, I would be happy to open a PR.

add parser/GraphDotParser.js

GraphDotParser.js probably should be in the repository, so make can be called without having pegjs installed.

I only have a GraphDotParser.js generated by pegjs 0.9.0, which messes the diff of dagitty-alg.js up after every make

Flow algorithm

There is currently a max-flow implementation in the package. This might not work well together with contractVertex. Investigate and write a unit test.

Github installs v0.2.3

Novice R user here, so I might be doing something wrong.
Installing from github (both master and v3.0) installs version 0.2.3:

Restarting R session...

> library("dagitty")
Error in library("dagitty") : there is no package calleddagitty> library(devtools)
Loading required package: usethis
> install_github("jtextor/dagitty/r")
Downloading GitHub repo jtextor/dagitty@masterchecking for file/private/var/folders/yk/3mfv2d_d33jc54854g68hktc0000gn/T/RtmpZVW1S6/remotes236e1ab6f7a7/jtextor-dagitty-d163478/r/DESCRIPTION...preparingdagitty:checking DESCRIPTION meta-information ...checking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directoriesbuildingdagitty_0.2-3.tar.gz* installing *source* packagedagitty...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (dagitty)
> packageVersion("dagitty")
[1] ‘0.2.3> remove.packages("dagitty")
Removing package from/Library/Frameworks/R.framework/Versions/3.6/Resources/library’
(aslibis unspecified)

Or from the v3.0 tag:

Restarting R session...

> library(devtools)
Loading required package: usethis
> packageVersion("dagitty")
Error in packageVersion("dagitty") : there is no package calleddagitty> install_github("jtextor/dagitty/r", ref = "v3.0")
Downloading GitHub repo jtextor/dagitty@v3.0checking for file/private/var/folders/yk/3mfv2d_d33jc54854g68hktc0000gn/T/Rtmp48SgpV/remotes23bca075161/jtextor-dagitty-86215de/r/DESCRIPTION...preparingdagitty:checking DESCRIPTION meta-information ...checking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directoriesbuildingdagitty_0.2-3.tar.gz* installing *source* packagedagitty...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (dagitty)

> packageVersion("dagitty")
[1] ‘0.2.3

adjustmentSets function doesn't work for some DAGs

Hi,
I'm using the development version: '0.2.3'
I've built the following DAG:

g <- dagitty( "dag {
churn [outcome]
cong [exposure]
cong -> CX [beta = -0.3]
CX -> churn [beta = -0.5]
comp -> cong [beta = -0.4]
comp -> churn [beta = 0.9]
cong -> brand [beta = -0.8]
brand -> comp [beta = 0.7]
demo -> comp [beta = 0.4]
demo -> churn [beta = -0.7]
}" )

I know that in order to estimate the causal effect of cong on churn I need to condition on {comp, demo}. I've verified that in simulation as well.

Running the following command:

print(adjustmentSets(g))

Yield an empty set.

I've tried removing the betas or move the exposure/outcome enumeration to the function itself to no avail. It seems that only if I reduce the model a bit e.g.:

g <- dagitty( "dag {
churn [outcome]
cong [exposure]
cong -> CX [beta = -0.3]
CX -> churn [beta = -0.5]
comp -> cong [beta = -0.4]
comp -> churn [beta = 0.9]
cong -> brand [beta = -0.8]
}" )

I get the right conditioning set ({comp}) by running print(adjustmentSets(g))

See attached md file too
try.docx

convert a Neo4j connection object into a DAGitty object

I am having problem to convert a neo4j connection object into a dagitty object.

using as.dagitty(con)

where con is a connection object using neo4r package.

Returned result is:
Error in as.vector(x, "character") :
cannot coerce type 'environment' to vector of type 'character'
In addition: Warning message:
In if (class(x) == "dagitty") { :
the condition has length > 1 and only the first element will be used

Would anyone enlighten me in this regard?

New GUI: make c work again

In the old GUI, it was possible to use the 'c' key to draw arrows. Should still be possible in the new GUI.

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

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 

R crash due to dagitty error: libicu data files missing?

Firstly, thank you very much for this great software and web service!

I'm trying to run it on Fedora 30, and get a crash with the error:

Failed to create ICU collator, are ICU data files missing?

I see this error occurs on the package build check on CRAN also.

Stacktrace:

library(dagitty)
RAA <- dagitty( "pdag { I -> B; {A SN PBC} -> I; A <-> {PBC SN} }" )

Fatal error in , line 0

Failed to create ICU collator, are ICU data files missing?

#FailureMessage Object: 0x7ffeada1b650
==== C stack trace ===============================

/lib64/libnode.so.64(v8::base::debug::StackTrace::StackTrace()+0x1a) [0x7fe44c55e88a]
/lib64/libnode.so.64(+0x92ccd1) [0x7fe44bae6cd1]
/lib64/libnode.so.64(V8_Fatal(char const*, int, char const*, ...)+0x177) [0x7fe44c55a387]
/lib64/libnode.so.64(v8::internal::Collator::InitializeCollator(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::JSObject>)+0x473) [0x7fe44c23b843]
/lib64/libnode.so.64(v8::internal::Runtime_CreateCollator(int, v8::internal::Object**, v8::internal::Isolate*)+0x192) [0x7fe44c3608d2]
[0x2cc02a7dc0d8]

*** caught illegal operation ***
address 0x7fe44b92538d, cause 'illegal operand'

Traceback:
1: context_eval(join(src), private$context)
2: get_str_output(context_eval(join(src), private$context))
3: ct$eval(paste("global.", name, "=", value))
4: .jsassign(xv, .jsp("GraphParser.parseGuess(global.", xv, ").toString()"))
5: doTryCatch(return(expr), name, parentenv, handler)
6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
7: tryCatchList(expr, classes, parentenv, handlers)
8: tryCatch({ .jsassign(xv, as.character(x)) .jsassign(xv, .jsp("GraphParser.parseGuess(global.", xv, ").toString()")) r <- structure(.jsget(xv), class = "dagitty")}, error = function(e) { stop(e)}, finally = { .deleteJSVar(xv)})
9: dagitty("pdag { I -> B; {A SN PBC} -> I; A <-> {PBC SN} }")

Error: object of type 'closure' is not subsettable

I'm unable to use 'dagitty' as every time I attempt to parse a DAG I receive the error "object of type 'closure' is not subsettable", even if I run an example from the documentation like:
dagitty("dag{y <- z -> x}")

Seems I'm not the only one with this issue, as someone posted the same problem on Stack Overflow 04/2020. I'm running R 3.6.2, and have tried installing 'dagitty' version "0.1-9" and this has not resolved the issue.

ancestors() and descendants() return input variable

The functions ancestors() and descendants() return the input variable.

library(dagitty)

sessioninfo::package_info("dagitty", dependencies = FALSE)
#>  package * version date (UTC) lib source
#>  dagitty * 0.3-2   2022-04-06 [1] Github (jtextor/dagitty@b31c919)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

graph <- dagitty('dag { X -> Y -> Z } ')

ancestors(graph, "Y")
#> [1] "Y" "X"

descendants(graph, "Y")
#> [1] "Y" "Z"

Created on 2022-04-06 by the reprex package (v2.0.1)

This does not follow the usual definitions; see, for example, (Pearl, 2016), p. 25.

Layout exposure and outcome separately

On a DAG with more than ~10 variables it's currently hard to see backdoor paths, IV etc.
Would be nice to allow a layout that separates exposure, outcome, backdoor paths, IV and so on.

hi, i have a question about the node's position?

hi, i have a question about the node's position?
Look the meta data like this below.

{
    e: "0  1  0  0  0  0  0  0  0  0  0  0  0  0\n"+
       "0  0  0  0  0  0  0  0  0  0  0  0  0  0\n"+
       "1  0  0  0  0  0  0  0  0  0  0  0  0  0\n"+
       "1  0  0  0  0  0  0  0  0  0  0  0  0  0\n"+
       "0  1  1  0  0  0  1  0  0  0  0  0  0  1\n"+
       "0  1  1  0  1  0  1  0  0  0  0  0  0  1\n"+
       "0  1  0  0  0  0  0  0  0  0  0  0  0  0\n"+
       "1  1  1  1  1  1  1  0  0  0  1  1  1  1\n"+
       "1  1  1  1  1  1  1  1  0  0  1  1  1  1\n"+
       "1  1  1  1  1  1  1  1  0  0  1  1  1  1\n"+
       "1  1  0  0  1  1  1  0  0  0  0  1  0  1\n"+
       "1  1  1  0  1  1  1  0  0  0  0  0  1  0\n"+
       "0  1  1  0  1  1  1  0  0  0  0  0  0  1\n"+
       "0  1  0  0  0  0  0  0  0  0  0  0  0  0",

    v: "ToothLoss E @-1.677,2.421\n"+
"Mortality O @1.900,2.360\n"+
"Periodontitis 1 @-0.335,1.703\n"+
"Caries 1 @-1.879,-1.875\n"+
"Diabetes 1 @-0.888,0.322\n"+
"Obesity 1 @-0.904,-1.340\n"+
"Hypertension 1 @1.780,-0.157\n"+
"Psychosocial 1 @-0.088,0.266\n"+
"Age 1 @-0.039,-1.762\n"+
"Sex 1 @-0.844,-3.340\n"+
"Alcohol 1 @0.054,-3.594\n"+
"Smoking 1 @0.772,0.379\n"+
"Sport 1 @0.914,-3.396\n"+
"Lipids 1 @2.026,-1.650",

    l: "Polzer et al., 2012"
},

how to calculte the nodes's positions(x,y) as the Matrix like this?
the important thing is to visuliazation.

impliedConditionalIndependencies missing several independences

When using impliedConditionalIndependencies() with the DAG
A ~ W1,
Y ~ W3,
W2 ~ W1 + W3,
W4 ~ W2
several independences are not returned by impliedConditionalIndependencies()
such as A II Y | W3; A II W3 | Y; A II W3 | W1, W2; W1 II Y | A
See section 5.1, top of p, 85 of Fundamentals of Causal Inference by Babette A. Brumback.

Incorrect comments for dconnected and dseparated in documentation

In the R documentation for dconnected and dseparated methods, the following examples are listed at the end:

"dconnected( "dag{x->m->y}", "x", "y", c() ) # TRUE
dconnected( "dag{x->m->y}", "x", "y", c("m") ) # FALSE
dseparated( "dag{x->m->y}", "x", "y", c() ) # TRUE
dseparated( "dag{x->m->y}", "x", "y", c("m") ) # FALSE"

The comments for the last two (dseparated) lines should be the other way around, as in :

"dseparated( "dag{x->m->y}", "x", "y", c() ) # FALSE
dseparated( "dag{x->m->y}", "x", "y", c("m") ) # TRUE"

Error `the condition has length > 1`

I made a mistake and tried to check adjustment from a plot instead of the of the DAG and there was an unexpected error:

library("dagitty")
library("ggdag")
#> 
#> Attaching package: 'ggdag'
#> The following object is masked from 'package:stats':
#> 
#>     filter
dag <- dagitty("dag{ 
  a -> b b -> c c -> d
 }")
plot <- ggdag(dag) + 
  theme_dag() + theme_dag_gray()
ggdag_adjustment_set(plot, outcome = "a")
#> Error in if (class(x) == "dagitty") {: the condition has length > 1

I think this could be just a simple case of replacing class(x) by is(x, "dagitty") in

if( class(x) == "dagitty" ){

Created on 2023-01-20 with reprex v2.0.2

Publish to npm?

Thank you for dagitty, it is a great help. Would you consider publishing the dagitty package (or its subset) to the npm repository?

HTTPS certificate

https://www.dagitty.net/ geht nicht mehr:

Websites bestätigen ihre Identität mittels Zertifikaten. Firefox vertraut dieser Website nicht, weil das von der Website verwendete Zertifikat nicht für dagitty.net gilt. Das Zertifikat gilt nur für folgende Namen: www.concebo.eu, concebo.eu

Fehlercode: SSL_ERROR_BAD_CERT_DOMAIN

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.