posterior
posterior copied to clipboard
pareto_khat errors when it should just give a warning
> pareto_khat(c(1e-4,rep(1,999)))
Error in if (ndraws_tail > S/2) { : missing value where TRUE/FALSE needed
> pareto_khat(c(1e-4,rep(1,999)), tail='right')
Error in seq.default(S - ndraws_tail + 1, S) :
'from' must be a finite number
also the following is a bit miseleading warning as 1) all values are finite, 2) smoothing was not requested
pareto_khat(rep(1,999), tail='right')
[1] NA
Warning message:
Input contains infinite or NA values, Pareto smoothing not performed.
I think this occurs because ess_tail(c(1e-4,rep(1,999)) returns NA (due to almost constant draws) in this case so the automatic calculation of relative efficiency ends up as NA, and so does the tail length. Should pareto_khat return NA in this case?
I've started to think that maybe we should drop the relative efficiency adjustment of tail size. It is causing problems in edge cases. Anyway, for constant or almost constant such that tail would be constant, we can return NA, and give a warning
Inconsistent return type
> str(pareto_smooth(rnorm(1000), tail='right', return_k=FALSE))
num [1:1000] -0.136 -2.086 -1.33 -0.801 -0.612 ...
but
> str(pareto_smooth(rep(1,1000), tail='right', return_k=FALSE))
List of 2
$ x : num [1:1000] 1 1 1 1 1 1 1 1 1 1 ...
$ diagnostics: num NA
Warning message:
Input contains infinite or NA values, Pareto smoothing not performed.
This should be fixed now by #314