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 parSim_example_psychonetrics_2
library("parSim")
parSim(
### SIMULATION CONDITIONS
# Vary sample size:
sampleSize = c(250, 500, 1000),
# Vary missingness:
missing = c(0, 0.1, 0.25),
View parSim_example_psychonetrics_1.R
library("parSim")
parSim(
### SIMULATION CONDITIONS
# Vary sample size:
sampleSize = c(250, 500, 1000),
# Vary missingness:
missing = c(0, 0.1, 0.25),
View compareNetworks.R
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)
View ggraph_example.R
# Install from github:
devtools::install_github("sachaepskamp/qgraph")
library("qgraph")
# Example network to play with:
# Load data:
library("psychTools")
data(bfi)
# Compute polychoric correlations:
View magicFuns.R
# Packages needed:
library("qgraph")
library("dplyr")
# Create a deck:
createDeck <- function(){
data.frame(
card = 1:60,
type = rep(c("land","spell","spell"), length = 60)
)
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
You can’t perform that action at this time.