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) Thresholds <- read.csv('http://sachaepskamp.com/files/thr.csv')[,-1] # Transform to -1 and 1: trans <- LinTransform(trueNetwork, Thresholds, from = c(0,1),to=c(-1,1)) # Estimate the distribution: startdistribution <- CURDIST <- IsingLikelihood(trans$graph, trans$thresholds, beta = 1, responses = c(-1,1)) # Compute layout: Layout <- qgraph(trueNetwork, layout = "spring", DoNotPlot=TRUE)$layout # Current state (-1 is off, 0 is unknown, 1 is on) CUR_STATE <- rep(0, ncol(trueNetwork)) # Compute last means: P <- startdistribution$Probability nodes <- as.matrix(startdistribution[,-1]) nodes[nodes==-1] <- 0 LAST_MEANS <- as.vector(t(nodes) %*% P)