Targeted maximum likelihood estimation for network-dependent data
Project description
MossSpider
MossSpider provides an implementation of the targeted maximum likelihood estimator for network-dependent data
(network-TMLE) in Python. Currently mossspider
supports estimation of the conditional network mean for stochastic
policies.
mossspider
get its name from the spruce-fir moss spider, a
tarantula that is both the world's smallest tarantula and native to North Carolina.
Installation
Installing:
You can install via python -m pip install mossspider
Dependencies:
The dependencies are: numpy
, scipy
, statsmodels
, networkx
, matplotlib
. Notice that NetworkX must be at least
2.0.0 to work properly.
Getting started
To demonstrate mossspider
, below is a simple demonstration of calculating the mean for the following data.
from mossspider import NetworkTMLE
from mossspider.dgm import uniform_network, generate_observed
First, we will use some built-in data generating functions
graph = uniform_network(n=500, degree=[1, 4])
graph_observed = generate_observed(graph)
Now, we can use NetworkTMLE
to estimate the causal conditional mean under a stochastic policy. Here, the stochastic
policy sets everyone's probability of action A=1
to 0.65.
ntmle = NetworkTMLE(network=graph_observed,
exposure='A', # Exposure in graph
outcome='Y', # Outcome in graph
verbose=True) # Print model summaries
ntmle.exposure_model(model="W + W_sum")
ntmle.exposure_map_model(model='A + W + W_sum', # Parametric model
measure='sum', # Summary measure for A^s
distribution='poisson') # Model distribution to use
ntmle.outcome_model(model='A + A_sum + W + W_sum')
ntmle.fit(p=0.65, samples=500)
ntmle.summary()
For full details on using mossspider
, see the full documentation and worked examples available
at MossSpider website.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mossspider-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e40434e16e301b4c13278c4de0deb69b78203e731663e3722d6c5ff8531b3c1e |
|
MD5 | 3248dc0b96ffc3ca711f73c03d6c5db8 |
|
BLAKE2b-256 | 8d30c085f7b02cefd6f08dca996d6042c47303609b36a264eef900c5e80e3af7 |