Hello everyone,

I am currently working on a dataset where I have multiple measurements of the same parameter for each individual at different time points. My goal is to compare the variability in these measurements with the changes observed over time. Specifically, I want to determine whether the changes over time are greater than the measurement variability.

I am considering calculating the standard error of the annual mean change as a measure of the precision of the sample mean. However, I’m unsure how to implement this in my dataset effectively, especially how to combine it for several individuals.

Additionally, I have tried to visualize the problem for one single individual using the R code below. Many thanks for your help in advance!

# Filter for the specific individual and select relevant columns for the parameter

data ← data %>%

filter(ID == “ID”) %>%

select(ExamDate, starts_with(“parameter”))

# Reshape data to long format

long_data ← data %>%

pivot_longer(cols = starts_with(“parameter”),

names_to = “measurement_type”,

values_to = “parameter_value”)

# Calculate mean parameter and standard deviation at each time point

mean_variability_data ← long_data %>%

group_by(ExamDate) %>%

summarise(mean_parameter = mean(parameter_value, na.rm = TRUE),

sd_parameter = sd(parameter_value, na.rm = TRUE),

.groups = ‘drop’)

# Calculate changes and compare with variability

change_data ← mean_variability_data %>%

mutate(mean_change = c(NA, diff(mean_parameter)),

sd_change = c(NA, diff(sd_parameter)),

time_diff = c(NA, diff(as.numeric(ExamDate)))) %>%

mutate(annual_change = mean_change / time_diff * 365,

se_mean = sd_parameter / sqrt(n()))

# Plot mean parameter with SD and mean changes for a single individual

ggplot(mean_variability_data, aes(x = ExamDate)) +

geom_line(aes(y = mean_parameter), color = “blue”, size = 1.2) +

geom_point(aes(y = mean_parameter), color = “blue”, size = 3) +

geom_ribbon(aes(ymin = mean_parameter - sd_parameter,

ymax = mean_parameter + sd_parameter),

fill = “grey”, alpha = 0.3) +

geom_line(data = change_data, aes(y = mean_change), color = “orange”, size = 1, linetype = “dashed”) +

geom_point(data = change_data, aes(y = mean_change), color = “orange”, size = 2) +

labs(title = “Parameter Measurements Over Time with Changes (Single Individual)”,

x = “Exam Date”,

y = “Parameter Value / Mean Change”) +

theme_minimal()