This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nSample <- 100 | |
gender <- sample(c("male","female"),nSample,TRUE) | |
coffee <- pmax(0, | |
round(rnorm(nSample,mean = ifelse(gender=="male",3,2)))) | |
heartrate <- 80 + 20 * coffee + rnorm(nSample, 0, 20) | |
Data2 <- data.frame(gender=gender, coffee = coffee, | |
heartrate = heartrate) | |
head(Data2) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Needs https://www.jcchouinard.com/wget/ | |
pokemon_image <- function(pokemon){ | |
sapply(pokemon,function(p){ | |
tryres <- try({ | |
# URL to image: | |
url <- sprintf("https://img.pokemondb.net/artwork/large/%s.jpg",tolower(p)) | |
# set downlaod method: | |
if (grepl("apple",sessionInfo()$platform)){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("parSim") | |
library("ggplot2") | |
library("tidyr") | |
library("dplyr") | |
res <- parSim( | |
nIndicator = 5, | |
nu_diff = c(0,0.5), | |
sampleSize = c(50, 100,500,1000,5000), | |
reps = 100, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load libraries: | |
library("dplyr") | |
library("psychonetrics") | |
# Read table: | |
data <- read.table("fwbmlqsgavagai.dat") | |
names(data) <- c('fwb1', 'fwb2', 'fwb3', 'fwb4', 'fwb5', | |
'mlqs1', 'mlqs2', 'mlqs3', 'mlqs4', 'mlqs5', | |
'gavagai') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("bootnet") | |
library("qgraph") | |
# This sets the constraint. 1 for normal behavior, higher for more constrained layouts: | |
constrain <- 10 | |
# Three similar networks: | |
net1 <- genGGM(10, p = 0.1, propPositive = 1, nei = 2) | |
net2 <- genGGM(10, p = 0.1, propPositive = 1, nei = 2) | |
net3 <- genGGM(10, p = 0.1, propPositive = 1, nei = 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script contains some functions to automate things: | |
cat("THIS FUNCTION IS OUTDATED, PLEASE SEE https://github.com/SachaEpskamp/RIVMgrowth") | |
# Function to automize dummy encoding: | |
rivm_lgc_dummy <- function( | |
data, # Dataset | |
design, # Design matrix, as in psychonetrics | |
type = c("non-linear","linear"), # Type of analysis to do | |
predictor_var, # Variable name of predictor (only one supported at the moment) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("shiny") | |
library("psychonetrics") | |
library("IsingFit") | |
library("IsingSampler") | |
library("qgraph") | |
# Load networks: | |
trueNetwork <- read.csv('http://sachaepskamp.com/files/weiadj.csv')[,-1] | |
trueNetwork <- as.matrix(trueNetwork) | |
Symptoms <- rownames(trueNetwork) <- colnames(trueNetwork) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
ui <- fluidPage( | |
h4("Click on plot to start drawing, click again to pause. Draw from LEFT to RIGHT"), | |
# sliderInput("mywidth", "width of the pencil", min=1, max=30, step=1, value=10), | |
plotOutput("plot", width = "800px", height = "500px", | |
hover=hoverOpts(id = "hover", delay = 100, delayType = "throttle", clip = TRUE, nullOutside = TRUE), | |
click="click"), | |
actionButton("reset", "RESET DRAWING"), | |
textInput("userid","Write your participant ID"), | |
downloadButton("downloadData", "Download data")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("lavaan") | |
library("psychonetrics") | |
library("dplyr") | |
# Generate data: | |
mod <- ' | |
F1 =~ X1 + X2 + X3 | |
F2 =~ X4 + X5 + X6 | |
F3 =~ X7 + X8 + X9 | |
G =~ F1 + F2 + F3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("psychonetrics") | |
library("psychTools") | |
library("dplyr") | |
data("bfi") | |
# Extraversion and Neuroticism items: | |
data <- bfi[,11:20] | |
# ggm model: | |
mod_ggm <- ggm(data, estimator = "FIML") %>% |
NewerOlder