arma11 = {
let rFn = await shelter.evalR(`function(innovs, phi, theta, m) {
c(
arima.sim(
model = list(
order = c(length(phi), ifelse(sum(phi) < 1, 0, 1), length(theta)),
ar = ifelse(phi < 1, phi, 0),
ma = theta
),
n = length(innovs),
innov = innovs,
n.start = length(phi) + length(theta), start.innov = rep(0, length(phi) + length(theta))
) + m
)
}`);
let ret = await rFn(errors, phi, theta, mu/(1-phi));
let { output } = await shelter.captureR('1+1', { withAutoprint: true, captureConditions: false });
mutable out = output.map((line) => line.data).join('\n');
return ret.values;
}