Skip to content

Commit

Permalink
Fix for #393
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Sep 6, 2023
1 parent 9b926f8 commit 77a561b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/ar.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ estimate_ar <- function(x, p, xreg, constant, fixed) {
coef.se = coef_se,
fits = c(rep.int(NA_real_, p), YH),
resid = c(rep.int(NA_real_, p), E),
reg_resid = x - xm*x_sd,
reg_resid = x - xm,
last = x[(length(E)+1):length(x)],
sigma2 = drop(varE),
aic = aic,
Expand Down Expand Up @@ -283,14 +283,14 @@ generate.AR <- function(x, new_data = NULL, specials = NULL,

# Predict xreg
nx <- length(coef) - p
ar <- coef[nx + seq_len(p)]
if (!is.null(xreg)) {
xcoef <- coef[seq_len(nx)]
xm <- drop(xreg %*% xcoef)
xm <- drop(xreg %*% xcoef) / (1 - sum(ar))
} else {
xm <- rep(0, nrow(new_data))
}

ar <- coef[nx + seq_len(p)]
# Generate future innovations if missing
if(!(".innov" %in% names(new_data))){
if(bootstrap){
Expand Down

0 comments on commit 77a561b

Please sign in to comment.