[Rd] Fix for bug in arima function
Patrick Perry
pperry at stern.nyu.edu
Thu May 28 05:19:09 CEST 2015
> I suspect that what we really need is
>
> fitI <- lm(x ~ xreg - 1, na.action = na.omit)
> fit <- if(length(dx) > ncol(dxreg))
> lm(dx ~ dxreg - 1, na.action = na.omit)
> else list(rank = 0L)
> if(fit$rank == 0L) {
> ## Degenerate model. Proceed anyway so as not to break old code
> fit <- fitI
> }
> n.used <- sum(!is.na(resid(fitI))) - length(Delta)
> init0 <- c(init0, coef(fit))
>
> At least that would be the conservative change to get n.used indentical to what it was in 3.0.1
Along the same lines, here’s a solution that avoids the extra call to lm:
fit <- if(length(dx) > ncol(dxreg))
lm(dx ~ dxreg - 1, na.action = na.omit)
else list(rank = 0L)
if(fit$rank == 0L) {
## Degenerate model. Proceed anyway so as not to break old code
fit <- lm(x ~ xreg - 1, na.action = na.omit)
}
isna <- apply(is.na(xreg), 1, any) | is.na(x)
n.used <- sum(!isna) - length(Delta)
init0 <- c(init0, coef(fit))
More information about the R-devel
mailing list