diff options
-rw-r--r-- | R/estUtil.R | 6 | ||||
-rw-r--r-- | R/estpoly.R | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/R/estUtil.R b/R/estUtil.R index 00404b0..353c100 100644 --- a/R/estUtil.R +++ b/R/estUtil.R @@ -197,14 +197,16 @@ bjGrad <- function(theta,e,dots){ reg <- function(i) { if(nk==0) v <- i-0:(nb-1) else v <- i-nk:nb1 - matrix(c(uout[v,],eout[i-1:nc,],wout[i-1:nd,],-zetaout[i-1:nf,])) + ereg <- if(nc==0) NULL else eout[i-1:nc,] + matrix(c(uout[v,],ereg,wout[i-1:nd,],-zetaout[i-1:nf,])) } X <- t(sapply(n+1:N,reg)) l <- list(X=X,Y=y,e=e) if(!is.null(e)){ - den <- as.numeric(polynom::polynomial(c(1,theta[nb+1:nc]))* + C_params <- if(nc==0) NULL else theta[nb+1:nc] + den <- as.numeric(polynom::polynomial(c(1,C_params))* polynom::polynomial(c(1,theta[nb+nc+nd+1:nf]))) filt1 <- signal::Arma(b=c(1,theta[nb+nc+1:nd]), a=den) diff --git a/R/estpoly.R b/R/estpoly.R index 2648ff3..76686e4 100644 --- a/R/estpoly.R +++ b/R/estpoly.R @@ -455,7 +455,8 @@ bj <- function(z,order=c(1,1,1,1,0), mod_oe <- oe(z,c(nb,nf,nk)) v <- resid(mod_oe); zeta <- matrix(predict(mod_oe)) mod_arma <- arima(v,order=c(nd,0,nc),include.mean = F) - theta0 <- matrix(c(mod_oe$sys$B,coef(mod_arma)[nd+1:nc], + C_params <- if(nc==0) NULL else coef(mod_arma)[nd+1:nc] + theta0 <- matrix(c(mod_oe$sys$B,C_params, -coef(mod_arma)[1:nd],mod_oe$sys$F1[-1])) eps <- matrix(resid(mod_arma)) |