GithubHelp home page GithubHelp logo

bootnet's People

Contributors

alexchristensen avatar falkcarl avatar mihaiconstantin avatar olivroy avatar paytonjjones avatar sachaepskamp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bootnet's Issues

summary bootnet

Hi,

I would like to ask how can I view the summarized table that is received in the output of the bootnet function in a full presentation or/and with Excel?

Attached is an image to illustrate my question.
picture1

Thank you for your help.
Adva

Problem with Bootstrapping "Error in makePSOCKcluster(nClust)"

I am having an issue with bootstrapping, and I wanted to reach out for your advice. I am attempting to run a network analysis. I have used this code before, and it works fine, until I attempt to bootstrap for stability analyses. Then I get the following error message:

Bootstrapping...
Error in makePSOCKcluster(nClust) :
Cluster setup failed. 3 of 3 workers failed to connect.
In addition: Warning message:
In EBICglassoCore(S = S, n = n, gamma = gamma, penalize.diagonal = penalize.diagonal, :
A dense regularized network was selected (lambda < 0.1 * lambda.max). Recent work indicates a possible drop in specificity. Interpret the presence of the smallest edges with care. Setting threshold = TRUE will enforce higher specificity, at the cost of sensitivity.

Any ideas on how to fix this? I am using Max OSX Catalina, R version 4.0 and R Studio Version 1.3.959.

Error nonparametric bootstrapping- dense network

Hi Sacha,

Getting an error with the strength metric (error below) when doing the nonparametric and case-dropping boostraps on a dense network. I only get the below error when bootstrapping (but I am warned that it is a dense network when estimating the original network). Thanks for your help with this!

Network with lowest lambda selected as best network: assumption of sparsity might be violated.
Computing statistics...
Error in data.frame(name = name, type = "strength", node1 = x[["labels"]], :
arguments imply differing number of rows: 1, 18, 13

ggmGenerator() potential issue when generating ordinal data (i.e., related to #20)

Hi Sacha,

I was looking at issue #20 where you mention that the input argument also needs to be supplied. I agree with that part, but then I am confused about the following scenario:

# Setting things up.
weights <- genGGM(10)
sampler <- ggmGenerator(TRUE, 5)

# Sampling data.
sampler(100, weights)

Running these lines results in:
Error in input$thresholds : $ operator is invalid for atomic vectors.

The sampler functions then looks like this:

function (n, input) {
    if (is.list(input)) {
        if ("graph" %in% names(input)) {
            graph <- input$graph
        }
        else stop("'graph' not in input list.")
        if ("intercepts" %in% names(input)) {
            intercepts <- input$intercepts
        }
        else {
            intercepts <- rep(0, ncol(graph))
        }
    }
    else {
        if (!is.matrix(input)) {
            stop("'input' is not a matrix or list.")
        }
        graph <- input
        intercepts <- rep(0, ncol(graph))
    }
    if (!all(diag(graph) == 0 | diag(graph) == 1)) {
        graph <- cov2cor(graph)
    }
    diag(graph) <- 0
    if (any(eigen(diag(ncol(graph)) - graph)$values < 0)) {
        stop("Precision matrix is not positive semi-definite")
    }
    Sigma <- cov2cor(solve(diag(ncol(graph)) - graph))
    Data <- mvtnorm::rmvnorm(n, sigma = Sigma)

    for (i in 1:ncol(Data)) {
        if (is.null(input$thresholds)) {
            Data[,i] <- as.numeric(cut(Data[,i],sort(c(-Inf,rnorm(5.000000-1),Inf))))
        } else {
            Data[,i] <- as.numeric(cut(Data[,i],sort(c(-Inf,input$thresholds[[i]],Inf))))
        }
    }
    return(Data)
}

I think the error is throwed by the conditional check within the for loop:

for (i in 1:ncol(Data)) {
    if (is.null(input$thresholds)) {
        Data[,i] <- as.numeric(cut(Data[,i],sort(c(-Inf,rnorm(5.000000-1),Inf))))
    } else {
        Data[,i] <- as.numeric(cut(Data[,i],sort(c(-Inf,input$thresholds[[i]],Inf))))
    }
}

Shouldn't it be something like:

if (is.list(input) && !is.null(input$thresholds)) {...} else {...}

which would end up in the following:

for (i in 1:ncol(Data)) {
    if (is.list(input) && !is.null(input$thresholds)) {
        Data[,i] <- as.numeric(cut(Data[,i],sort(c(-Inf,input$thresholds[[i]],Inf))))
    } else {
        Data[,i] <- as.numeric(cut(Data[,i],sort(c(-Inf,rnorm(5.000000-1),Inf))))
    }        
}

Sorry if I miss something obvious here... But if this makes sense I can send a pull request later this week.

Best,
Mihai

Error computing expected influence from node-dropping bootstraps

Hi Sacha,

I'm experiencing a bug in bootnet 1.1 when the case dropping bootstrap is calculating centrality statistics:

Error in checkForRemoteErrors(val) :
one node produced an error: arguments imply differing number of rows: 1, 58, 0

The code I'm using:
boot4b <- bootnet(Network3, nBoots = 20, type = "case", nCores = 4, statistics = c("expectedInfluence", "closeness", "betweenness"))

The error doesn't seem to occur when I don't include type = "case"
In addition, the error doesn't occur when I don't include "expectedInfluence"

Let me know if there's anything else I can provide. Thanks in advance for your help!
Patrick

Issue with EstimateNetwork

When running networks, I updated R, R Studio and all packages but am now getting the error:
Error in estimateNetwork(data, default = c("none", "EBICglasso", "pcor", :
could not find function "estimateNetwork"

When I try to load bootnet, I get the error:
Error: package or namespace load failed for ‘bootnet’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘Epi’

When I try to load Epi, it works but does not show up under my packages, so now the EstimateNetwork function does not work.

netSimulator() Error in eigen(...)

I am trying to create data that are based on different network structures, and then use netSimulator() to test how well different methods perform. One persistant challenge is that I very often receive the error from netSimulator() that "Error in eigen(sigma, symmetric = TRUE) : \n infinite or missing values in 'x'\n".

I have checked a variety of things. E.g., whether the input matrix is not positive definite or singular. And although these things will matter, they are not the sole problem. Here is a reproducible example, I think.

#necessary packages

library(bootnet)
library(BDgraph)
library(matrixcalc)

#function to create matrix for input. Created with help from FB Dynamic modeling group

genmat <- function(p, graph, prob = NULL, class = NULL){
  G <- bdgraph.sim(p = p, graph = graph, prob = prob, class = class, n = 10)
  adj.g <- G$G
  sample <- rgwish( n = 1, adj.g = adj.g, b = 20, D = diag(20, p))
  sam_K <- sample[,,1]
  sigma <- solve( sam_K )
  samcor <- cov2cor(sigma)
  samcor <- as.matrix(forceSymmetric(samcor,uplo="L")) #necessary b/c otherwise it is interpreted as not symmetric.
  
  if (is.positive.definite(samcor) == F) {
    print("Error: Not positive definite")
  } else {
    if (is.singular.matrix(samcor) == T) {
    print("Error: Singular matrix")
  } else {
    return(samcor)
  } }
}

# Estimate a random network to use as input. 40 nodes, probability of connection = .1
genmat.random.1 <- genmat(p = 40, graph = "random", prob = .1)

# Simulate
simres.genmat.random.1    <- netSimulator(input = genmat.random.1,    nCases = c(500, 1000, 2000, 5000), nReps = 10, default = c("cor", "pcor", "EBICglasso"), dataGenerator = ggmGenerator(ordinal = TRUE, nLevels = 7))

simres.genmat.random.1 then contains only error messages for each grouping.
screen shot 2018-03-31 at 11 29 01

Thanks for any insight on this. I am unsure whether this is an issue within netSimulator or on my end, which is why I've posted this here.

installation trouble on macs and with mybinder

Hello,
i've been able -after some trouble- to get bootnet run on my mac. As it often goes with troubleshooting, isolating the root cause is no longer possible - it all hangs together in a complex network... Anyway, what seems to be problematic on my mac and with R was sth. along the g++ compiler.

Now being able to work with bootnet on my Mac, I wanted to share the joy with others and get it to run in the cloud via mybinder.org. However, when firing up virtual machines via binder, i again am running into installation issues that are now even harder to diagnose since everything runs remotely. I haven't been able to find an exact dependency list for bootnet, but one particular think I ran into trouble with was the "car" library. To complicate the matter, the binder only installs R3.4.4, but car is apparently not working with this. However, i thought that bootnet existed already with R3.4.4? Any suggestions are welcome.
Thank you, Ralf.

bootstrapping, empty networks, and corStability

Hello. I have a question regarding the corStability function:
when I bootstrap case-dropping type (total of 487 cases), some permutations of the network return empty, and running corStability results in an error message. I looked at the code, and I was wondering if it is possible for me to bypass it by having the cor0 function return 0 instead of NA?

Error computing betweenness from node-dropping bootstraps

Hi again Sacha!

I have noticed another error when computing centrality statistics from the node-dropping bootstrap, particularly when calculating betweenness centrality of certain bootstraps. I have noticed it in networks of a 'smaller' sample size (e.g. < 50 people). An example of the error is:

Error in lab(Betweenness, Labels) : 'names' attribute [5] must be the same length as the vector [4]

It's doesn't always occur, but it should be reproducible in the following (admittedly, slightly tedious) code:

library("psych")
data(bfi)
repBoots <- function( times ) {
boot <- vector(mode="list", length=times)
for(i in 1:times ) {
boot[[i]] <- bootnet(na.omit(bfi[sample(1:nrow(bfi),runif(1,10,50)),11:15]) ,
nBoots = 25 , type = "node" , default = "EBICglasso")
}
boot
}

repBoots(times=20)

It seems that the betweenness calculations of certain bootstrap networks are returning vector lengths smaller than the number of nodes in those networks?

Thanks again,
Conor

bootnet error messages

I’m using bootnet to estimate a network of ordinal, binary, and continuous variables. Network estimation is fine as far as I can tell:

EDDS_net<-estimateNetwork(EDDS_complete, default = "mgm")

But I get a series of error messages when I attempt to bootstrap for centrality stability

Boot_edds2 <- bootnet(EDDS_net, type = "case", nCores = 1, default = "mgm")

Bootstrapping...
Error in glmnetRequirements(data = data, type = type, weights = weights) :
Please only provide variables with nonzero variance. Variable(s) with zero variance: V14.
Error in glmnetRequirements(data = data, type = type, weights = weights) :
At least 2 events required for each category. Requirement not met for variable(s): NA
Error in glmnetRequirements(data = data, type = type, weights = weights) :
Please only provide variables with nonzero variance. Variable(s) with zero variance: V14.
Error in glmnetRequirements(data = data, type = type, weights = weights) :
At least 2 events required for each category. Requirement not met for variable(s): NA
Error in glmnetRequirements(data = data, type = type, weights = weights) :
Please only provide variables with nonzero variance. Variable(s) with zero variance: V14., V15.
Error in glmnetRequirements(data = data, type = type, weights = weights) :
At least 2 events required for each category. Requirement not met for variable(s): NA
Error in glmnetRequirements(data = data, type = type, weights = weights) :
Please only provide variables with nonzero variance. Variable(s) with zero variance: V14.
Error in glmnetRequirements(data = data, type = type, weights = weights) :
At least 2 events required for each category. Requirement not met for variable(s): NA, NA

And so on. It does finish running. The errors may be at least party due to the fact that some of these variables measure behaviors that have a relatively low prevalence in community samples. For example, variables 14 and 15:

table(EDDS_complete$V14)

0 1 2 3 4 5 8
238 3 1 2 3 1 1

table(EDDS_complete$V15)

0 1 2 3 4 5 6 7 14
233 4 5 2 1 1 1 1 1

Are these results valid, or should I combine some variables to address these error messages?

CS coefficient error

I'm getting the following error when trying to estimate the CS-coefficent:

Error in if (!x$type %in% c("node", "person")) { :
argument is of length zero

Any suggestions much appreciated!

lambda.min.ratio

I am getting a warning message when I run estimatenetwork that I should set my lambda.min.ratio lower. This is related to the long facebook conversation about large unstable network. I know I can use lambda.min.ratio in qgraph, but when I try to use it in bootnet I get an error message.
Code:
library(qgraph)
library(bootnet)
data <- read.table("C:/Users/Irina/Dropbox/EPSI Paper/EDEQ/Goldbricker/EDEQ1-1.csv", header=TRUE, sep=",")
n1 <- estimateNetwork(data, lambda.min.ratio = 0.001, default="EBICglasso")
Error:
Error in (function (data, tuning = 0.5, corMethod = c("cor_auto", "cov", :
unused argument (lambda.min.ratio = 0.001)

"Error in checkForRemoteErrors(val)" appears when running bootnet.

Hi, Sacha
Recently, there appears a strange error when I running the bootnet.
bootnet_SAS <- bootnet(Data_SAS, nBoots = 10000, default = "EBICglasso", tuning = 0.5, type = "nonparametric", statistics = c("edge","strength","closeness","betweenness"), nCores = 2)
When I ran the above code in R (v.3.5.2) with package bootnet (v.1.1.0) on my old computer, it worked very well. Recently, I ran the above code on my new computer installed with R (v.3.6.3) and bootnet (v1.1.0), it cannot work and returned the following message:

Note: bootnet will store only the following statistics: edge, strength, closeness, betweenness
Estimating sample network...
Estimating Network. Using package::function:

  • qgraph::EBICglasso for EBIC model selection
    • using glasso::glasso
  • qgraph::cor_auto for correlation computation
    • using lavaan::lavCor
      Variables detected as ordinal: A1; A2; A3; A4; A5; A6; A7; A8; A9; A10; A11; A12; A13; A14; A15; A16; A17; A18; A19; A20
      Bootstrapping...
      | | 0 % ~calculating Error in checkForRemoteErrors(val) :
      one node produced an error: Maximum number of errors in bootstraps reached
      Warning message:
      In EBICglassoCore(S = S, n = n, gamma = gamma, penalize.diagonal = penalize.diagonal, :
      A dense regularized network was selected (lambda < 0.1 * lambda.max). Recent work indicates a possible drop in specificity. Interpret the presence of the smallest edges with care. Setting threshold = TRUE will enforce higher specificity, at the cost of sensitivity.

This error "Error in checkForRemoteErrors(val) :
one node produced an error: Maximum number of errors in bootstraps reached
" may stop the process of bootnet.
Then, I updated the package bootnet to version 1.3, however, the same error still appeared. The data is a dataset which has 20 variables and 218 cases. It really confused me. Thank you very much for your help to solve this error!
Sincerely,
Shen Jianfei.

"Correlation matrix is not positive definite"

Hi Sacha,
I believe my issue is similar to one already posted, but I'm posting a separate entry just in case.

I'm getting an error when attempting to run the estimateNetwork function.
Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
Correlation matrix is not positive definite.

The code I'm using is as follows:
T_W58 <- read.csv("Teacher_Wave 58.csv")
T58_Network <- estimateNetwork(T_W58, default = "EBICglasso")

My understanding was that in the past, the function has found the nearest positive definite matrix, so I wanted to check with you. Thanks for the help!

Error in binarize()

Hi,

I think there is an error with binarize() function.

for (i in seq_len(ncol(x))) {
            x[, i] <- 1 * (x[, i] < splits[i])
        }

So if split[i]=2 and for example x[1,1]=1 since 1<2 is true, return value is 1 (and it should be 0 since x[1,1] is less than split value).

Extract confidence intervals

Is there a way to extract the 5% and 95% confidence interval from the bootnet object?
I have run

boot <- bootnet(data, default = "EBICglasso", type = "nonparametric", nBoots = 10)
plot(boot, labels = FALSE, order = "sample")

And then checked the output of all the different values that bootnet gives and I cannot find a way to extract just the confidence interval.
Any suggestions would be great.

Estimating networks on items on different scales

This is not necessarily an issue, and it's more of a question, but couldn't find a forum where to ask this, so please feel free to close this.

I am wondering if there are any considerations on estimating networks on items with different response scales. Say a group of items with likert ratings from 1-4 and another set of items with 1 to 5 ratings.

My intuition is that I can combine those to estimate a joint network and that this should be fine, since the networks are based on correlations (or partial correlations). But wondering if there are any considerations I am missing.

Thanks you

Helio

netSimulator & multiple cores

I am trying to re-run netSimulator code that worked well in the past. I received the error:

Error in eval(expr, envir = AllConditions[i, ]) : object 'input' not found

I had included an explicit "input" argument, so this was a surprise. After trying varying combinations of options, I've narrowed it down to the nCores argument. If nCores = 1, it runs fine. If nCores > 1, I receive this error.

The following code reproduces the issue.

bootnet::netSimulator() # works
bootnet::netSimulator(nCores = 2) #does not work

This issue appeared for both the CRAN and the most recent github versions.

And Happy New Year!

About " 'S' is not positive definite"

Hi,
I have a problem when using bootnet. My data includes ordinal data(60 varibles, 4 levels, using "1"to "4")and binary data(4 varibles, using "1" and "2"), "sdr" is raw data, no missing value. The error show here, I did not fix it. Help me please. Thanks a lot!

boot_64 <- bootnet(sdr, default ="EBICglasso", statistics =c("Betweenness","Strength","Closeness"),
nBoots = 1000, type = "case", nCores = 8)
Note: bootnet will store only the following statistics: Betweenness, Strength, Closeness
Estimating sample network...
Estimating Network. Using package::function:

  • qgraph::EBICglasso for EBIC model selection
    • using glasso::glasso
  • qgraph::cor_auto for correlation computation
    • using lavaan::lavCor
      Variables detected as ordinal: sdr1; sdr2; sdr4; sdr5; sdr6; sdr7; sdr8; sdr9; sdr10; sdr11; sdr12; sdr13; sdr14; sdr16; sdr17; sdr18; sdr19; sdr20; sdr21; sdr22; sdr23; sdr24; sdr25; sdr26; sdr27; sdr28; sdr29; sdr30; sdr31; sdr32; sdr33; sdr34; sdr35; sdr36; sdr37; sdr38; sdr39; sdr40; sdr41; sdr42; sdr43; sdr44; sdr45; sdr46; sdr47; sdr48; sdr49; sdr50; sdr51; sdr52; sdr53; sdr54; sdr55; sdr56; sdr57; sdr58; sdr59; sdr60; sdr61; sdr62; sdr63; sdr64; sdr65; sdr66
      Error in EBICglassoCore(S = S, n = n, gamma = gamma, penalize.diagonal = penalize.diagonal, :
      'S' is not positive definite

Error computing expected influence from case-dropping bootstrap

Hi,

I am getting an error somewhat similar to a few mentioned here when trying to bootstrap centrality indices- specifically, expected influence.

My data is ordinal ranging from 0 to 8 (beyond what is automatically detected by corAuto), so I used the custom function below.

function0 <- function(symdata){
EBICglasso(cor(symdata,method="spearman",use="pairwise.complete.obs"),
nrow(symdata),gamma=0)}
net0 <- estimateNetwork(symdata,default="none",fun=function0)

Going on to bootstrap my results, I can successfully bootstrap the edges and even strength, closeness, and betweenness.

net0_boot_centrality <- bootnet(net0, nBoots = 1000, type = "case",
statistics = c("strength","betweenness","closeness"))

However, when I try to look at expected influence, I get the following error while bootstrapping:
Error in eigen(S) : infinite or missing values in 'x'

and the following error when computing statistics:
Error in data.frame(name = name, type = "expectedInfluence", node1 = x[["labels"]], :
arguments imply differing number of rows: 1, 17, 0

I have tried different bootnet argument variations with the same result. Any help would be greatly appreciated!

Brooklynn

IsingGenerator() errors

I am working with netSimulator() using the most recent version of bootnet from Github. When trying to simulate network estimation using IsingFit I receive the following error message.

"Error in dataGenerator(nCases, inputResults) : \n Input must be a list containing elements 'graph' and 'intercepts'\n"

A reproducible example:


devtools::install_github("sachaepskamp/bootnet")
library(bootnet)

doesnotwork <- netSimulator(nCases = 1000, nReps = 5, default = c("IsingFit"), dataGenerator = IsingGenerator())

Error in bootnet after update

Hi Sasha,

I am getting an error calculating strength centrality stability after installing the update. I was able to run this exact code with no issues before and CS was calculated then. I am using Spearman correlation for this network. I am getting the error "strength: Could not be computed (likely due to non-finite values)"

I am pasting my code below. Thank you for your help!

MMIEnetwork1 <- estimateNetwork(MMIE, default="EBICglasso", corMethod = "cor", corArgs=list(method = "spearman", use = "pairwise.complete.obs"))
MMIE1boot1<- bootnet(MMIEnetwork1, nBoots=1000,nCores=4)
MMIE1boot2 <- bootnet(MMIEnetwork1, nBoots=1000,nCores=4, type="case")
corStability(MMIE1boot2)

Error when running bootnet with raw data

I am new to both R and network analysis. I am using EGA to estimate a network of psychological symptoms and I want to use bootnet to estimate the centrality stability with node dropping. However, I could only run bootnet after using estimateNetwork. I tried with the raw data, as it says in the documentation, but got an error message. What would be the reason for this? Am I doing the right thing?

This is my EGA estimation code:

gega.v1 <- EGA(gcombdata.v1, model = "glasso", algorithm = "louvain")

This code resulted in an error:

gega_centrstab_t4 <- bootnet(gcombdata.v1, nBoots=2500, type="case", nCores=3,
statistics = c("strength", "closeness", "betweenness"))

"Note: bootnet will store only the following statistics: strength, closeness, betweenness
Estimating sample network...
Error in do.call(.input$estimator, c(list(data), .input$arguments)) :
'what' must be a function or character string
In addition: Warning messages:
1: In formals(fun) : argument is not a function
2: In formals(fun) : argument is not a function"

So I run this instead, which worked:

gega_estnet_v1 <- estimateNetwork(gcombdata.v1, default="EBICglasso")
gega_centrstab_v1 <- bootnet(gega_estnet_v1, nBoots=2500, type="case", nCores=3,
statistics = c("strength", "closeness", "betweenness"))
plot(gega_centrstab_v1, statistics = c("strength"), perNode=TRUE, labels=TRUE, legend=TRUE)

Another issue is that after running bootnet the order of the strength centrality estimates in the node dropping plot was somewhat different compared to that estimated from the EGA network:

gega_graph_v1 <- plot(gega.v1, vsize = 7, labels = colnames(gega_colnames_v1))
gega_centrstab_t4 <- bootnet(gcombdata_v1, nBoots=2500, type="case", nCores=3,
statistics = c("strength", "closeness", "betweenness"))

Would this difference be because I run estimateNetwork or could this occur anyway because of the bootstrap sampling?

I am using R 4.0.2 with RStudio 1.3.959.

default = "adalasso" error

Hi Sacha,

I am trying to use estimateNetwork: network <- estimateNetwork(Data, default = "adalasso"), but I get this message:
Error in (function (data, missing = c("listwise", "stop"), verbose = TRUE, :
Adaptive LASSO default set is currently not supported due to CRAN removal of 'parcor' package.

Could you please help me with further steps? Or am I doing something wrong?

Thank you,
Tijana

Empty network selected as best fitting network.

I get this message when I try to use the case dropping bootstrapping method (using this command: bootcent<-bootnet(Network2, gamma = .5, nBoots = 1000, type = "case")

"An empty network was selected to be the best fitting network. Possibly set 'lambda.min.ratio' higher to search more sparse networks. You can also change the 'gamma' parameter to improve sensitivity (at the cost of specificity)."

I've changed gamma around but no difference. I can't find any information on changing the lambda.min.ratio option. Any thoughts much appreciated.

Why were there different wadj matrixs when reorder columns using estimateNetwork function?

Hi sacha
I found the results of wadj were different when I used estimateNetwork function to estimate different orders of column of dataframe like following:
sdrtest<-sdr[,c(1:14),c(34:64),c(15:33)] .

All the variables are treated as categorical. It includes 60 4-levels and 4 binarys.
The code was like:

test2<-estimateNetwork(as.matrix(sdrtest), default = "mgm",
type = types,
level = level,
order = 2, threshold = "HW",
)

Observation is 2864.
I found the difference by the nnzero command, the results were:

nnzero(test2$results$pairwise$wadj)
[1] 1048
nnzero(test3$results$pairwise$wadj)
[1] 1050
nnzero(mgm_bt$results$pairwise$wadj)
[1] 1042
nnzero(Network$results$pairwise$wadj)
[1] 1046

Could you help to explain it? Thanks a lot!

Network Comparison Test

Hi,

What are the differences between "the network structure invariance", "the global strength invariance", and "the edge invariance"?

Unfortunately, I didn't find papers that describe this issue in details.

Thank you for your help.
Adva

Centrality Tables

Novice network analyzer here,

I've successfully obtained my network plot and with centrality plots, but am having an issue in generating a table with my numerical centrality indices. I'd like one to report precise numbers for a manuscript.

I've tried several codes yet nothing seems to work. I'm conducting networks in R using bootnet.
I have experimented with different syntax as per my internet search and reading of different articles, along with using the '?centrality' command in R.

One error I've repeatedly gotten is "edgeweights must have 2 or 3 columns" - any insight into this issue would be helpful as well.

Let me know if you need more info for assistance.

Thanks in advance.

Trying to use a map as a background in a graph

Hi Sacha and others:

I wonder if there is any way to use a user specific plot as a background in a graph. Specifically, I'm trying to use latitude and longitude coordinates to put the graph nodes over a map... However I'm unable to use a map as a underling picture...

Any idea?

Cheers

estimatebootnet

HI,

Recently started having an issue on different machines. Script used to run fine now getting error: "Error in estimateNetwork(network, default = "EBICglasso", tuning = 0.5, : could not find function "estimateNetwork"

EBICgraph <- estimateNetwork(network, default = "EBICglasso", tuning = 0.5, corMethod = ("cor_auto"), missing = ("pairwise"))

Error in case-dropping Bootstrap

Running into an error in RStudio that I have not previously. Any assistance would be very much appreciated.

Graph_lassoRandom2<-estimateNetwork (Data3, default="EBICglasso")
boot1random2<- bootnet(Graph_lassoRandom2, type="case", nBoots=2500, nCores=8)
Note: bootnet will store only the following statistics: edge, strength, outStrength, inStrength
Estimating sample network...
Estimating Network. Using package::function:

  • qgraph::EBICglasso for EBIC model selection
    • using glasso::glasso
  • qgraph::cor_auto for correlation computation
    • using lavaan::lavCor
      Variables detected as ordinal: R_B1; R_B2; R_B3; R_B4; R_B5; R_C1; R_C2; R_C3; R_C4; R_C5; R_C6; R_C7; R_D1; R_D2; R_D3; R_D4; R_D5
      Bootstrapping...
      |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 08m 54s
      Computing statistics...
      |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 01m 01s
      Warning message:
      In EBICglassoCore(S = S, n = n, gamma = gamma, penalize.diagonal = penalize.diagonal, :
      A dense regularized network was selected (lambda < 0.1 * lambda.max). Recent work indicates a possible drop in specificity. Interpret the presence of the smallest edges with care. Setting threshold = TRUE will enforce high specificity, at the cost of sensitivity.

corStability(boot1random2)
=== Correlation Stability Analysis ===

Sampling levels tested:
nPerson Drop% n
1 94 74.9 257
2 123 67.2 230
3 152 59.5 253
4 181 51.7 263
5 210 44.0 232
6 240 36.0 243
7 269 28.3 236
8 298 20.5 276
9 327 12.8 266
10 356 5.1 244

Maximum drop proportions to retain correlation of 0.7 in at least 95% of the samples:

edge: Could not be computed (likely due to non-finite values)

strength: Could not be computed (likely due to non-finite values)

Accuracy can also be increased by increasing both 'nBoots' and 'caseN'.

Quick Side question: How does one remove the bootstrap mean from the bootstrap confidence interval graph? I tend to see this published without the mean show. Thank you for your time.

Error computing centrality statistics in node-dropping bootstrap

Hi again Sacha,

In fact, I am experiencing another bug when the node-dropping bootstrap is calculating centrality statistics:

Error in data.frame(name = name, type = "strength", node1 = x[["labels"]], : arguments imply differing number of rows: 1, 5, 2

A reproducible example:

library("psych")
data(bfi)
bfiSub <- bfi[,11:15]

NodeDrop <- bootnet( bfiSub , nBoots = 20 , type = "node" , default="EBICglasso", computeCentrality=TRUE)

Running non-parametric and person-dropping bootstrapping, or node-dropping with centralityCompre = FALSE, does not return the error.

I am using R 3.3.1. for Mac OS X.

Thanks for all your help!
Conor

after plot(), browser() appears when type is specified in bootnet

when the type argument is specified to be "person" or "case" in a bootnet object, I get the browser() in R when I want to plot the results.

this works:

library(bootnet)
library("psychTools")
data(bfi)
bfiSub <- bfi[,1:25]

Estimate network:

Network <- estimateNetwork(bfiSub, default = "EBICglasso")

Results1 <- bootnet(Network, nBoots = 1000, nCores = 8
Screenshot 2019-10-08 at 09 58 00
)

Plot bootstrapped edge CIs:

plot(Results1, labels = FALSE, order = "sample")

This doesn't work

library(bootnet)
library("psychTools")
data(bfi)
bfiSub <- bfi[,1:25]

Estimate network:

Network <- estimateNetwork(bfiSub, default = "EBICglasso")

Results1 <- bootnet(Network, nBoots = 1000, nCores = 8, type = "person")

Plot bootstrapped edge CIs:

plot(Results1, labels = FALSE, order = "sample")

Difficulties running bootnet when type is set to "case"

Hi Sacha,
I'm having difficulties running bootnet when type is set to "case" (no issues when type is set to "nonparametric").
The bootnet function is as follows:
bnet_case = bootnet(net4025,nBoots=100,nCores=1,type="case")
When I'm setting the nBoots to small numbers (<50) the function works fine (even though it takes a long time), but when I'm setting the nBoots to higher numbers R seems to stop in the middle.
In the R Condole the last line is " Error in if (sum(abs(beta - beta_old)) < (convergence * sum(abs(beta_ridge)))) { : missing value where TRUE/FALSE needed

The estimateNetwork function is as follows:
net4025 = estimateNetwork(Datasplit[["4025"]],default="graphicalVAR",tuning = 0, vars = labels, dayvar = "date",nLambda = 25).
The data are 9 variables time series of a single participant with 50 time points.
Many thanks for the help!

Gal

GGM size of weights

I have a question about genGGM(). I'm been trying to use it explore how some network estimation techniques work in different circumstances; however, I cannot convince it to give me networks with very large weights between nodes. I expected that if I increased the parRange I would have a broader range of weights, but I do not and I typically have only small weights.

Any insight into what I might be doing wrong, or where my misunderstanding might be? Most of the data I work with have at least some weights that are stronger that the weights I get with genGGM() and so it'd be ideal to have the ability to generate networks with larger weights. Thanks.

library(bootnet)

GGM01 <- genGGM(40, 
          p = 0.1, 
          nei = 5,  
          propPositive = 0.75,
          parRange = c(0, 1))

GGM.51 <- genGGM(40, 
                p = 0.1, 
                nei = 5,  
                propPositive = 0.75,
                parRange = c(.5, 1))

GGM0.5 <- genGGM(40, 
                p = 0.1, 
                nei = 5,  
                propPositive = 0.75,
                parRange = c(0, .5))

range(GGM01)
range(GGM.51)
range(GGM0.5)

screen shot 2018-03-29 at 23 01 01

Error with Bootnet's default = c("cor", "TMFG")

I would like to run the following code (which I believe should be possible from your most recent updates of the bootnet package)

netSimulator(input = genGGM(NVar = 40),
  nCases = c(50, 100, 250, 500, 1000, 2500),
  nReps = 10, # for testing code
  default = c("cor", "TMFG"))

But I get the following error:

Error in netSimulator(input = genGGM(NVar = 40), nCases = c(50, 100, 250,  : 
  Default set 'cor' not yet supported. Please manually specify 'dataGenerator'Default set 'EBICglasso' not yet supported. Please manually specify 'dataGenerator'Default set 'TMFG' not yet supported. Please manually specify 'dataGenerator'

Any help would be greatly appreciated.

Error with plotting bootnet results object

I am trying to plot

plot(boot1, "strength", plot="difference", order="sample", labels=F) 

But get the following error

Expected significance level given number of bootstrap samples is approximately: 0.05
Error in FUN(X[[i]], ...) : object '.group' not found

I have also tried

plot(boot1, "strength", plot="difference", order="sample", labels=F, inherit.aes = FALSE) 

But it doesn't help.
This code was working and then I pulled bootnet from github just before this error occured so could it be related to some updates? Any help would be greatly appeciated.

Empty network in bootnet, but not qgraph

I'm still getting my head round network analysis, but I'm having an issue I can't quite figure out where a network that looks pretty normal when I estimate it with qgraph
graph <-qgraph(data, graph = "glasso", layout = "spring", sampleSize = nrow(data), groups = groups, vTrans = 150, legend = TRUE, borders = FALSE)
will not run in bootnet ('Empty network was selected to be the best fitting network.'):
Network <- estimateNetwork(data, default = "EBICglasso") case <- bootnet(Network, default ="EBICglasso", nBoots = 2500,type = "case", statistics = c("strength", "closeness", "betweenness"))
unless I set the tuning parameter to 0. Of course I would like to estimate the network I obtained with the qgraph estimation method and not one where I've fiddled with the tuning parameter? Why would I get an empty network if I can clearly see a non-empty network with the qgraph approach?

Error while ploting bootstrap results with interval

I am using bootnet 1.4.3, I wanted to generate interval plots following the last functionalities of Bootnet.

However, after running bootstraps (with boots_DIAG_all <- bootnet(net_DIAG_all, type="case", nBoots = 10000)), both ways describe in the tutorial lead to (different) errors:

> plot(boots_DIAG_all, graph = "contemporaneous", plot = "interval")
Error in FUN(X[[i]], ...) : object 'nPeople' not found

and:

> plot(boots_DIAG_all, plot = "interval", split0 = TRUE)
Error in FUN(X[[i]], ...) : object 'q2.5_non0' not found

Any idea where I did a mistake or where this could come from?
Thanks in advance for your help!

ggmGenerator() issue with ordinal

I'm using netSimulator() from the most recent version of bootnet() on Github. When running a simulation with ggmGenerator(ordinal = TRUE) I receive the following error.

"Error : $ operator is invalid for atomic vectors\n"

A reproducible example:

`
devtools::install_github("sachaepskamp/bootnet")
library(bootnet)

works <- netSimulator(nCases = 1000, default = "EBICglasso", dataGenerator = ggmGenerator(ordinal = FALSE))

doesnotwork <- netSimulator(nCases = 1000, default = "EBICglasso", dataGenerator = ggmGenerator(ordinal = TRUE))
`

Problem with using custom function in bootnet()

I would like to use a custom network estimation function with bootnet().

I first define by custom function. This is just a simple correlation matrix for sake of example.

cortest <- function(x){
  require(qgraph)
  cor_net <- cor_auto(x, 
                      detectOrdinal = T, ordinalLevelMax = 7, 
                      missing = "fiml")
  return(cor_net)
}

I can estimate a network using estimateNetwork(). This has no problems.

net <- estimateNetwork(dat, fun = cortest)

However, if I try to use bootnet() to estimate this network and estimate stability etc, I run into errors. Here is my code (nBoots = 10 as I test my code)

boots <- bootnet(dat, fun = cortest, type = "parametric", nBoots = 10)

And here is my error message.

Error in checkInput(default = default, fun = fun, prepFun = prepFun, prepArgs = prepArgs, :
If 'default' is not set and 'fun' is missing, 'prepFun', 'prepArgs', 'estFun' and 'estArgs' may not be missing.

I have tried setting default to "none", but received the same error message.

Thanks for any help.

Error installing 'bootnet': "undefined exports: centralityCompare"

Dear Sacha,

I am having trouble installing bootnet from the Github repository. I receive the error:

Error in namespaceExport(ns, exports) : undefined exports: centralityCompare Error: loading failed Execution halted

I am running:

install_github("SachaEpskamp/bootnet")

I see that you have been recently updating the package, including a renaming of the centralityCompare() function.

Best
Conor Goold

bootnet

Hi, I am fairly new to coding in R. I am trying to load the library(“bootnet”), but it says that there is no bootnet. I installed the package and I see bootnet when I search for it in my downloaded packages.

Error when non-parametric bootstrapping

Hi Sacha,

I'm getting an error in bootnet when calculating edge weight stability.

*******************ESTIMATE NETWORK-RELATED OUTPUT

W1_Network <- estimateNetwork(W1, default = "EBICglasso")
Estimating Network. Using package::function:

  • qgraph::EBICglasso for EBIC model selection
    • using glasso::glasso
  • qgraph::cor_auto for correlation computation
    • using lavaan::lavCor
      Variables detected as ordinal: CarelessMistakes; SustainAttn; Daydreams; FollowInstrux; Organizing; MentalEffort; LosesThings; EasilyDistract; Forgetful; Fidgets; RemainsSeat; RunsClimbs; PlaysQuietly; Motor; TalksExcessive; Blurts; WaitTurn; Intrudes
      Warning message:
      In EBICglassoCore(S = S, n = n, gamma = gamma, penalize.diagonal = penalize.diagonal, :
      A dense regularized network was selected (lambda < 0.1 * lambda.max). Recent work indicates a possible drop in specificity. Interpret the presence of the smallest edges with care. Setting threshold = TRUE will enforce high specificity, at the cost of sensitivity.

*******************BOOTSTRAPPING-RELATED OUTPUT

boot1a <- bootnet(W1_Network, nBoots = 100, type = "nonparametric", nCores = 4, statistics = c("betweenness","closeness", "expectedInfluence"))
Note: bootnet will store only the following statistics: betweenness, closeness, expectedInfluence
Estimating sample network...
Estimating Network. Using package::function:

  • qgraph::EBICglasso for EBIC model selection
    • using glasso::glasso
  • qgraph::cor_auto for correlation computation
    • using lavaan::lavCor
      Variables detected as ordinal: CarelessMistakes; SustainAttn; Daydreams; FollowInstrux; Organizing; MentalEffort; LosesThings; EasilyDistract; Forgetful; Fidgets; RemainsSeat; RunsClimbs; PlaysQuietly; Motor; TalksExcessive; Blurts; WaitTurn; Intrudes
      Bootstrapping...
      |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 37s
      Computing statistics...
      |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 02s
      Warning message:
      In EBICglassoCore(S = S, n = n, gamma = gamma, penalize.diagonal = penalize.diagonal, :
      A dense regularized network was selected (lambda < 0.1 * lambda.max). Recent work indicates a possible drop in specificity. Interpret the presence of the smallest edges with care. Setting threshold = TRUE will enforce high specificity, at the cost of sensitivity.

plot(boot1a, labels = FALSE, order = "sample")
Expected significance level given number of bootstrap samples is approximately: 0.051
Error in $<-.data.frame(*tmp*, "fill", value = "same") :
replacement has 1 row, data has 0

plot = "difference" problem

Hello Sacha,

I´m trying to use the following code:

plot(data, layout = "groups", "edge", plot = "difference", alpha = c(0.001, 0.01, 0.05),
onlyNonZero = TRUE)

which gives me this error:

Error in if (plot) { : argument is not interpretable as logical
In addition: Warning message:
In qgraph::qgraph(wMat, labels = labels, directed = directed, parallelEdge = parallelEdge, :
The following arguments are not documented and likely not arguments of qgraph and thus ignored: onlyNonZero

Do you have an idea?

This is what I used to build the network:

data <- estimateNetwork(dataframe, default = "cor",
corMethod ="cor_auto", threshold ="fdr")

Thanks,
Jan

error in glassopath in estimateNetwork

I tried to run the code below

netnet <- estimateNetwork(my_df, default = "EBICglasso")

then it printed this massage

#######################################################
Estimating Network. Using package::function:

  • qgraph::EBICglasso for EBIC model selection
    • using glasso::glasso
  • qgraph::cor_auto for correlation computation
    • using lavaan::lavCor
      Variables detected as ordinal: 1 ;2 ;3

Error in glassopath(S, lambda, trace = 0, penalize.diagonal = penalize.diagonal, : unused argument (refit = FALSE)

please let me know what is happening here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.