How to get mgcv::gam
to display my actual treatment names in the parametric coefficients intercept names? I just have random letters on them.
Family: quasipoisson
Link function: log
Formula:
weekly_eggs ~ food + s(week) + s(week, by = Ofood) + s(id,
bs = "re")
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.5624 0.2031 -2.769 0.00581 **
food.L 0.1011 0.4086 0.247 0.80473
food.Q 0.5398 0.4076 1.324 0.18594
food.C 0.2136 0.4053 0.527 0.59838
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(week) 6.403 6.403 49.376 < 2e-16 ***
s(week):Ofoodlow 1.000 1.000 0.001 0.976359
s(week):Ofoodmed 1.000 1.000 14.360 0.000167 ***
s(week):Ofoodhigh 2.078 2.078 1.656 0.141125
s(id) 43.669 49.000 12.984 < 2e-16 ***
Confusingly, the smooth terms actually have the treatment names. Before, this problem with the parametric coefficients was fixed by adding an "O" before naming the treatment column, but that seems to not work.
I set all groups to factors before gam
, and also created a new column with the O in front of the treatment column which somehow makes it easier to make the summed smooth curves later.
Any advice...? Still unfamiliar with a lot of the gam
function. I know this isn't reproducible code, but wasn't sure how to do that with this situation.
Code:
df_P_egg_gamm$id = as.factor(df_P_egg_gamm$id)
df_P_egg_gamm$food = as.factor(df_P_egg_gamm$food)
df_P_egg_gamm$Ofood = factor(df_N_P_egg_gamm$food, ordered=T)
egg_gamm_P = gamm(weekly_eggs ~ food + s(week) + s(week, by=Ofood) + s(id, bs="re"), family="quasipoisson",
correlation=corCAR1(form=~week|id), data=df_P_egg_gamm)