Learn R Programming

EDISON (version 1.1.1)

simulateNetwork: Generate network and simulate data.

Description

This function generates a random network with structure changepoints (or takes one as input) and simulated data from it using a regression model.

Usage

simulateNetwork(l = 100, min_phase_length = 10, k_bar = 10, q = 10, lambda_2 = 0.45, noise = 0.25, net = NULL, lambda_3 = 2, spacing = 0, gauss_weights = FALSE, same = FALSE, changes = "sequential", fixed = FALSE, cps = NULL, saveFile = NULL)

Arguments

l
Length of the time series.
min_phase_length
Minimum segment length.
k_bar
Maximum number of changepoints.
q
Number of nodes.
lambda_2
Average number of parents for each node in the network (parameter for a Poisson distribution).
noise
Standard deviation of the Gaussian observation noise. Can be constant, or segment specific (in which case the number of changepoints needs to be fixed and the noise needs to be a vector of the same length).
net
Input network, can be NULL if a new network should be generated.
lambda_3
Average number of structure changes between two segments (parameter for a Poisson distribution).
spacing
1 if segments are equally spaced, 0 if they are spaced randomly (subject to the constraints of min_phase_length).
gauss_weights
1 if edge weights in the network are drawn from N(0, 1), 0 if they are fixed to be 1.
same
1 if the networks should all be the same (no changes), 0 otherwise.
changes
'sequential' if the changes happen sequentially (i.e. changes at segment i are applied to segment i-1), 'hierarchical' if the changes happen with respect to a hypernetwork (i.e. changes at segment i are applied to segment 0).
fixed
T if the changepoint locations are fixed, F if they should be sampled.
cps
Changepoint locations (if they are fixed).
saveFile
If not NULL, indicates the filename for saving the output in R data format.

Value

A list with elements:
sim_data
A matrix of length NumNodes by NumTimepoints containing the simulated data from the regression model.
epsilon
Changepoint vector.
k
Number of changepoints.
network
The network, a list of length NumSegs, where each element is a NumNodes by NumNodes matrix.
noise
The standard deviation of the applied Gaussian noise.

See Also

generateNetwork

Examples

Run this code

# Generate random network and simulate data with default parameters
dataset = simulateNetwork()

# Generate random network and simulate data with an average of 
# 1 change per node among network segments
dataset = simulateNetwork(lambda_3=1)

# Generate random network and simulate data with an average of 
# 1 change per node among network segments and standard deviation 
# of the Gaussian observation noise 0.5
dataset = simulateNetwork(lambda_3=1, noise=0.5)

# Generate random network with default parameters
network = generateNetwork()

# Simulate data using generated network
dataset = simulateNetwork(net=network)

# Generate random network with 4 changepoints and 15 nodes, 
# with changepoints distributed over a timeseries of length 50
network = generateNetwork(l=50, q=15, fixed=TRUE, k_bar=4)

# Simulate data of length 50 using generated network
dataset = simulateNetwork(net=network)

Run the code above in your browser using DataLab