Skip to content

Commit 9251890

Browse files
committed
Fix simulation methid
1 parent 1191e21 commit 9251890

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/interface.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,17 @@ with the simulated data, using random number generator `rng` and apply a burn-in
160160
function simulate(model::DynamicFactorModel; burn::Integer = 100,
161161
rng::AbstractRNG = Xoshiro())
162162
# factor process
163-
F_sim = simulate(process(model), burn = burn, rng = rng)
163+
f = simulate(process(model), nobs(model) + burn, rng = rng)
164+
F = copy(process(model))
165+
factors(F) .= f[:, (burn + 1):end]
164166

165167
# error distribution
166-
ε_sim = simulate(errors(model), rng = rng)
168+
e = simulate(errors(model), nobs(model), rng = rng)
167169

168170
# simulate data
169-
y_sim = mean(mean(model)) .+ loadings(model) * factors(F_sim) + resid(ε_sim)
171+
y = mean(mean(model)) .+ loadings(F) * factors(F) + e
170172

171-
return DynamicFactorModel(y_sim, copy(mean(model)), ε_sim, F_sim)
173+
return DynamicFactorModel(y, copy(mean(model)), copy(errors(model)), F)
172174
end
173175

174176
"""

0 commit comments

Comments
 (0)