Re: [r-inla] how to use INLA for segmented regression models

100 views
Skip to first unread message

Helpdesk

unread,
Jul 5, 2022, 5:43:51 PM7/5/22
to Jonathan Simkin, R-inla discussion group

I think you would have to do this conditionally on the break points, or
alternatively, simulate from the break-point model and then for each
sample run inla, and then merge the results (inla.merge(...))


On Tue, 2022-07-05 at 10:18 -0700, Jonathan Simkin wrote:
> Hi there,
>
> I am analyzing trends in annual cancer rates, which is looking for
> multiple break points in the rates over time. Traditionally, cancer
> epidemiologists would use JoinPoint regression program but I've seen
> this carried out in the R package segmented (frequentist) and mcp
> (Bayesian), which is carrying out piece-wise linear regression.
>
> I'm quite interested in the mcp package but I do not know JAGS well
> and was wondering if this could be implemented in INLA.
>
> Any thoughts would be appreciated!
>
> As an example, I see that the mcp package builds the model in the
> following way, with multiple `~`
>
> library(mcp) 
>   # Define the model model = list( 
>   response ~ 1, # plateau  (int_1) 
>  ~ 0 + time, # joined slope (time_2) at cp_1 
>  ~ 1 + time # disjoined slope (int_3, time_3) at cp_2 ) 
>  
> # Get example data and fit it 
> ex = mcp_example("demo") 
> fit = mcp(model, data = ex$data)
> plot(fit)
>
> in INLA, I'm not entirely sure how this would 'translated'.. that is,
> adding new segments to the inla model.. I tried the:
>
> formula1 <- Age.Adj..Rate ~ 0 + Year ( no break points)
> formula2 <- Age.Adj..Rate ~ 0 + Year ~ 0 + Year (1 break point)
>
> linemod1 <- inla(formula1, family="gaussian", data=data)
> linemod2 <- inla( formula2   , family="gaussian", data=data)
>
> but the formula 2 won't work as it does not allow for '~'.
>
> Any help appreciated!
>
> J
> --
> 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/48926e95-5230-4dc6-947d-7ab33a5dae22n%40googlegroups.com
> .

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