Learn R Programming

ntwk

The goal of ntwk is to provide functions for the statistical modelling of network time series, especially with irregularly-spaced data and a Lévy-type driving noise.

Installation

SOON You can install the released version of ntwk from CRAN with:

# install.packages("ntwk")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("valcourgeau/ntwk")

Example

This is a basic example of the GrOU 2-parameter MLE after constructing a sample path driven by a Brownian motion:

library(ntwk)
set.seed(1)
n <- 10000
d <- 5
theta_1 <- 1
theta_2 <- 2
mesh_size <- 0.01

# Generate a graph adjacency matrix
adj <- polymer_network(d = d, theta_1 = theta_1, theta_2 = theta_2)

# Generate a path
times <- seq(from = 0, by = mesh_size, length.out = n) # time grid
noise <- matrix(rnorm(d * n, mean = 0, sd = sqrt(mesh_size)), ncol = d)
path <- construct_path(
  nw_topo = adj, noise = noise, y_init = rep(0, d), delta_time = mesh_size
)

# Fits the Theta-GrOU (2 parameters) process
fit <- grou_mle(times = times, data = path, mode = "network")
print(fit) # should be c(theta_1, theta_2) = c(1, 2)
#> [1] 1.077150 2.137579

Copy Link

Version

Install

install.packages('ntwk')

Monthly Downloads

1

Version

1.0.0

License

MIT + file LICENSE

Maintainer

Valentin Courgeau

Last Published

September 13th, 2021

Functions in ntwk (1.0.0)

grad_likelihood_fn

Gradient of the GrOU likelihood function with penalty.
polymer_network

Creates adjacency matrix with min degree one and max degree two.
row_normalised

Normalise a square matrix by dividing elements by the sum of off-diagonal entries row-wise. Note: sets diagonal to zero.
construct_path

Generates a single Graph Ornstein-Uhlenbeck path with the given network topology (nw_topo), noise increments (noise), initial values (y_init) and unique time difference (delta_time).
core_node_mle

Computes the MLE numerator and denominator of a batch of data
fit_ghyp_diffusion

Fit a Generalised Hyperbolic distribution.
node_mle_components

Returns the components (i.e. numerator and denominator) of the MLE
fully_connected_network

Fully-connected graph.
node_mle_long

Constructs the Node MLE with jump thresholding
concatenate_col

Concatenate col_vec columnwise n times
clean_data

Clean data using STL / Loess function.
correlated_brownian_noise

Generates multidimensional correlated Brownian motion increments
data_filtering

Filters the data above the thresholds (set to zero). Thresholds can be a single value, or equal to the number of rows. If thresholds is set to NA, no thresholding happens.
fasen_regression

Fasen's multivariate OU least squares regression /10.1016/j.jeconom.2012.08.019.
fit_bm_compound_poisson

Fit Brownian motion mixture with Gaussian jumps.
isolated_network

Creates adjacency matrix with max degree zero.
likelihood_fn

Likelihood function for the GrOU process with penalty.
grou_regularisation

Regularisation schemes for the GrOU process that implements a Lasso, Ridge or Adaptive Lasso penalty.
make_node_mle

Constructs the MLE from its components
bm_compound_poisson_ghyp

Generates a (correlated) Brownian motion path with correlated but unsynchronised GHYP jumps.
bm_compound_poisson

Generates a (correlated) Brownian motion path with correlated but unsynchronised Gaussian jumps.
lattice_network

Lattice/grid-like network with max degree of four across all nodes.
augmented_diag

Returns an offset diagonal matrix.
levy_recovery

Apply the Levy recovery on data with (fitted) adjacency/dynamics matrix.
check_thetas

Checks that |theta_1| <= theta_2.
grou_mle

Computes the GrOUs MLE of a batch of data