Determine significance in time

Hi all,

Im doing analysis on brain connectivity. I have longitudinal data of patients (at least 2 visits up to 5, resulting in 614 data rows for 208 patients) and I am analysing brain connectivity of 87 nodes with the following joint model (to account for attrition) looped over all 87 nodes:

fixed_formula <- as.formula(paste0("scale(", Node, ") ~ AoO + Gender + Scanner_date_check + disease_duration + (disease_duration | patient_number)"))
  survival_formula <- as.formula("Surv(SurvOnsetYears, Dropout) ~ 1")
  joint_model_stan <- stan_jm(
    formulaLong = fixed_formula, 
    dataLong = dat,
    formulaEvent = survival_formula, 
    dataEvent = datsurv,
    time_var = "disease_duration",
    cores = coresnr,
    chains = chainsnr, 
    iter = iterations,  
    refresh = 10000, 
    seed = 12345
  )

In which “Node” is the 614 brain connectivity values for that node.
With this I get out of the 87 nodes an X amount of nodes that show a “significant” decrease in brain connectivity over the disease duration (Long1|disease_duration 2.5-97.5 confidence interval < 0)

But now i would like to find out a pattern of brain connectivity decrease so in a way find out of the significantly decreased nodes, which ones become “significant” earlier in disease_duration and which later.

I have tried the following but this gives no significant points in time at all for the nodes that are “significantly” decreased over time according to the joint_model:

data<-posterior_predict(joint_model, newdata = NULL, draws=10000)
disdur <- dat$disease_duration
predicted <- colMeans(data)  # Mean prediction
predicted_vals_all <- data.frame(
        Disease_duration = disdur,
        Predicted = predicted
      )
predicted_vals_sorted <- predicted_vals_all[order(predicted_vals_all[, 1]), ]
colnames(predicted_vals_sorted) <- c("x", "y")  # Name the columns
polynomial_model <- stan_glm(y ~ poly(x, 1), data = predicted_vals_sorted)
baseline_value <- mean(posterior_predict(polynomial_model, newdata = data.frame(x = 0)))
x_sequence <- seq(0, 10, by = 0.1)
predicted_values <- colMeans(posterior_predict(polynomial_model, newdata = data.frame(x = x_sequence)))
observed_sd <- sd(predicted_vals_sorted$y)
deviations <- abs((predicted_values) - (baseline_value))
threshold <- 2 * observed_sd
exceeding_points <- x_sequence[deviations > threshold]
onset_time <- exceeding_points[1]

Is there something I did wrong or can you give me your opinions on how I would tackle this please?

Thanks in advance!

Hi, @boaz_kalkhoven and welcome to the Stan forums. I updated the tags on your post to indicate this is about rstanarm. For that, we’re probably going to need to hear from @bgoodri.

1 Like