-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Description
cc @robjhyndman - I think this is due a difference in checks of characteristic equation roots between the C++ during optimisation (used in model()
/estimate()
), and the R check during initialisation (used in refit()
)
Lines 503 to 512 in 0f3c42f
# End of easy tests. Now use characteristic equation | |
P <- c(phi * (1 - alpha - gamma), alpha + beta - alpha * phi + gamma - 1, rep(alpha + beta - alpha * phi, m - 2), (alpha + beta - phi), 1) | |
roots <- polyroot(P) | |
# cat("maxpolyroots: ", max(abs(roots)), "\n") | |
if (max(abs(roots)) > 1 + 1e-10) { | |
return(0) | |
} | |
} |
From R, we have P[2] = alpha + beta - alpha * phi + gamma - 1
fable/src/etsTargetFunction.cpp
Lines 280 to 306 in 0f3c42f
// End of easy tests. Now use characteristic equation | |
std::vector<double> op_new(m+2, alpha+beta-alpha*phi); | |
// P <- c(phi*(1-alpha-gamma),alpha+beta-alpha*phi+gamma-1,rep(alpha+beta-alpha*phi,m-2),(alpha+beta-phi),1) | |
op_new[0] = phi*(1-alpha-gamma); | |
op_new[1] = phi*(alpha+beta-alpha*phi+gamma-1); | |
op_new[m] = alpha+beta-phi; | |
op_new[m+1] = 1; | |
Environment base("package:base"); | |
Function polyroot = base["polyroot"]; | |
Function abs = base["abs"]; | |
NumericVector res = abs(polyroot(op_new)); | |
// Rprintf("alpha = %f, beta = %f, gamma = %f, phi = %f, m = %i\n", | |
// alpha, beta, gamma, phi, m); | |
// Rprintf("C: c("); | |
// for(int i=0;i<opr.size();i++) { | |
// Rprintf("%f, ", opr[i]); | |
// } | |
// Rprintf(")\n"); | |
// Rprintf("C_new: c("); | |
//Rprintf("maxpolyroot: %f\n", max); | |
double max_root = max(res); | |
if(max_root > 1+1e-10) return(false); |
From C++ we have op_new[1] = phi*(alpha+beta-alpha*phi+gamma-1)
Which is correct?
Metadata
Metadata
Assignees
Labels
No labels