I have just finalised the analysis of a dataset fitting Generalised additive mixed models (GAMMs) with mgcv package in R v3.3.0. But I am having trouble in writing my models into their correct mathematical notations.
I am not an expert in this filed but despite that, I have “understood” how this model works and how to choose which would give the best fit. However, now I am writing a paper and I have to report the models with mathematical notation but I am not sure if I am doing it correctly.

To give you an overview of my design, I am measuring the shape variability of some individuals that has been quantified into a continuous variable (SV my response variable). For each individual I got 5 SV observations from different body parts = PC (categorical) and I got repeated individuals (30) from each of 20 samples sites = SITE (categorical). So what I have are PC and SITE as “completely crossed factors” (just to give you an idea, I know that this definition applies to random effects).
What I wanted to analyse was the variability (SV) for each of the measured body parts (PC) with temperature = TEMP and salinity=SAL (continuous response variables for which I have just ONE value for each of the 20 sampled SITEs) and length = LENGTH (continuous, 1 observation per individual). (only the individual interaction terms are of interest to me)

To sum up the varaibles involved are:

  • SV (response)
  • PC (indipendant categorical, 5 levels, fixed effect)
  • SITE (ind. categorical, 20 levels, random effect)
  • TEMP (ind. continous, ONE value for each SITE) non-linear
  • SAL (ind. continous, ONE value for each SITE) linear
  • LENGTH (ind. continous, one value per observation) linear

This is the model with R (I included just the core of the model):

gamm(SV ~ s(TEMP, by = PC) + SAL*PC + Length*PC,
             random = list(SITE= ~ 1),
             method = "REML", data = xxx)

The mathematical notation should be:

$$ SV_{ijk}\ =\ \alpha_j\ +\ f_j(TEMP_i)\ +\ \beta_{1j} SAL_i\ +\ \beta_{2j} Length_{ik}\ +\ Site_i\ +\ \epsilon_{ijk} $$

SV is the observation from $i^{th}$ =1...20 Site, $j^{th}$=1...5 PC, $k^{th}$ individual, and I fit a smoother for each PC;
in a more "extended" form showing interaction terms

$$ SV_{ijk}\ =\ \alpha\ +\ f(TEMP_i)\ \times PC_j\ +\ \beta_1 SAL_i\ +\ \beta_2 Length_{ik}\ +\ \beta_3 PC_j\\ +\ \beta_4 SAL_{i} \times PC_j\ +\ \beta_5 Length_{ik} \times PC_j\ +\ Site_i\ +\ \epsilon_{ijk} $$

$Site_i\ \sim\ N(0,\sigma^2_{Site})$

$\epsilon_{ijk}\ \sim\ N(0,\sigma^2)$

Are the above mathematical notations correct? Specifically what I don't get is:

  • Is it correct stating $TEMP_i$ if I have just one measure of TEMP per Site, or should it be $TEMP_{ik}$?
  • as a consequence is $Length_{ik}$ correct since I have a measure per individual per site?
  • are the two ways I specify the interaction correct?

Thank you so much in advance for any help and andvise! (and let me know if it is not clear or more info are needed!)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.