0
$\begingroup$

I have a test dataset looking like;

ID Sample Group Week
X1 Sample1 Healthy 0
X1 Sample2 Disease 0
X1 Sample3 Healthy 2
X1 Sample4 Disease 2
X1 Sample5 Healthy 5
X1 Sample6 Healthy 16
X1 Sample7 Disease 16
X2 Sample8 Healthy 0
X2 Sample9 Disease 0
X2 Sample10 Healthy 2
X2 Sample11 Disease 2
X2 Sample12 Healthy 5
X2 Sample13 Disease 5
X2 Sample14 Healthy 16
X2 Sample15 Disease 16
X3 Sample16 Healthy 0
X3 Sample17 Disease 0
X3 Sample18 Healthy 2
X3 Sample19 Disease 2
X3 Sample20 Healthy 5
X3 Sample21 Disease 5
X3 Sample22 Healthy 16
X3 Sample23 Disease 16
X4 Sample24 Disease 0
X4 Sample25 Healthy 2
X4 Sample26 Disease 2
X4 Sample27 Healthy 5
X4 Sample28 Disease 5
X4 Sample29 Healthy 16
X4 Sample30 Disease 16

The ID columns define each subject that paired samples collected from. There are total of four time points; 0, 2, 5, and 16.

As some part of the data were exampled above, I have 200 different log-transformed measurements taken from each paired sites at each time point, but not all subjects have complete sample sets. Assuming the measurements are not following linear trend, can you please suggest (to someone who is pretty new to the GAMs/GAMMs) how can I perform testing whether measurements have significantly different longitudinal trend between healthy and disease groups by taking care of the paired sampling strategy using GAM or GAMMs in R?

PS: I tried some models such as

gam(Measurement1 ~ Group + Week +
            s(ID, bs = 're'),
          data = data, method = 'REML')

but I need some other families to test rather than Gaussian.

$\endgroup$
2
  • $\begingroup$ To clarify: does each ID represent an individual, and the Healthy/Disease Group represent two distinct (anatomical) sites on the same individual? And are there only 4 time points (at most) for each individual? Please provide that information by editing the question directly, as comments on this site are easy to overlook and can be deleted. $\endgroup$
    – EdM
    Commented yesterday
  • $\begingroup$ Edits were made, thank you $\endgroup$
    – eraysahin
    Commented yesterday

1 Answer 1

0
$\begingroup$

You probably don't need a generalized additive model (GAM) for this study.

A smooth in a GAM can nicely handle a nonlinear association between a predictor and an outcome when your knowledge of the subject matter doesn't suggest a particular functional form. For example, if you had a large number of time points varying among subjects, a GAM for time (perhaps in the simple form of a restricted cubic spline) could be a good choice.

The model you propose, however, doesn't even include Week in a GAM smooth term. The way the model is written, you are assuming a strictly linear association between Week and your outcome. Without an interaction between Week and Group, you are further assuming that the only difference between the Group values is in the intercepts, not in the slopes.

As there are only 4 distinct Week values and two Group values in your data, there wouldn't be much to gain here by using a GAM smooth for Week and its interaction with Group. You can include Group and Week as fixed effects, along with a term for their interaction, to capture the fundamental structure of your data.

With such a model and default coding of predictors:

  • the intercept will be the estimated outcome at Week0 for the reference level of Group;
  • the Group coefficient will represent the difference between groups at Week0;
  • the Week coefficients will be the differences from Week0 associated with the other Week values, for the reference level of Group
  • the interaction coefficients will document whether there are differences over time between the healthy and disease groups, evaluating whether the Group difference is significant at each Week.

You do need to handle the within-individual correlations. Instead of the s(ID, bs = 're') term used for that in the gam() function of the R mgcv package, you could proceed instead with a mixed model with random effects for ID, or with a generalized least squares model if you have a reasonably well behaved continuous outcome measure. If you do have a reasonably well behaved continuous outcome measure, you won't need to use a generalized linear model with a family different from Gaussian.

Chapter 7 of Frank Harrell's Regression Modeling Strategies provides a useful overview of longitudinal data analysis. Although the emphasis is on generalized least squares, it nicely outlines the principles and the strengths and weaknesses of different approaches.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.