# Ideal Settings for Longitudinal Models?

The way I see it, logically speaking - Longitudinal Data (e.g. medical patients being measured repeatedly over a period of time) can have one of two forms:

• Case 1: All patients are measured exactly "n" times
• Case 2: Not all patients are measured exactly "n" times

(Also) Logically speaking, for a similar quality and volume of data - I would imagine that applying Longitudinal Models in Case 1 must be "easier" than applying Longitudinal Models in Case 2. In this context, I imagine that "easier" refers to the (Longitudinal) model estimates "inherently" having better statistical properties such as lower asymptotic variance, higher efficiency and stronger consistency (I could be wrong about this).

As a crude and somewhat unrelated example, it is easier to stack books on top of each other if all books are roughly the same shape and size. If the books begin to vary in shape and size from each other, then this becomes more complicated. And if the books significantly vary in shape sand size from each other, then it becomes even more complicated to stack these books on top of each other. For instance, stacking 10 of the exact same textbooks on top of each other will likely be easier and likely result in a sturdier pile. Stacking 5 books of one size and 5 books of another size on top of each other will be more challenging and be less likely to be as sturdy (e.g. in the previous example, the 10 books of the same size can be stacked in any order and be as sturdy - whereas in this example, only some orderings of the books will somewhat sturdy and most of the orderings will not be as sturdy. For example, stacking the 5 bigger books on the bottom and the 5 smaller books on top will likely result in the sturdiest pile - but randomly stacking these 10 different sized books will less likely to be as sturdy). And if the books are significantly varying in sizes (e.g. stacking encyclopedias, dictionaries, magazines... audio cassette tapes), it will likely be very difficult to stack these books together and the resulting stacks will likely not be very sturdy. All in all, the more similar the books are to one another, the more easier they are to stack - the less similar the books are to one another, the less easier they are to stack.

My Question: Can this same analogy be extended to analyzing Longitudinal Data where all patients are measured the exact same number of times vs. Longitudinal Data where not all patients are measured the exact same number of times? Mathematically, can we somehow show that Longitudinal Models fitted to Longitudinal Data where all patients are measured the exact same number of times will inherently produce "higher quality estimates" compared to Longitudinal Data where all patients are not measured the exact same number of times - or is this just a incorrect fallacy with no theoretical basis?

Thanks!

Using the R programming language, I loaded an (artificially created) Longitudinal Dataset :

# each row represents an a unique medical patient and each column represents the same variable being measured at 10 different points in time

library(longitudinalData)
data(artificialLongData)


I then randomly removed observations throughout this dataset (replaced them with NA) to represent some patients being measured less frequently than other patients:

    # First Dataset : All Patients With Equal Measurements
first_dataset = artificialLongData

id    t0    t1    t2    t3    t4    t5    t6    t7    t8    t9   t10
1 s1  3.82  2.42 -1.85 -2.05  1.01  1.56  0.34  0.52 -0.06 -1.09  0.44
2 s2 -4.88 -2.95 -2.38  3.73 -2.77  1.72 -0.99 -0.70  0.15  2.38 -0.72
3 s3  0.57 -0.86  1.46 -2.04 -1.18  4.89 -3.94  0.50  4.90 -0.52  1.52
4 s4 -3.83 -1.22  0.17 -0.22 -3.05 -0.74  1.93  1.85 -3.93 -2.91 -1.13
5 s5 -3.99 -2.82 -2.13 -4.29 -2.33 -0.79 -0.86 -6.23 -8.13 -8.53 -0.87
6 s6  6.67  5.87  8.45  4.80  3.78  4.18  4.16  2.10  3.14  3.46  5.49

# Second Dataset : Some Patients (10%) are Measured Less Frequently

id = first_dataset[,1]
t10 = first_dataset[,12]

second_dataset = first_dataset[,-c(1,12)]

second_dataset = as.data.frame(lapply(second_dataset, \(x) replace(x, sample(length(x), .1*length(x)), NA)))

second_dataset = cbind(id, second_dataset, t10)

id    t0    t1    t2    t3    t4    t5    t6    t7   t8    t9   t10
1 s1  3.82  2.42 -1.85 -2.05    NA    NA    NA    NA   NA    NA  0.44
2 s2    NA    NA -2.38  3.73    NA    NA -0.99 -0.70   NA    NA -0.72
3 s3    NA -0.86    NA    NA    NA  4.89    NA    NA   NA -0.52  1.52
4 s4 -3.83    NA  0.17 -0.22    NA -0.74  1.93    NA   NA -2.91 -1.13
5 s5    NA -2.82 -2.13 -4.29 -2.33 -0.79    NA -6.23   NA    NA -0.87
6 s6  6.67    NA    NA    NA  3.78    NA  4.16    NA 3.14    NA  5.49

# Third Dataset : Many Patients (50%) are Measured Less Frequently

id = first_dataset[,1]
t10 = first_dataset[,12]

third_dataset = first_dataset[,-c(1,12)]

third_dataset = as.data.frame(lapply(third_dataset, \(x) replace(x, sample(length(x), .5*length(x)), NA)))

third_dataset = cbind(id, third_dataset, t10)

id    t0    t1    t2    t3    t4    t5    t6    t7    t8    t9   t10
1 s1    NA  2.42 -1.85    NA  1.01  1.56  0.34    NA -0.06 -1.09  0.44
2 s2    NA -2.95    NA    NA -2.77  1.72    NA -0.70    NA  2.38 -0.72
3 s3  0.57    NA    NA -2.04 -1.18  4.89 -3.94    NA  4.90    NA  1.52
4 s4 -3.83    NA    NA    NA -3.05    NA  1.93  1.85 -3.93 -2.91 -1.13
5 s5    NA    NA -2.13 -4.29 -2.33 -0.79    NA    NA -8.13 -8.53 -0.87
6 s6  6.67    NA    NA  4.80    NA  4.18    NA  2.10    NA  3.46  5.49

#visualization source: https://github.com/jevgenij-p/blog/blob/master/Missing%20Values%20Plot/MissingValues.R and https://jev-pankov.com/2017/11/15/visualize-missing-values-in-r/a


Suppose we are interested in fitting a Longitudinal Regression Model to these 3 datasets for predicting the value of "t10" for each patient. Although in my mind this is very a logical and natural result (it will be easier to "adapt" the longitudinal regression model to "fuller datasets" compared to the "emptier datasets) - can we somehow "mathematically prove" that in general, the properties of the Longitudinal Regression Models on data with conditions resembling the first dataset will be necessarily be "better" (e.g. lower asymptotic variance) than models on data with conditions resembling the second dataset, and both of these models will necessarily be "better" than models on data with conditions resembling the third dataset?

Thanks!

There is a simple counterexample to your suggestion. Imagine a case where some units are affected by large measurement error, while others have only small measurement error. It is more statistically efficient to collect more data from the units with greater measurement error than to collect the same amount from each unit.

Although the details depend on the model in question, here's a proof for a simple model. Say you have two patients, each patient's data are normally distributed with a patient-specific mean ($$\mu_1$$ and $$\mu_2$$) and standard deviation ($$\sigma_1$$ and $$\sigma_2$$), and you're interested in estimating the means. The error variance for each patient in this model is $$\frac{\sigma_i^2}{n_i}$$, where $$n_i$$ is the number of observations for patient $$i$$. You can collect $$n = 100$$ observations, and you want to minimise the total error variance, $$\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{100 - n_1}$$, since this should also minimise the expected sum of squared errors.

Let's say $$\sigma_1 = 1$$ and $$\sigma_2 = 4$$. We could find the value of $$n_1$$ that minimises the total error variance using calculus, but let's cheat and just use a computer.

total_squared_error = function(n1, n = 100, s1 = 1, s2 = 4){
(s1^2 / n1) + (s2^2 / (n - n1))
}
plot(total_squared_error,
from = 1, to = 50, xlab = 'Observations for patient 1', ylab = 'Total RSE')


This shows that the lowest expected total squared error is achieved when $$n_1 = 20$$.

optimize(total_squared_error, c(1, 99))

$minimum [1] 19.99999$objective
[1] 0.25

• @ Eoin: thank you for your answer! Could you please write a bit more if you have time? Thank you! Jun 5, 2022 at 17:07
• What else would you like to know? The key point is that it's generally preferable to collect more data from the units that are harder to estimate parameters for, but the underlying maths differ depending on your design and analysis.
– Eoin
Jun 5, 2022 at 18:25