andjar / ALASCA

https://andjar.github.io/ALASCA/
10 stars 0 forks source link

Problems with adding random slopes to the model. #13

Closed ElMatko closed 4 months ago

ElMatko commented 5 months ago

Hi Anders,

To familiarize myself with the ALASCA package, I tried to retrieve random slopes from simulated data. Running the script:

** library(lme4) library(data.table) library(ggplot2) library(ALASCA)

df <- fread("[...]/data_long.csv")

res <- ALASCA( df, value ~ time + time:group + (time | sub_id), use_Rfast = FALSE, equal_baseline = FALSE, validate = TRUE, n_validate = 1000, effects = c("time", "time:group", "time+time:group"), scale_function = "sdall" ) **

returns the output:

INFO [2024-06-17 16:47:01] Initializing ALASCA (v1.0.15, 2024-02-07) INFO [2024-06-17 16:47:01] Will use linear mixed models! ERROR [2024-06-17 16:47:01] Cannot use Rfast in this case. Use lme4 with use_Rfast = FALSE instead! Error in private$set_method() :

It works well when I try random intercepts only (1 | sub_id).

Thanks already for the great package! Any further help, working example, or reference is much appreciated!

Cheers Martin

andjar commented 4 months ago

Hi @ElMatko! Thanks for checking out the ALASCA package, I am glad you find it useful. Regarding random slopes: I have to admit that I am not entirely sure how adding random slopes to the model would impact the underlying statistical theory. All the studies I am aware of use random intercept.

The lme4 package supports random intercepts, so it shouldn't be too difficult to implement, but I think I'll wait until it's better known how random slopes will impact validation etc. In the meantime, for your current needs, you might have to rely on lme4 directly. Please let me know if you need assistance getting the coefficients and subjecting them to PCA.

Again, thank you for your feedback. If you have any more questions or need further assistance, feel free to reach out.

Best, Anders