Error in seq.default(xmin, xmax, length.out = n) : 'from' must be a finite number.

217 views
Skip to first unread message

Enyu Tong

unread,
Jun 16, 2024, 9:14:39 AM6/16/24
to R-inla discussion group
Dear respected members of the INLA community,

I have been trying to use the BAPC/INLA package to project age-standardized rates. Below is the code I am using:

if(requireNamespace("INLA", quietly = TRUE)) {
    require(INLA)
    data(FemLCSweden)
    data(FemPYSweden)
    data(whostandard)

    lc_sweden <- APCList(FemLCSweden, FemPYSweden, gf=5)

    result  <- BAPC(lc_sweden, predict=list(npredict=10, retro=TRUE),
        verbose=FALSE, stdweight=whostandard[6:17,2])

    plotBAPC(result, scale=10^5, type="ageSpecProj", showdata=TRUE)

    ## Assume the data for 2000 to 2010 are not observed
    ## (projection results are the same as above)
    FemLCSweden[51:60,] <- NA

    lc_sweden <- APCList(FemLCSweden, FemPYSweden, gf=5)

    result  <- BAPC(lc_sweden, predict=list(npredict=10, retro=FALSE),
        verbose=FALSE, stdweight=whostandard[6:17,2])

    plotBAPC(result, scale=10^5, type="ageSpecProj", showdata=TRUE)
}
However, I keep encountering the error:
Error in seq.default(xmin, xmax, length.out = n) : 'from' must be a finite number.

I have tried multiple attempts to troubleshoot this issue, but it persists. Could you please guide how to resolve this error?

Best regards,
Enyu






Finn Lindgren

unread,
Jun 16, 2024, 9:52:44 AM6/16/24
to Enyu Tong, R-inla discussion group
Hi,
First step is to identify what code is actually throwing the error, as it could be anywhere, including in a package unrelated to inla. The traceback() output after the error can help with that. The seq() function is an extremely commonly used R function…
Finn

On 16 Jun 2024, at 14:14, Enyu Tong <enyuto...@gmail.com> wrote:


--
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/074d7697-0db1-425d-b8ab-eef14a6b4339n%40googlegroups.com.

Helpdesk (Haavard Rue)

unread,
Jun 16, 2024, 6:25:57 PM6/16/24
to Finn Lindgren, Enyu Tong, R-inla discussion group

I would guess there an Inf in the results (a marginal distribution) that cause
this, usually caused to large uncertainty that then sent through the exp()
function
Håvard Rue
he...@r-inla.org

Helpdesk (Haavard Rue)

unread,
Jun 16, 2024, 6:38:12 PM6/16/24
to Finn Lindgren, Enyu Tong, R-inla discussion group

your example runs fine w me. make sure you're using R-4.4 and a recent R-INLA
version
Reply all
Reply to author
Forward
0 new messages