smry_ssnet: Extract Simulation Summaries

View source: R/smry_ssnet.R

smry_ssnetR Documentation

Extract Simulation Summaries

Description

Using the tidyverse to summarize simulation results.

Usage

smry_ssnet(sim.data, output = "raw")

Arguments

sim.data

A data frame containing simulation resuls. The data is intended to be generated from stacking multiple compare_ssnet() outputs in a single data frame.

output

When "raw" outputs the nested data frame along with data frames contiaining means and standard deviations of model fit statistics. When "mean" or "sd" outputs a data frame of the means or standard deviations, respectively, of model fit statistics. Defaults to "raw".

Value

A data frame.

Examples

## number of simulations
M <- 2
## subj/sim
N <- 30
## image resolution for spatial predictors
ir <- c(5, 5)
L <- sim2Dpredictr::chol_s2Dp(im.res = ir, rho = 0.90,
                              corr.structure = "ar1",
                              triangle = "lower")

## generate non-zero parameters with spatial clustering
betas <- sim2Dpredictr::beta_builder(index.type = "ellipse",
                                     w = 2, h = 2,
                                     row.index = 3, col.index = 3,
                                     B.values = 0.5, im.res = ir)
## generate data
set.seed(68741)
for (m in 1:M) {
  datm <- sim2Dpredictr::sim_Y_MVN_X(N = N, dist = "gaussian",
                                     L = L$L, S = L$S,
                                     B = betas$B)

  mod.out.m <- compare_ssnet(
    x = as.matrix(datm[, grep("X.*", names(datm), perl = TRUE)]),
    y = datm$Y, models = c("glmnet", "ss"),
   s0 = seq(0.01, 0.05), nfolds = 3,
   family = "gaussian", model_fit = "all",
   variable_selection = TRUE,
   B = betas$B[-1],
   iar.data = model_info
   )
  if (m > 1) {
    mod.out <- rbind(mod.out, mod.out.m)
  } else {
    mod.out <- mod.out.m
  }
}

## summarize measures of model fitness
smry_ssnet(mod.out)

## just means
smry_ssnet(mod.out, output = "mean")
## just sd
smry_ssnet(mod.out, output = "sd")

jmleach-bst/ssnet documentation built on March 4, 2024, 5:04 p.m.