Skip to content
Prev 14193 / 20628 Next

Random effects in GAMs

I am now using random effects of GAM to predict crash frequency at
intersections. The family is negative binomial distribution. I wonder if
this term bs="re" can account for both random intercepts and random slopes
effects together?

It is longitudinal data. The number of crashes, traffic volume on major
roads and traffic volume on minor roads are observed repeatedly three years
for each different intersection as below.

crash main.traffic.volume minor.traffic.volume  ID
1 38122 2789 1
0 40216 2930 1
0 41231 3022 1
2 12890 3401 2
3 13241 3211 2
2 13568 3322 2
1 46889 5688 3
2 48232 5843 3
0 52301 6012 3
*... ...         ...         ...*

I wonder if my code below can account for both random intercepts and random
slopes effects together? or only random slopes effects? Any suggestions?
#########################################################################################
gam(crash~s(main.traffic.volume, ID, bs=?re")+s(minor.traffic.volume, ID,
bs="re"), family=nb(),data=mydata3sg)
#########################################################################################

Many thanks!
Julian

On Fri, Feb 12, 2016 at 1:58 PM, Julian Chen <power.julian.chen at gmail.com>
wrote: