Skip to content

Instantly share code, notes, and snippets.

View SachaEpskamp's full-sized avatar

Sacha Epskamp SachaEpskamp

View GitHub Profile
# Input:
payout <- 35
winSpaces <- 1
allSpaces <- 37
bet <- 10
# Probability:
p <- winSpaces / allSpaces
# Expected value:
library("qgraph")
library("bootnet")
# Number of nodes:
nNode <- 10
# Make a list with intervals:
intervals <- replicate(nNode,sort(runif(2,0.5,1)),simplify = FALSE)
# Rescale intervals so they represent difference:
library("qgraph")
library("bootnet")
set.seed(1)
# Number of nodes:
nNode <- 10
# random point estimates:
pointests <- runif(nNode,0,1)
# Load network:
library("maps")
library("qgraph")
map("world", fill=TRUE, col="white", bg="lightblue", ylim=c(-60, 90), mar=c(0,0,0,0))
# Some network with 4 nodes:
Adj <- matrix(1,4,4)
# Layout using coordinates:
# Packages needed:
library("qgraph")
library("dplyr")
# Create a deck:
createDeck <- function(){
data.frame(
card = 1:60,
type = rep(c("land","spell","spell"), length = 60)
)
# Install from github:
devtools::install_github("sachaepskamp/qgraph")
library("qgraph")
# Example network to play with:
# Load data:
library("psychTools")
data(bfi)
# Compute polychoric correlations:
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)
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),
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)