Skip to content

Instantly share code, notes, and snippets.

@dfeng
Created November 17, 2015 16:49
Show Gist options
  • Select an option

  • Save dfeng/978a4985cbdde1a6bc48 to your computer and use it in GitHub Desktop.

Select an option

Save dfeng/978a4985cbdde1a6bc48 to your computer and use it in GitHub Desktop.
Body of the Paper
setwd("/Users/dfeng/Documents/Work/Research/YINS/Negative Ties/Code")
source('init.R')
dat <- data.frame(
id=1:n.graphs,
standard=numeric(n.graphs),
se=numeric(n.graphs),
stratified=numeric(n.graphs)
)
for (i in 1:n.graphs) {
Nsim <- 10^4
# Initialize
g <- graph.u[[i]]
weights <- edge_attr(g, "weight")
ecount <- ecount(g)
triads <- GetTriads(g)
if (g$n.neg < 5) {
dat[i,-1] <- NA
next
}
# TEST 1: Standard
standard <- PermuteSigns(triads, weights, Nsim, GetTriadCount, type=1)
dat$standard[i] <- Signif(standard, `>=`)
# TEST 2: SE
se <- PermuteSigns(triads, weights, Nsim, GetMeanTriadCount, ecount=ecount, neg.only=TRUE)
dat$se[i] <- Signif(se, `>=`)
# TEST 3: Stratified
stratified <- StratifiedPermute(triads, weights, ecount, Nsim, GetTriadCount, type=2)
dat$stratified[i] <- Signif(stratified, `<=`)
}
system("say Your Code is Done")
pval <- gtools::stars.pval
Vectorize(pval)(dat[,-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment