Init

library(kirkegaard)
## Loading required package: tidyverse
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.4     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: magrittr
## 
## 
## Attaching package: 'magrittr'
## 
## 
## The following object is masked from 'package:purrr':
## 
##     set_names
## 
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
## 
## 
## Loading required package: weights
## 
## Loading required package: Hmisc
## 
## 
## Attaching package: 'Hmisc'
## 
## 
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## 
## 
## The following objects are masked from 'package:base':
## 
##     format.pval, units
## 
## 
## Loading required package: assertthat
## 
## 
## Attaching package: 'assertthat'
## 
## 
## The following object is masked from 'package:tibble':
## 
##     has_name
## 
## 
## Loading required package: psych
## 
## 
## Attaching package: 'psych'
## 
## 
## The following object is masked from 'package:Hmisc':
## 
##     describe
## 
## 
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## 
## 
## 
## Attaching package: 'kirkegaard'
## 
## 
## The following object is masked from 'package:psych':
## 
##     rescale
## 
## 
## The following object is masked from 'package:assertthat':
## 
##     are_equal
## 
## 
## The following object is masked from 'package:purrr':
## 
##     is_logical
## 
## 
## The following object is masked from 'package:base':
## 
##     +
load_packages(
  MASS,
  tidymodels
)
## 
## Attaching package: 'MASS'
## 
## The following object is masked from 'package:dplyr':
## 
##     select
## 
## ── Attaching packages ────────────────────────────────────── tidymodels 1.3.0 ──
## ✔ broom        1.0.7     ✔ rsample      1.2.1
## ✔ dials        1.4.0     ✔ tune         1.3.0
## ✔ infer        1.0.7     ✔ workflows    1.2.0
## ✔ modeldata    1.4.0     ✔ workflowsets 1.1.0
## ✔ parsnip      1.3.1     ✔ yardstick    1.3.2
## ✔ recipes      1.1.1     
## ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
## ✖ psych::%+%()             masks ggplot2::%+%()
## ✖ scales::alpha()          masks psych::alpha(), ggplot2::alpha()
## ✖ recipes::averages()      masks kirkegaard::averages()
## ✖ scales::discard()        masks purrr::discard()
## ✖ recipes::discretize()    masks kirkegaard::discretize()
## ✖ magrittr::extract()      masks tidyr::extract()
## ✖ dplyr::filter()          masks stats::filter()
## ✖ recipes::fixed()         masks stringr::fixed()
## ✖ assertthat::has_name()   masks tibble::has_name()
## ✖ kirkegaard::is_logical() masks purrr::is_logical()
## ✖ dplyr::lag()             masks stats::lag()
## ✖ MASS::select()           masks dplyr::select()
## ✖ magrittr::set_names()    masks purrr::set_names()
## ✖ yardstick::spec()        masks readr::spec()
## ✖ Hmisc::src()             masks dplyr::src()
## ✖ recipes::step()          masks stats::step()
## ✖ Hmisc::summarize()       masks dplyr::summarize()
## ✖ parsnip::translate()     masks Hmisc::translate()
#override functions
select = dplyr::select

theme_set(theme_bw())

options(
    digits = 3
)

Functions

#function to simulate data
# Set seed for reproducibility
set.seed(1)

sim_autocor_mvn_data = function(n, rho, p) {
  # Number of variables
  n_vars <- p
  
  # Create the covariance matrix
  cov_matrix <- matrix(0, nrow = n_vars, ncol = n_vars)
  
  # Fill the covariance matrix with decaying correlations
  for (i in 1:n_vars) {
    for (j in 1:n_vars) {
      # Correlation decreases with power of distance
      cov_matrix[i,j] <- rho^(abs(i-j))
    }
  }
  
  # Diagonal should be 1 (variance of each variable)
  diag(cov_matrix) <- 1
  
  # Verify the matrix is positive definite
  # If not, the multivariate normal simulation might fail
  if (!all(eigen(cov_matrix)$values > 0)) {
    stop("Covariance matrix is not positive definite")
  }
  
  # Generate multivariate normal data
  # Using MASS package (install if needed: install.packages("MASS"))
  n_samples <- n  # Number of observations
  data <- mvrnorm(n = n_samples, 
                  mu = rep(0, n_vars),  # Mean of zero for each variable
                  Sigma = cov_matrix)
  
  # Convert to data frame
  data_df <- as.data.frame(data)
  colnames(data_df) <- paste0("V", 1:n_vars)
  
  data_df
}

#test
sim_autocor_mvn_data(1000, 0.5, 10) %>% GG_heatmap(reorder_vars = F)

sim_autocor_mvn_data(1000, 0.8, 15) %>% GG_heatmap(reorder_vars = F)

#convert data to alleles, 0, 1, or 2 using random thresholds
convert_to_alleles = function(x, thresholds = NULL) {
  #if no thresholds given, assume evenly spaced
  if (is.null(thresholds)) {
    x2 = map_df(x, \(v) {
      cut(v, breaks = 3, labels = 0:2) %>% as.character() %>% as.numeric()
    })
  } else {
    x2 = map2_df(x, thresholds, \(v, t) {
      cut(v, breaks = c(-Inf, sort(t), Inf), labels = 0:2) %>% as.character() %>% as.numeric()
    })
  }
  
  x2
}

#test
sim_autocor_mvn_data(1000, 0.9, 100) %>% convert_to_alleles() %>% GG_heatmap(reorder_vars = F, add_values = F)

GG_save("figs/cormat_example.png")

sim_autocor_mvn_data(1000, 0.8, 10) %>% convert_to_alleles(thresholds = map(1:10, ~rnorm(2))) %>% map_df(as.numeric) %>% colMeans()
##    V1    V2    V3    V4    V5    V6    V7    V8    V9   V10 
## 0.579 1.618 0.378 0.702 0.985 1.168 1.479 1.244 0.725 0.774
sim_autocor_mvn_data(1000, 0.8, 10) %>% convert_to_alleles(thresholds = map(1:10, ~rnorm(2))) %>% GG_heatmap(reorder_vars = F)

#determine model cv r2 using tidymodels
model_cv_r2 = function(n, rho, p, thresholds, v = 11, noise_sd, cv_repeats = 1, quietly = F) {

  #simulate data
  data = sim_autocor_mvn_data(n, rho, p)
  
  #convert to alleles
  data2 = convert_to_alleles(data, thresholds) %>% map_df(as.numeric)
  
  #make y, unscaled
  data2$y = (as.matrix(data2) %*% rnorm(p, 0, 0.5)) %>% as.numeric()
  
  #standardize it
  y_noise_free = data2$y %>% scale() %>% as.numeric()
  
  #add noise
  data2$y = y_noise_free + rnorm(n, 0, noise_sd)
  
  #create model
  model = linear_reg() %>%
    set_engine("lm") %>%
    set_mode("regression")
  
  #create recipe
  recipe = recipe(y ~ ., data = data2)
  
  #create workflow
  wf = workflow() %>%
    add_recipe(recipe) %>%
    add_model(model)
  
  #cv splits
  data2_cv = vfold_cv(data2, v = v, repeats = cv_repeats)
  
  #cross validate
  if (!quietly) {
    res = wf %>%
    fit_resamples(
      resamples = data2_cv,
    ) %>%
    collect_metrics()
  } else {
    res = suppressMessages(suppressWarnings(wf %>%
    fit_resamples(
      resamples = data2_cv,
    ) %>%
    collect_metrics())) 
  }
  

  #return mean r2
  res %>%
    filter(.metric == "rsq") %>%
    summarise(
      model_r2 = mean(mean)
      ) %>% 
    mutate(
      n = n, 
      rho = rho, 
      p = p, 
      np_ratio = data2_cv$splits[[1]]$in_id %>% length() / p,
      thresholds = thresholds, 
      v = v, 
      noise_sd = noise_sd, 
      true_r2a = 1/(1 + noise_sd^2), 
      true_r2e = cor(y_noise_free, data2$y)^2,
      r2_frac = model_r2 / true_r2e
      # model = list(lm(y ~ ., data = data2))
    )
}

Simulations

#run model sim
res1 = model_cv_r2(
  n = 110 * 10,
  v = 11,
  rho = 0.9,
  p = 100,
  thresholds = NULL,
  noise_sd = 1.5,
  quietly = T
)
res1
#run across many pars
set.seed(1)
sim_grid = expand_grid(
  rho = c(0.1, 0.5, 0.8, 0.9),
  n = c(110) * c(1, 2, 3, 5, 10),
  noise_sd = c(0.5, 1, 1.5, 2),
) %>% 
  #duplicate rows 10 times
  slice(rep(1:n(), each = 10))

#results
res = sim_grid %>%
  mutate(
    p = 100,
    thresholds = NULL,
    v = 11
  ) %>%
  pmap_dfr(model_cv_r2, thresholds = NULL)
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x4There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x4There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x4There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x9There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x5There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x10There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x6There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x2There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x8There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x1There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11There were issues with some computations   A: x11
## → A | warning: prediction from rank-deficient fit; consider predict(., rankdeficient="NA")
## There were issues with some computations   A: x3There were issues with some computations   A: x7There were issues with some computations   A: x11
res_means = res %>%
  group_by(n, rho, noise_sd) %>%
  summarise(
    model_r2 = mean(model_r2),
    true_r2a = mean(true_r2a),
    true_r2e = mean(true_r2e),
    r2_frac = mean(r2_frac),
    np_ratio = mean(np_ratio)
  ) %>% ungroup()
## `summarise()` has grouped output by 'n', 'rho'. You can override using the
## `.groups` argument.
#investigate results
res %>% 
  ggplot(aes(np_ratio, r2_frac, color = factor(rho))) +
  geom_point() +
  geom_line(data = res_means) +
  scale_x_continuous(breaks = unique(res$np_ratio)) +
  facet_wrap(~round(true_r2a, 2)) +
  labs(
    x = "Cases per predictor ratio",
    y = "Model R2 / True R2e",
    color = "rho (adjacent autocor.)"
  )

GG_save("figs/results.png")

Meta

#versions
write_sessioninfo()
## R version 4.4.3 (2025-02-28)
## Platform: x86_64-pc-linux-gnu
## Running under: Linux Mint 21.1
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_DK.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_DK.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_DK.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Europe/Brussels
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] yardstick_1.3.2       workflowsets_1.1.0    workflows_1.2.0      
##  [4] tune_1.3.0            rsample_1.2.1         recipes_1.1.1        
##  [7] parsnip_1.3.1         modeldata_1.4.0       infer_1.0.7          
## [10] dials_1.4.0           scales_1.3.0          broom_1.0.7          
## [13] tidymodels_1.3.0      MASS_7.3-64           kirkegaard_2025-03-12
## [16] psych_2.4.12          assertthat_0.2.1      weights_1.0.4        
## [19] Hmisc_5.2-2           magrittr_2.0.3        lubridate_1.9.4      
## [22] forcats_1.0.0         stringr_1.5.1         dplyr_1.1.4          
## [25] purrr_1.0.4           readr_2.1.5           tidyr_1.3.1          
## [28] tibble_3.2.1          ggplot2_3.5.1         tidyverse_2.0.0      
## 
## loaded via a namespace (and not attached):
##  [1] Rdpack_2.6.2        mnormt_2.1.1        gridExtra_2.3      
##  [4] rlang_1.1.5         furrr_0.3.1         compiler_4.4.3     
##  [7] gdata_3.0.1         systemfonts_1.2.1   vctrs_0.6.5        
## [10] lhs_1.2.0           pkgconfig_2.0.3     shape_1.4.6.1      
## [13] fastmap_1.2.0       backports_1.5.0     labeling_0.4.3     
## [16] rmarkdown_2.29      prodlim_2024.06.25  tzdb_0.4.0         
## [19] nloptr_2.1.1        ragg_1.3.3          xfun_0.51          
## [22] glmnet_4.1-8        jomo_2.7-6          cachem_1.1.0       
## [25] jsonlite_1.9.1      pan_1.9             parallel_4.4.3     
## [28] cluster_2.1.8       R6_2.6.1            bslib_0.9.0        
## [31] stringi_1.8.4       parallelly_1.42.0   boot_1.3-31        
## [34] rpart_4.1.24        jquerylib_0.1.4     Rcpp_1.0.14        
## [37] iterators_1.0.14    knitr_1.49          future.apply_1.11.3
## [40] base64enc_0.1-3     Matrix_1.7-2        splines_4.4.3      
## [43] nnet_7.3-20         timechange_0.3.0    tidyselect_1.2.1   
## [46] rstudioapi_0.17.1   yaml_2.3.10         timeDate_4041.110  
## [49] codetools_0.2-19    listenv_0.9.1       lattice_0.22-5     
## [52] withr_3.0.2         evaluate_1.0.3      foreign_0.8-88     
## [55] future_1.34.0       survival_3.8-3      pillar_1.10.1      
## [58] mice_3.17.0         checkmate_2.3.2     foreach_1.5.2      
## [61] reformulas_0.4.0    generics_0.1.3      hms_1.1.3          
## [64] munsell_0.5.1       minqa_1.2.8         gtools_3.9.5       
## [67] globals_0.16.3      class_7.3-23        glue_1.8.0         
## [70] tools_4.4.3         data.table_1.17.0   lme4_1.1-36        
## [73] gower_1.0.2         grid_4.4.3          rbibutils_2.3      
## [76] ipred_0.9-15        colorspace_2.1-1    nlme_3.1-167       
## [79] htmlTable_2.4.3     Formula_1.2-5       cli_3.6.4          
## [82] DiceDesign_1.10     textshaping_1.0.0   lava_1.8.1         
## [85] gtable_0.3.6        GPfit_1.0-8         sass_0.4.9         
## [88] digest_0.6.37       farver_2.1.2        htmlwidgets_1.6.4  
## [91] htmltools_0.5.8.1   lifecycle_1.0.4     hardhat_1.4.1      
## [94] mitml_0.4-5         sparsevctrs_0.3.0
#write data to file for reuse
# d %>% write_rds("data/data_for_reuse.rds")

#OSF
if (F) {
  library(osfr)
  
  #login
  osf_auth(readr::read_lines("~/.config/osf_token"))
  
  #the project we will use
  osf_proj = osf_retrieve_node("https://osf.io/XXX/")
  
  #upload all files in project
  #overwrite existing (versioning)
  osf_upload(
    osf_proj,
    path = c("data", "figures", "papers", "notebook.Rmd", "notebook.html", "sessions_info.txt"), 
    conflicts = "overwrite"
    )
}