Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 46 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,56 @@ The `NetworkCausalTree` package introduces a machine learning method that uses t

## Getting Started

Installing the latest developing version:
Installing the latest developing version:

```r
``` r
library(devtools)
install_github("fbargaglistoffi/NetworkCausalTree", ref="master")
```

Import:
Import + set seed:

```r
``` r
library("NetworkCausalTree")
set.seed(123)
```

## Examples

### Example 1

Data generated using Erdos Renyi networks.
Data generated using Erdos Renyi networks.

```r
``` r
## Examples
dataset <- data_generator_direct_indirect(N = 4000,
M = 4,
k = 80,
p = rep(0.2,4000),
het = TRUE,
h = 2,
method_networks = "er",
param_er = 0.1)
dataset_direct <- data_generator_direct(N = 4000,
M = 4,
k = 80,
p = rep(0.2,4000),
het = TRUE,
h = 2,
method_networks = "er",
param_er = 0.1)
```

Singular splitting based on the main treatment effect only
Singular splitting based on the main treatment effect only

```r


result <- NetworkCausalTree(X = dataset[["X"]],
Y = dataset[["Y"]],
W = dataset[["W"]],
A = dataset[["A"]],
K = dataset[["K"]],
p = dataset[["p"]],
``` r
result <- NetworkCausalTree(X = dataset_direct[["X"]],
Y = dataset_direct[["Y"]],
W = dataset_direct[["W"]],
A = dataset_direct[["A"]],
K = dataset_direct[["K"]],
p = dataset_direct[["p"]],
effect_weights = c(1,0,0,0),
ratio_disc = 0.5,
depth = 3,
depth = 2,
minsize = 5,
method = "singular",
output = "estimation")


title <- expression(paste("CAUSAL TREE TARGETED TO ",tau,"(1,0;0,0)"),sep="")
cov_names <- colnames(dataset[["X"]])
cov_names <- colnames(dataset_direct[["X"]])

plot_NCT(NCT = result,
cov_names = cov_names,
Expand All @@ -64,55 +62,50 @@ plot_NCT(NCT = result,

### Example 2

Data generated using Barabasi - Albert networks.

```r


dataset <- data_generator_direct_indirect(N = 4000,
M = 4,
k = 80,
p = rep(0.2,4000),
het = TRUE,
h = 3,
method_networks = "sf")
Data generated using Barabasi - Albert networks.

``` r
dataset_direct_indirect <- data_generator_direct_indirect(N = 4000,
M = 4,
k = 80,
p = rep(0.2,4000),
het = TRUE,
h = 3,
method_networks = "sf")
```

Composite splitting (NCT based on all the four effects)

```r

result <- NetworkCausalTree(X = dataset[["X"]],
Y = dataset[["Y"]],
W = dataset[["W"]],
A = dataset[["A"]],
K = dataset[["K"]],
p = dataset[["p"]],
``` r
result <- NetworkCausalTree(X = dataset_direct_indirect[["X"]],
Y = dataset_direct_indirect[["Y"]],
W = dataset_direct_indirect[["W"]],
A = dataset_direct_indirect[["A"]],
K = dataset_direct_indirect[["K"]],
p = dataset_direct_indirect[["p"]],
effect_weights = c(0.25, 0.25, 0.25, 0.25),
ratio_disc = 0.5,
depth = 2,
minsize = 5,
method = "composite",
output = "detection")
output = "estimation")

title <- expression("CAUSAL TREE TARGETED TO ALL THE EFFECTS")
cov_names <- colnames(dataset[["X"]])
title <- expression(paste("CAUSAL TREE TARGETED TO ",tau,"(0.25,0.25;0.25,0.25)"),sep="")
cov_names <- colnames(dataset_direct_indirect[["X"]])

plot_NCT(NCT = result,
cov_names = cov_names,
title = title,
output = "detection")
effect_color_nodes = "0100")
```

## Code of Conduct

Please note that the CRE project is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct). By contributing to this project, you agree to abide by its terms. More information about the opening issues and contributing (i.e., git branching model) can be found [here](https://nsaph-software.github.io/CRE/articles/Contribution.html).


## Cite

```bibtex
``` bibtex
@article{bargagli2025heterogeneous,
title={Heterogeneous treatment and spillover effects under clustered network interference},
author={Bargagli-Stoffi, Falco J. and Tort{\'u}, Costanza and Forastiere, Laura},
Expand Down
Binary file modified paper/images/NCT_algorithm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed paper/images/nct_algorithm.png
Binary file not shown.
Loading