inla.marginal.fix / inla.smarginal /inla.zmarginal error / issue

107 views
Skip to first unread message

Jae Choi

unread,
Feb 19, 2022, 8:08:46 AM2/19/22
to R-inla discussion group
Hello,

Occasionally, when a marginal distribution is very skewed, I get the following error. I wonder if there is a workaround or fix?

An example marginal is attached (m0) which when processed through inla.zmarginal gives and error, or through inla.smarginal provides a single point estimate. This is caused by INLA:::inla.marginal.fix removing all the other elements after spline interpolation.

The sequence to replicate the error is as follows:

m0 = readRDS( "marginal_initial_problem.RDS")
inla.smarginal(m0) # single point
inla.zmarginal(m0) # error:  Error in seq.default(2L, n - 1L, by = 2L) : wrong sign in 'by' argument

# the cause looks to be when inla.marginal.fix operates upon the results of the spline  which I have saved as "m1":

m1 = readRDS( "marginal_spline_problem.RDS")
INLA:::inla.marginal.fix(m1)  # gives just one point

Any help would be appreciated.

Jae
marginal_initial_problem.RDS
marginal_spline_problem.RDS

Helpdesk

unread,
Feb 19, 2022, 8:24:32 AM2/19/22
to Jae Choi, R-inla discussion group

I see your point. as long as one should create a function that represent
, using finite number of points, any density, I guess one can always
crash the function, as least numerically. it seems like this is what you
have done.

if you log-transform m0[,1], then its ok. maybe a good representation is
possible without doing the transformation, but rather keeping it with
the marginal representation and compute the jacobian on the fly. well,
that gives some issues for quantile computations, for which the inverse
is also needed.

the internal concept is that the density can be represented as a
Gaussian times a smooth correction function. In the case where there
exists a lower bound, like variance > 0, then this could cause an issue.
(as you have I guess). 

this is why its always safer to use the
result$internal.marginals.hyperpar, f.ex, which represents
log(precision) and not precision.

I can fix it, then you can come up with a new example which breaks it,
and there we go ;-)

If anyone has a better idea, please let me know, or better, send me a
merge request for a new and better `marginal.R'

H
> --
> You received this message because you are subscribed to the Google
> Groups "R-inla discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to r-inla-discussion...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/28bd34aa-2d2e-4d06-8c52-0a80bd19ca65n%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org
Reply all
Reply to author
Forward
0 new messages