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")