#Given a network and a permuation this function calculates the LOLOG change stats
#after each edge has been considered in the edge permutation scheme
#' @export
#'
#'
lolog_change_stats<- function(net, #the network of interest
s, #The permutations of interest
formula_rhs #rhs formula of model
){
#define network size
n <- network.size(net)
e_obs <- length(net$mel)
if(get.network.attribute(net,"directed")){e<-n*(n-1)
}else{e <- (n)*(n-1)/2}
if(length(s)!= e){stop("permutation is the wrong length")}
#make edge list that we can permute
edges <- combn(seq(1,n),2)
tails = edges[1,][s]-1
heads = edges[2,][s]-1
model <- createCppModel(as.formula(paste("net ~",formula_rhs,sep = "")))
model <- lolog::createLatentOrderLikelihood(as.formula(paste("net ~",formula_rhs,sep = "")),theta = model$thetas())
change_on = model$calcChangeStats(heads,tails)
change_off = lapply(1:length(change_on),function(x){rep(0,length(change_on[[1]]))})
return(change_on)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.