LinTransform | R Documentation |
This function is mainly used to translate parameters estimated with response options set to 0 and 1 to a model in which the response options are -1 and 1, but can be used for any linear transformation of response options.
LinTransform(graph, thresholds, from = c(0L, 1L), to = c(-1L, 1L), a, b)
graph |
A matrix containing an Ising graph |
thresholds |
A vector containing thresholds |
from |
The original response encoding |
to |
The response encoding to transform to |
a |
The slope of the transformation. Overwrites |
b |
The intercept of the transformation. Overwrites |
Sacha Epskamp <sacha.epskamp@gmail.com>
N <- 4 # Number of nodes
# Ising parameters:
Graph <- matrix(sample(0:1,N^2,TRUE,prob = c(0.7, 0.3)),N,N) * rnorm(N^2)
Graph <- pmax(Graph,t(Graph)) / N
diag(Graph) <- 0
Thresh <- -(rnorm(N)^2)
Beta <- 1
p1 <- IsingLikelihood(Graph, Thresh, Beta, c(0,1))
a <- 2
b <- -1
# p2 <- IsingLikelihood(Graph/(a^2), Thresh/a - (b*rowSums(Graph))/a^2, Beta, c(-1,1))
p2 <- IsingLikelihood(LinTransform(Graph,Thresh)$graph,
LinTransform(Graph,Thresh)$thresholds ,
Beta, c(-1,1))
LinTransform
round(cbind(p1[,1],p2[,1]),5)
plot(p1[,1],p2[,1])
abline(0,1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.