[R] CEoptim problems

Adelchi Azzalini @zz@||n| @end|ng |rom @t@t@un|pd@|t
Tue Apr 9 16:36:53 CEST 2024


Thanks for the suggestion, Ivan.

The issue has been overcome with a simple change of the code to the form

(is.null(A) || any(is.na(A))

following advice from Peter Dalgard.

However, I have kept a note of the R Inferno reference, for future problems.

Best wishes,

Adelchi


> On 9 Apr 2024, at 12:22, Ivan Krylov <ikrylov using disroot.org> wrote:
> 
> В Tue, 9 Apr 2024 12:04:26 +0200
> Adelchi Azzalini <azzalini using stat.unipd.it> пишет:
> 
>> res <- CEoptim(sumsqrs, f.arg = list(xt), continuous = list(mean =
>> c(0, 0, 0), sd = rep(1,    3), conMat = A, conVec = b), discrete =
>> list(categories = c(298L, 298L), smoothProb = 0.5),    N = 10000, rho
>> = 0.001)
>> 
>> Error in is.null(A) || is.na(A) : 
>>  'length = 18' in coercion to 'logical(1)'
> 
> There is a book titled "The R Inferno" with lots of debugging tips for
> R: https://www.burns-stat.com/documents/books/the-r-inferno/
> 
> Start with a traceback(). Which function gave a matrix to the ||
> operator (which accepts only logical scalars)?
> 
> If traceback is not enough, use options(error = recover). Once the
> error happens, you will be able to inspect local variables inside any
> of the active call frames, which may help understand where did A come
> from and why it was given to the || operator.
> 
> Good luck!
> 
> -- 
> Best regards,
> Ivan



More information about the R-help mailing list