jasp-stats / jasp-issues

This repository is solely meant for reporting of bugs, feature requests and other issues in JASP.
59 stars 29 forks source link

[Bug]: Different Results in JASP and R #2872

Open tonante-BR opened 2 months ago

tonante-BR commented 2 months ago

JASP Version

0.19.0

Commit ID

No response

JASP Module

Network

What analysis are you seeing the problem on?

Classic Network

What OS are you seeing the problem on?

Windows 10

Bug Description

I ran a network analysis and noticed some differences in the results between JASP and R. For example, the number of non-zeros was different, as well as the centrality metrics. From what I observed, I followed the same settings in R as I did in JASP. I would like to know if there is indeed a difference or if I might be doing something differently between them. Attached are the JASP file, the R script, and the dataset I'm using. Thank you very much. PHQ.zip

Expected Behaviour

I expected to obtain the same metrics when performing the analysis in both JASP and R.

Steps to Reproduce

  1. I have uploaded the dataset.
  2. I requested to display the network graph and the metrics.
  3. Default settings in JASP.
  4. I replicated the analysis in R. ...

Log (if any)

No response

More Debug Information

No response

Final Checklist

vandenman commented 2 months ago

Hi @tonante-BR,

What is going on is that jasp treats the data as ordinal and R treats it as continuous. If you have them treat the data the same you get the same results. To replicate the results in your jasp file in R, do

Dados2 <- Dados
for (i in seq_along(Dados2)) {
  Dados2[[i]] <- as.factor(Dados2[[i]])
}

Network2 <- estimateNetwork(Dados, default = "EBICglasso", weighted = TRUE, tuning = 0.5,
                            corMethod = "cor_auto")

centralityPlot(Network2, scale = c("z-scores"), 
               include = c("Strength","Closeness", "Betweenness"), 
               theme_bw = TRUE, print = TRUE,
               verbose = TRUE, weighted = TRUE, 
               decreasing = T) +
  ggplot2::scale_y_discrete(limits=rev)

To replicate the results from R in jasp, click these icons next to the variables

image

which opens a dropdown

image

and then you can change them to scale. In addition, change the Correlation method to Cor.

image

Hope that helps!

github-actions[bot] commented 2 weeks ago

This issue will be automatically closed in 42 days due to inactivity. Feel free to leave a comment if you believe this is still relevant.