4
$\begingroup$

What aspects do I need to consider when plotting a smooth curve with the LOESS method (geom_smooth) using predicted means from a linear mixed model? My data consists of longitudinal psychological scale scores across 12 timepoints. I treated the timepoints as 12 separate levels of a factor.

I hope to show how psychological symptoms fluctuate during a period. In my data, for example, using the smooth curve (LOESS), one type of these symptoms reduced, but another initially decreased and posteriorly increased. Furthermore, I hope to handle the missing data. When I ran a smooth considering all data, the confidence intervals were very high, seem an imprecise model due to my considerable missing data. I used LOESS due to a low number of observations since I considered the predicted means from LMM of each time point (the time points were treated as factor levels). Would be very important to my data analysis the graphical representation of these symptoms.

$\endgroup$
2
  • $\begingroup$ Welcome to Cross Validated! How did you handle the 12 timepoints in your model: did you treat them as 12 separate levels of a factor, or did you model time as some continuous function, for example as a regression spline? Please provide that information by editing the question, as comments are easy to overlook and can be deleted. $\endgroup$
    – EdM
    Commented Mar 6 at 21:02
  • $\begingroup$ Thanks! Edited. $\endgroup$
    – ACOM
    Commented Mar 6 at 21:26

1 Answer 1

3
$\begingroup$

The overall idea of using modeled mean values based on the fixed-factor values to illustrate experimental results is fine. That's what the R emmeans package is designed to do, for example. The question is how to display your confidence intervals, which doesn't work well with a loess fit to all the raw data.

One way to proceed could be to show the confidence intervals for the modeled outcome at each time point along with a piecewise-linear display (or perhaps a smooth loess fit) based on the point estimates.

It might be better if you could re-do the modeling with a smooth continuous treatment of time, instead of separately modeling each time point. Chapter 7 of Frank Harrell's Regression Modeling Strategies recommends regression splines along the time axis for longitudinal data. That gives you a pre-smoothed parametric estimate over time with corresponding confidence intervals, and can save you several degrees of freedom versus your 12-level categorical treatment of time. Unless you have reason to believe that there will be discontinuous jumps in outcome between time points, that might represent your results in an even better way.

$\endgroup$
4
  • $\begingroup$ Let me know if I understand correctly. A better representation could be to plot the estimated points and their confidence intervals (using the ggeffect function, for example) along with a smooth curve fitted using LOESS (for this curve, I utilized the geom_smooth function)? In my data, the time points might be associated with significant variations, so I chose to treat them as a factor. $\endgroup$
    – ACOM
    Commented Mar 7 at 15:35
  • 1
    $\begingroup$ @MarcosO.C.Alves if you really think that individual "time points might be associated with significant variations" then it might not be a good idea to do any smoothing at all. Plot the modeled point estimates and confidence intervals, and if anything connect adjacent points in time with straight lines. Whether you do parametrically modeled smoothing with a spline or nonparametric smoothing with loess, you are assuming that there aren't rapid jumps between time points and that the individual time-point values just represent sampling from a smooth distribution across time. $\endgroup$
    – EdM
    Commented Mar 7 at 17:18
  • $\begingroup$ Maybe I didn't express myself well. More specifically, my outcome variable is related to the pandemic period (number of cases), which has evolved in waves. That's why the idea of using some smoothing method to represent it. $\endgroup$
    – ACOM
    Commented Mar 7 at 17:27
  • 1
    $\begingroup$ @MarcosO.C.Alves then you should be able to do smoothing as part of the model itself, typically with a regression spline in time. That should give you much tighter confidence intervals for the modeled estimates than a loess fit (even if you could figure out a way to do loess appropriately with your data set). Regression splines and loess both do smoothing over time. If loess smoothing is appropriate so is a regression spline, which in turn provides some advantages over the nonparametric loess. $\endgroup$
    – EdM
    Commented Mar 7 at 17:52

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.