# netsimhelpers

`netsimhelpers` provides tools for designing and evaluating simulation studies in network psychometrics. 

## Overview

`netsimhelpers` simplifies simulation studies by providing easy-to-use functions for:

- **Network generation**
  - `genIsing()`: generate Ising networks with controllable density and edge weights
  - `genGVAR()`: generate graphical vector autoregressive (GVAR) models with contemporaneous and temporal networks
  
- **Data simulation**  
  - `GGMsim()`: generate multivariate normal data from Gaussian Graphical Models (GGM)
  
- **Performance evaluation**
  - `evalNet()`: compute 20+ metrics comparing true vs. estimated networks (sensitivity, specificity, correlations, centrality recovery, and more)

## Installation 

You can install the current developmental version in R using the remotes-package:

```r
install.packages("remotes")
remotes::install_github("RiaHoekstra/netsimhelpers")
```

## Example

```r
library(netsimhelpers)
```

### Generate Ising network

```r
ising_net <- genIsing(n_node = 10, inclusion = 0.3)
```

### Simulate data based on a GGM

`netsimhelpers` works seamlessly with existing packages such as `bootnet` for additional network generation:

```r
library(bootnet) # for additional network generation

# Generate GGM using bootnet package
ggm_net <- bootnet::genGGM(Nvar = 6)

# Simulate data based on GGM using netsimhelpers
sim_data <- GGMsim(n_obs = 100, omega = ggm_net)
```

### Generate GVAR network model

```r
# Generate GVAR network using netsimhelpers
true_gvar <- genGVAR(n_node = 5)

# Inspect networks
true_gvar$PCC   # contemporaneous network
true_gvar$PDC   # temporal network
```

### Evaluate network model estimation 

```r
# Generate GGM
true_ggm <- bootnet::genGGM(Nvar = 6)
est_ggm <- true_ggm

# Perfect evaluation
evaluation <- evalNet(true_ggm, est_ggm)
```

### Minimal simulation workflow

```r
library(netsimhelpers)
library(bootnet)
library(graphicalVAR)

# Generate true netwrok model
true_net <- genGVAR(n_node = 5)

# Simulate data based on network model
sim_data <- as.data.frame(graphicalVAR::graphicalVARsim(nTime = 200, beta = true_net$beta, kappa = true_net$kappa))

# Estimate network
est_net <- estimateNetwork(sim_data, default = "graphicalVAR")

# Evaluate recovery
eval_contemp <- evalNet(true_net$PCC, est_net$PCC)
eval_temporal <- evalNet(true_net$PDC, est_net$PDC)
```
