You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
check_identifiable() crashes when eigenvalues of a bad "covariance" matrix are complex. The following code handles the situation without blowing up. Might want to add an error message pointing out why the check failed.
check_identifiable() crashes when eigenvalues of a bad "covariance" matrix are complex. The following code handles the situation without blowing up. Might want to add an error message pointing out why the check failed.
check_identifiable <- function(model, path=getwd()){
Check eigendecomposition
fit <- adnuts:::.read_mle_fit(model, path)
hes <- adnuts:::.getADMBHessian(path)
ev <- eigen(hes);
if (any(is.complex(ev$values))){
WhichBad <- which( abs(Im(ev$values)) > .Machine$double.eps);
} else {
WhichBad <- which( ev$values < sqrt(.Machine$double.eps) );
}
if(length(WhichBad)==0){
message( "All parameters are identifiable" )
} else {
## Check for parameters
if(length(WhichBad)==1){
RowMax <- abs(ev$vectors[,WhichBad])
} else {
RowMax <- apply(ev$vectors[, WhichBad], MARGIN=1, FUN=function(vec){max(Mod(vec))} )
}
bad <- data.frame(ParNum=1:nrow(hes), Param=fit$par.names,
MLE=fit$est[1:nrow(hes)],
Param_check=ifelse(RowMax>0.1, "Bad","OK"))
row.names(bad) <- NULL
bad <- bad[bad$Param_check=='Bad',]
print(bad)
return(invisible(bad))
}
}
The text was updated successfully, but these errors were encountered: