time_varying {rcausim}R Documentation

Generate time-varying data

Description

Generate time-varying data

Usage

time_varying(func, data, T_max)

Arguments

func

Functions, an object class generated by function_from_edge or function_from_user functions. All vertices must be defined for their functions. The causal structure needs to be a directed cyclic graph (DCG), which means loops are allowed. Use edge_from_function to identify edges given a list of functions, then draw a causal diagram using the edges data frame (see vignettes). All arguments within any function must be defined by their respective functions, except the argument 'n'. The output lengths of vertex functions must match the input length.

data

Data, a data frame generated by data_from_function which contains causally-simulated data at t=0. Column names of 'i', 't', and 't_max' are not allowed, which respectively refer to instance, time, and maximum time.

T_max

Maximum time for every instance, a numeric vector of length equal to the number of rows in 'data' and must be non-negative and non-decimal.

Value

A data frame which include the simulated data for each vertex as a column for each time up to maximum time for every instance.

Examples


data(functions)
simulated_data <- data_from_function(functions, n = 100)

function_B <- function(B){
  B + 1
}

functions <- define(functions, which = "B", what = function_B)
T_max <- rpois(nrow(simulated_data), lambda = 25)

time_varying(functions, data = simulated_data, T_max = T_max)

[Package rcausim version 0.1.1 Index]