Is the problem the choice of family or the linear model? Have your tried something like a smooth term for example?
fit <- brm(node_length ~ type + s(node_num2, by=type, k=10) + (1|location), data=data_ck_IAA)
From your plot (which looks like a conditional_effects plot from brms) it looks like you are trying to fit a line for each “type” through data where “node_length” and “node_num2” are not related in that way.
Your problem is that you are modeling clearly nonlinear relationships between the response and node_num2 using linear terms. The issue isn’t primarily the family (though it looks like the data might not be homoskedastically Gaussian), but rather the form of the linear predictor. Try fitting a linear predictor that is quadratic in node_num2 or perhaps a linear predictor with still greater flexibility.
This is my first time to use this code. +s(node_num2, by=type, k=10) , where can I learn about it?
and how can I explain this results?
Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept 3.05 0.21 2.63 3.51 1.00 1417 1557
typeIAA -0.03 0.01 -0.04 -0.01 1.00 4751 2166
snode_num2:typeCK_1 6.31 1.01 4.36 8.28 1.00 1917 2277
snode_num2:typeIAA_1 3.36 0.76 1.88 4.84 1.00 2079 2163
Family Specific Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
shape 24.07 0.44 23.23 24.95 1.00 4276 2479
**I think snode_num2:typeCK_1 and snode_num2:typeIAA_1 mean the interaction effect terms, but in the linear model, just one interaction effect terms, that means there are interaction effect when comparing CK or IAA. **
This is a smooth term. Specifically a penalized thin plate regression spline (if I remember correctly that is the default). You can learn a lot about splines from Gavin Simpson’s blog and this excellent post by Tristan Mahr about splines as they are implemented in brms.
The code that you ran fit a smooth term to each ‘type’.
The coefficients of the smooth terms are not very interpretable. See here and here.
You can make predictions for different values of ‘node_num2’ and different levels of ‘type’ and ‘location’. You can also estimate the first derivative of the spline via finite differences if you would like to find the slope of the spline, see here for the concept and here for what you will need from brms, posterior_smooths.
If this isn’t acceptable, then maybe you should think about the relationship between ‘node_length’ and ‘node_num2’ and come up with a more generative explanation that you could fit using the non-linear syntax in brms.