Skip to content

Instantly share code, notes, and snippets.

Sacha Epskamp SachaEpskamp

Block or report user

Report or block SachaEpskamp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View qgraphmap.R
# 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:
View pieCIexample.R
library("qgraph")
library("bootnet")
set.seed(1)
# Number of nodes:
nNode <- 10
# random point estimates:
pointests <- runif(nNode,0,1)
View pieRange.R
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:
View Roulette.R
# Input:
payout <- 35
winSpaces <- 1
allSpaces <- 37
bet <- 10
# Probability:
p <- winSpaces / allSpaces
# Expected value:
View evolution.R
library("foreign")
Data <- read.spss("vHB_SESP_Datafile_for_sharing 29.8.15.sav", to.data.frame = TRUE)
# Relabel data:
names(Data) <- gsub("\\.","",names(Data))
# Lavaan model:
mod <- '
f1 =~ SexDifG1 + GenVio1 + UAtt1 + MenUnf1 + SexHorm1 + EvoPsy1
f2 =~ SexDifG2 + GenVio2 + UAtt2 + MenUnf2 + SexHorm2 + EvoPsy2
View Psychonetrics RNM example
# Install psychonetrics:
# devtools::install_github("sachaepskamp/psychonetrics")
library("psychonetrics")
# Set the seed:
set.seed(1)
# Let's simulate some data, 2-factor model with 10 indicators each and residual chain graph.
# Generate factor loadings:
lambda <- matrix(0,20,2)
View ggmFit example
# Needed packages:
library("qgraph")
library("psych")
library("huge")
data(bfi)
# Subset of 2000 to train model on:
bfiTrain <- huge.npn(bfi[1:1000,1:25])
corMat_train <- cor_auto(bfiTrain, missing = "fiml", detectOrdinal = FALSE)
@SachaEpskamp
SachaEpskamp / global.R
Last active Jun 29, 2018
Shiny App change scores Cross-sectional networks
View global.R
library("bootnet")
library("qgraph")
library("dplyr")
library("ggplot2")
library("knitr")
nNodes <- 12
neighborhood <- 2
@SachaEpskamp
SachaEpskamp / app.R
Created Jun 2, 2018
Statcheck web app
View app.R
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
View MeasurementError.R
library(qgraph)
library(bootnet)
net <- genGGM(10)
Sigma <- cov2cor(solve(diag(10) - net))
D <- diag(1, 10) # Change the value here to add or remove measurment error
qgraph(Sigma + D, graph = "pcor")
You can’t perform that action at this time.