Skip to content

Instantly share code, notes, and snippets.

View SachaEpskamp's full-sized avatar

Sacha Epskamp SachaEpskamp

View GitHub Profile
@SachaEpskamp
SachaEpskamp / APS.R
Last active December 21, 2019 22:55
library("qgraph")
# https://twitter.com/EikoFried/status/1208502815099932685
# Symposia:
Symposia <- list(
# 1.
centrality = c("Eiko Fried", "Ciaran O'Driscoll", "Joshua Buckman", "Donald Robinaugh", "Teague Henry", "Laura Bringmann"),
computational = c("Julian Burger", "Donald Robinaugh", "Lucy Robinson", "Jonas Haslbeck", "Teague Henry", "Sacha Epskamp"),
\documentclass{article}
\usepackage[
paperwidth=27cm,paperheight=13cm,
margin=1cm,
]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
library("bootnet")
library("mvtnorm")
library("qgraph")
# Sample size:
n <- 40000
# Generate 10-node chain graph with positive edges:
net <- genGGM(10, propPositive = 1, constant = 1.1)
library("SEset")
library("qgraph")
library("pcalg")
# For true DAG:
A <- matrix(c(
0,0.25,0.25,
0,0,0,
0,0,0
),3,3,byrow=TRUE)
library("SEset")
library("qgraph")
library("pcalg")
# For true DAG:
A <- matrix(c(
0,0,0,
0.25,0,0,
0,0.25,0
),3,3,byrow=TRUE)
library("parSim")
parSim(
### SIMULATION CONDITIONS
# Vary sample size:
sampleSize = c(250, 500, 1000),
# Vary missingness:
missing = c(0, 0.1, 0.25),
library("parSim")
parSim(
### SIMULATION CONDITIONS
# Vary sample size:
sampleSize = c(250, 500, 1000),
# Vary missingness:
missing = c(0, 0.1, 0.25),
compareNetworks <- function(true,est, directed = FALSE){
cor0 <- function(x,y,...){
if (sum(!is.na(x)) < 2 || sum(!is.na(y)) < 2 || sd(x,na.rm=TRUE)==0 | sd(y,na.rm=TRUE) == 0){
return(0)
} else {
return(cor(x,y,...))
}
}
bias <- function(x,y) mean(abs(x-y),na.rm=TRUE)
# Install from github:
devtools::install_github("sachaepskamp/qgraph")
library("qgraph")
# Example network to play with:
# Load data:
library("psychTools")
data(bfi)
# Compute polychoric correlations:
# Packages needed:
library("qgraph")
library("dplyr")
# Create a deck:
createDeck <- function(){
data.frame(
card = 1:60,
type = rep(c("land","spell","spell"), length = 60)
)