[R] R optim() function
Baker, Kieran
k|er@n@b@ker @end|ng |rom kc|@@c@uk
Thu Oct 29 00:03:21 CET 2020
Hi R-Help,
I am using R to do functional outlier detection (using PCA to reduce to 2 dimensions - the functional boxplot methodology used in the Rainbow package), and using Hscv.diag function to calculate the bandwidth matrix where this line of code is run:
result <- optim(diag(Hstart), scv.mat.temp, method = "Nelder-Mead", control = list(trace = as.numeric(verbose)))
Within the optim function, there is a call to an external C function:
.External2(C_optim, par, fn1, gr1, method, con, lower, upper)
Where
Par = (0.339, 0.339),
fn1 = function (diagH)
{
H <- diag(diagH) %*% diag(diagH)
if (default.bflag(d = d, n = n))
scvm <- scv.mat(x.star, H, Gs, binned = binned, verbose = FALSE,
bin.par = bin.par.star, deriv.order = r)
else scvm <- scv.mat(x.star, H, Gs, binned = binned, verbose = FALSE,
deriv.order = r)
return(scvm)
},
gr1 is Null,
method = "Nelder-Mead"
con is a list of 18 items (trace=0, fnscale=1, parscale=(1,1), ...),
lower and upper are -Inf and Inf respectively.
When this is run, it returns an error
Error in chol.default(H) :
the leading minor of order 1 is not positive definite
Has anyone any experience with this error, or know where I can locate the code for the C_optim function to continue trying to find the issue and a work around?
Thanks for any help,
Kieran
[[alternative HTML version deleted]]
More information about the R-help
mailing list