Forward-integrates the model defined by M$f (state equation) and
M$g (observation equation) under the input U, returning the
predicted observations at the requested sample points.
dcm_int(P, M, U)Numeric matrix of predicted observations (rows = samples).
M$f and M$g may be given as functions or as the names of
functions. M$n must be the length of the flattened state
(length(dcm_vec(M$x)), i.e. regions x hidden states), while
M$l is the number of observed outputs (regions) and M$m
the number of inputs.
dcm_estimate, which calls this as its forward model.
# Simulate the BOLD response of a two-region model to a boxcar input.
n <- 2L
pri <- dcm_fmri_priors(A = matrix(1, n, n),
B = array(0, c(n, n, 1)),
C = matrix(c(1, 0), n, 1),
D = array(0, c(n, n, 0)),
options = list())
U <- list(u = matrix(c(rep(1, 16), rep(0, 16)), ncol = 1), dt = 1)
M <- list(f = "dcm_fx_fmri", g = "dcm_gx_fmri", x = pri$x,
m = ncol(U$u), n = length(pri$x), l = nrow(pri$x), ns = 32)
# The priors put C at zero, so start from them and switch on a driving
# input to region 1 and a connection from region 1 to region 2.
P <- pri$pE
P$C[1, 1] <- 1
P$A[2, 1] <- 0.4
y <- dcm_int(P, M, U)
dim(y) # 32 samples x 2 regions
#> [1] 32 2
round(y[seq(1, 32, 4), ], 3)
#> [,1] [,2]
#> [1,] 0.000 0.000
#> [2,] 0.304 0.078
#> [3,] 1.569 0.809
#> [4,] 2.156 1.532
#> [5,] 2.195 1.745
#> [6,] 1.938 1.704
#> [7,] 0.718 1.036
#> [8,] 0.050 0.282