-
I currently face the issue of defining an additive linear predictor for the location with fixed and smooth effects in liesel. I use the lpred_loc_fn = lambda x, beta, smooth_1: jnp.dot(x, beta) + smooth_1
lpred_loc_calc = lsl.Calc(lpred_loc_fn, x=X, beta=beta, smooth_1=smooth_group_1["smooth"])
lpred_loc = lsl.Var(lpred_loc_calc, name="lpred_loc") where gb = lsl.GraphBuilder().add(response)
gb.add_groups(smooth_group_1) Is this the intended way of defining an additive linear predictor in |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hi @Seb-Lorek, thanks for your question! 😊 The code you use looks to me like it would work. You are using the One thing you could do is more clearly separate the linear part and the nonlinear part with a setup like this: x_lin = ... # the design matrix for the linear effect
x_lin_node = lsl.Obs(x_lin, name="x_lin")
coef_lin = lsl.Param(..., name="beta_lin")
smooth_lin_calc = lsl.Calc(jnp.dot, x_lin, coef_lin)
smooth_lin = lsl.Var(smooth_lin_calc, name="smooth_lin")
smooth_1 = ... # defined in your code
location_calc = lsl.Calc(lambda *args: sum(args), smooth_lin, smooth_1) # corrected sum(*args) to sum(args)
predictor_location = lsl.Var(location_calc, name="predictor_location") It will lead to a graph that looks like this: But that is more of a maintainability / code organization suggestion. As I said, I think your code should work fine. |
Beta Was this translation helpful? Give feedback.
-
Maybe also one general suggestion would be to create more general tutorials on |
Beta Was this translation helpful? Give feedback.
Hi @Seb-Lorek, thanks for your question! 😊
The code you use looks to me like it would work. You are using the
lsl.Calc
class exactly like it is intended to be used, by providing the function that you need to be executed. It is indeed possible to use theDistRegBuilder
for this, but since it is not well-documented at the moment, let's not get into that here.One thing you could do is more clearly separate the linear part and the nonlinear part with a setup like this: