A package for estimating dynamic graphical lasso with heavy tailed distributions
Project description
DyGraph
A package for dynamic graph estimation.
pip install DyGraph
from sklearn.datasets import make_sparse_spd_matrix
import DyGraph as dg
import numpy as np
from scipy.stats import multivariate_t as mvt
Generate some data.
d = 5 # number of nodes
A = make_sparse_spd_matrix(d, alpha=0.6)
X = mvt.rvs(loc = np.zeros(d),df = 4, shape = np.linalg.inv(A), size=200)
max_iter = 100
obs_per_graph = 50
alpha = 0.05
kappa = 0.1
kappa_gamma = 0.1
tol = 1e-4
Gaussian
dg_opt = dg.dygl_inner_em(X, obs_per_graph = obs_per_graph, max_iter = max_iter, lamda = alpha, kappa = kappa, tol = tol, lik_type='gaussian')
dg_opt.fit(temporal_penalty = 'element-wise')
access the graphs via:
dg_opt.theta
t, inner and outer. Can give degrees of freedom, or estimate
# inner
dg_opt_t_inner = dg.dygl_inner_em(X = X, obs_per_graph = obs_per_graph, max_iter = max_iter, lamda = alpha, kappa = kappa, tol = tol, lik_type='t')
dg_opt_t_inner.fit(temporal_penalty = 'element-wise')
# outer
dg_opt_t_outer = dg.dygl_outer_em(X = X, obs_per_graph = obs_per_graph, max_iter = max_iter, lamda = alpha, kappa = kappa, tol = tol, lik_type='t')
dg_opt_t_outer.fit(temporal_penalty = 'element-wise', nu = [4]*4) # Note one nu/DoF for each graph.
Group t
# outer
dg_opt_gt_outer = dg.dygl_outer_em(X = X, obs_per_graph = obs_per_graph, max_iter = max_iter, lamda = alpha, kappa = kappa, tol = tol, lik_type='group-t')
dg_opt_gt_outer.fit(temporal_penalty = 'element-wise', nu = [[4] * d]*4, groups = [0]*d) # Note one nu/DoF for each graph and feature/group, all features in same group
skew group t
# outer
dg_opt_sgt_outer = dg.dygl_outer_em(X = X, obs_per_graph = obs_per_graph, max_iter = max_iter, lamda = alpha, kappa = kappa, kappa_gamma = kappa_gamma, tol = tol, lik_type='skew-group-t')
dg_opt_sgt_outer.fit(temporal_penalty = 'element-wise', nu = None, groups = [0]*d) # nus estimate, all features in same group
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
DyGraph-0.0.12.tar.gz
(30.8 kB
view details)
Built Distribution
DyGraph-0.0.12-py3-none-any.whl
(39.7 kB
view details)
File details
Details for the file DyGraph-0.0.12.tar.gz
.
File metadata
- Download URL: DyGraph-0.0.12.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01bb7390fa4c719571776de7bd55acd89db0e8461ae26c72f8d931e9cfb45482 |
|
MD5 | 8240e0b3e48ab6e90d71041d88032481 |
|
BLAKE2b-256 | 615193561b83bec59c8e85a5e91c3e5dec0671f9682449e761a0191a98515828 |
File details
Details for the file DyGraph-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: DyGraph-0.0.12-py3-none-any.whl
- Upload date:
- Size: 39.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 813f6eeb6526276bf9dad74b772c5af8e9b610c47ba02c3ffb3bf36b289879e3 |
|
MD5 | e7285c9a5a831ce042eb47ad4b9258a1 |
|
BLAKE2b-256 | 847356d2061daefc44d99b46bfcf54709b4dd0e178df8202d41910de503ebc85 |