GithubHelp home page GithubHelp logo

Comments (9)

SachaEpskamp avatar SachaEpskamp commented on May 29, 2024

Hi Shen,

This is not really the way bootnet is supposed to be used. Please first use estimateNetwork:

net <- estimateNetwork(Data_SAS,  default = "EBICglasso", tuning = 0.5)
bootnet_SAS <- bootnet(net , nBoots = 10000, type = "nonparametric", statistics = c("edge","strength","closeness","betweenness"), nCores = 2)

This may solve the problem. If not, please use nCores = 1 and see if you get a more informative error message (the current message simply says that something went wrong in the multi-core process).

from bootnet.

Shen-Jianfei avatar Shen-Jianfei commented on May 29, 2024

Thanks very much for your response!
I tried the codes recommended in your reply. Unfortunately, the same error still existed. After I used nCores = 1 instead of nCores = 2, R returned the imformation including a series of errors which is just like below:

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%Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      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.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      Error in bootnet(net, nBoots = 1000, type = "nonparametric", statistics = c("edge", :
      Maximum number of errors in bootstraps reached

It seems that there is something wrong in the correlation matrix calculated from the dataset. But the same correlation matrix can be used correctly by bootnet on my old computer. So I am very confused about the error information. Many thanks and looking forward to hearing from you!
Sincerely,
Shen Jianfei.

from bootnet.

SachaEpskamp avatar SachaEpskamp commented on May 29, 2024

This is likely due to polychoric correlations being unstable. Try corMethod = "spearman" instead.

from bootnet.

Shen-Jianfei avatar Shen-Jianfei commented on May 29, 2024

Many thanks for your reply!
After I added corMethod = "spearman", the bootnet ran correctly!!! I am very grateful for your kind help!
Sincerely,
Shen Jianfei.

from bootnet.

YRasch avatar YRasch commented on May 29, 2024

Hello Sacha,
thank you for all your work and output regarding psychological network models! I have the same Problem. I have plotted a polychloric partial correlation network of 90 SCL-90 items (5-point-likert scale) with n=1506 using

V5_Netzwerk_boot <- estimateNetwork(v5_final, default = "EBICglasso", cormethod = "cor_auto").

This works fine. Also the casedrop bootstrapping worked fine, using the function

bootnet(V5_Netzwerk_boot, nBoots = 2500, nCores = 8, type ="case")

I have the value 0.594 for both strength and edge, so I figured it was stable enough regardless of the pretty "heavy" network containing 90 nodes. Nonethelesss, running

bootnet(V5_Netzwerk_boot, nBoots = 1000, nCores =8)

does produce the same Error Shen-Jianfai described above. I tried

bootnet(V5_Netzwerk_boot, nBoots = 1000, corMethod="spearman", nCores =8)

and also

bootnet(V5_Netzwerk_boot, nBoots = 1000, nonPositiveDefinite = "continue", nCores =8)

to try if it really is just the matrix being not positive definite, even if the functions beforehand worked perfectly fine. Also restarting R didn't solve the issue :-)
Is there anything else I can try to solve the problem?

Kind regards
Yvonne Rasch

from bootnet.

SachaEpskamp avatar SachaEpskamp commented on May 29, 2024

Hi Yvonne,

You have to put corMethod = "spearman" in the estimateNetwork call, not in the bootnet call. It should work then.

Best, Sacha

from bootnet.

YRasch avatar YRasch commented on May 29, 2024

Hi Sacha,
thank you for your quick response.
Unfortunately the network created with

V5_Netzwerk_boot_spearman <- bootnet::estimateNetwork(V5_Matrix, default="EBICglasso", corMethod ="spearman")

with bootstrap code

V5_boot_casedrop_sp <- bootnet(V5_Netzwerk_boot_spearman, nBoots = 1000, nCores = 8, type ="case")

yields the same error.

V5_Matrix, which I use above, is a correlation-matrix estimated with cor_auto (detect ordinal = true & ordinalLevelMax=5).
If I use the original dataset (w/o missings, imputed with predictive mean matching) or a correlation-matrix calculated with cor() and spearman correlations as input computing a network yields the error cormat is not posdef.

It was possible to bootstrap the edgeweights with the polychloric estimated network once I reduced the nboot to 100 and 200 though. There was no big difference according to visual analysis of the edgeplot and the CIs did not seem to be broad. If thats fine - I would be good?

Independently, after calculating the nBoot(200) the

_

plot(v5_boot_all_edgeweight, "edge", plot ="difference", order = "sample")

_

responds with the error "rep.int(seq_len(nx), rep.int(rep.fac, nx)) : invalid 'times' value.
I'm guessing the file is just too big. Is there a possibility to only plot a subset of nodes? as only a subset is relevant for me.

Best
Yvonne

from bootnet.

SachaEpskamp avatar SachaEpskamp commented on May 29, 2024

Hi Yvonne,

The input to estimateNetwork must be raw data not a correlation matrix.

Best, Sacha

from bootnet.

lxxhy avatar lxxhy commented on May 29, 2024

Hi Sacha,

I want to ask you a question because I have a similar problem as above.
At first, I put the code as below, and I changed it to the second code according to your advice.

boots <- bootnet(Network, statistics = c("Strength", "Closeness", "Betweenness"), nBoots = 1000, nCores = 4, type = "case")

Note: bootnet will store only the following statistics: 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: D1; D2; D3; D4; D5; D6; D7; D8; D9; D10; D11; D12; D13; D14; D15; D16; D17; D18; D19; D20; D21; A1; A2; A3; A4; A5; A6; A7; A8; A9; A10; A11; A12; A13; A14; A15; A16; A17; A18; A19; A20; A21
      Bootstrapping...
      |++++++++++++++++++ | 35% ~28m 06s Error in checkForRemoteErrors(val) :
      one node produced an error: Maximum number of errors in bootstraps reached
      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.

boots <- bootnet(Network, statistics = c("Strength", "Closeness", "Betweenness"), nBoots = 1000, nCores = 1, corMethod = "spearman", type = "case")

Then I got this error.

Note: bootnet will store only the following statistics: 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: D1; D2; D3; D4; D5; D6; D7; D8; D9; D10; D11; D12; D13; D14; D15; D16; D17; D18; D19; D20; D21; A1; A2; A3; A4; A5; A6; A7; A8; A9; A10; A11; A12; A13; A14; A15; A16; A17; A18; A19; A20; A21
      Bootstrapping...
      | | 0%Error in bootnet_correlate(data = data, corMethod = corMethod, corArgs = corArgs, :
      Correlation matrix is not positive definite.
      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.

I would really appreciate it if you could let me know if there are other possible attempts to resolve this error.

from bootnet.

Related Issues (20)

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.