Monotonically increasing RW2

28 views
Skip to first unread message

John Molitor

unread,
May 24, 2025, 2:52:58 PM5/24/25
to R-inla discussion group
Hello,

Suppose I fit a model (using simplified notation):

ER ~ 1 + f(heat,model="rw2")

However, I want the "dose-response" relationship between heat and ER to be monotonically increasing, so if heat increases, the ER value will either stay the same or increase, but not decrease.

Is this possible?

Thanks,

John

John Molitor

unread,
May 24, 2025, 3:05:52 PM5/24/25
to R-inla discussion group
To to follow up on my own post, what I'm really after is a model with a monotonic relationship between heat and ER (as heat goes up ER goes up), but I want the effect of heat to vary by zipcode (zip) with some besag-like spatial smoothing on "intercepts" and "slopes" (effects), similar in spirit to Spatially Varying Coefficient (SVC) models but with a "spline" (RW2) relationship between heat and ER.

Håvard Rue

unread,
May 24, 2025, 3:15:25 PM5/24/25
to John Molitor, R-inla discussion group

there is no way of doing exactly this. the the case you need this, you need to
write something spesific (using 'rgeneric' or 'cgeneric')

essentially, you need to put the coefficients into the hyperparameters and do
the spline, similar to the 'linear regression' example in 'rgeneric'

Best
Havard
> --
> 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, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/f13426f9-60f5-48cf-8b54-b20cc73b511bn%40googlegroups.com
> .

--
Håvard Rue
hr...@r-inla.org

John Molitor

unread,
May 24, 2025, 7:46:36 PM5/24/25
to R-inla discussion group
Suppose I fit a polynomial model, something like:

ER ~ 1 + f(zip0,model="bym2") + heat + f(zip,heat,model="besag") + heat^2 + f(zip2, heat^2,model="besag")

Can I induce a monotonic relationship with this simpler approach?

John

Helpdesk (Haavard Rue)

unread,
May 25, 2025, 12:20:16 PM5/25/25
to John Molitor, R-inla discussion group
If this how you want to use it, then yes.

its important to have

heat + f(zip, heat, ...)

as the besag has default sum-to-zero constraints.

also, you need to make sure 'heat' is centered at zero.

you can also expand it using a increasing function of 'heat', and go along this
line
he...@r-inla.org

Helpdesk (Haavard Rue)

unread,
May 25, 2025, 12:46:25 PM5/25/25
to John Molitor, R-inla discussion group

there is no guarentee that you'll get something increasing though...

you can define something spline-like that is ok, but when you wrap it in the
'besag' framework, then no
Reply all
Reply to author
Forward
0 new messages