# Simulate x -> y -> z
set.seed(101)
x = rnorm(100)
y = 0.5*x + rnorm(100)
z = 1*y + rnorm(100)
tsdata = ts(data.frame(x=x, y=y, z=z))
# define candidates
model_options = c(
"y -> z, 0, y_to_z",
"x -> z, 0, x_to_z"
)
# define paths that are required
model_shared = "
x -> y, 0, x_to_y
"
# Do selection
step = stepwise_selection(
model_options = model_options,
model_shared = model_shared,
tsdata = tsdata,
quiet = TRUE
)
# Check selected model
cat(step$model)
Run the code above in your browser using DataLab