Comments (6)
Right, I see. Thanks! This may not be trivial for now, I need to open up the function and add that the edge colors are also retained properly. Will put it on the todo list!
from qgraph.
This is now fixed in the devel version (sorry for the delay).
from qgraph.
Here's the covariance matrix:
and here's what I did with mgm:
bctdf_pa_combinedAgreementBcts <- bctdf_pa_combinedAgreementBcts %>% na.omit()
mgm_pa_variable_types <- c("g", "g", rep("c", 7))
mgm_pa_variable_levels <- c("1", "1", rep("2", 7))
mgm_obj <- mgm::mgm(data = bctdf_pa_combinedAgreementBcts,
type = mgm_pa_variable_types,
level = mgm_pa_variable_levels,
lambdaSel = "CV",
lambdaFolds = 10,
pbar = FALSE,
binarySign = TRUE)
pred_obj <- predict(object = mgm_obj,
data = bctdf_pa_combinedAgreementBcts)
pred_obj$errors
# Take R2 from gaussian, CC from categorical variables
pie_errors <- c(pred_obj$errors[1, 3],
pred_obj$errors[2, 3],
pred_obj$errors[3:nrow(pred_obj$errors), 4])
# PLOT NETWORK
node_colors <- c(viridis::viridis(4, begin = 0.3, end = 0.8)[1],
viridis::viridis(4, begin = 0.3, end = 0.8)[2],
rep(viridis::viridis(4, begin = 0.3, end = 0.8)[3], 7))
BCT_mgm <- qgraph::qgraph(mgm_obj$pairwise$wadj,
layout = "spring",
repulsion = 1, # To nudge the network from originally bad visual state
title = "agreement-measured BCTs and PA",
edge.color = ifelse(mgm_obj$pairwise$edgecolor == "darkgreen", "blue", mgm_obj$pairwise$edgecolor),
pie = pie_errors,
pieColor = viridis::viridis(4, begin = 0.3, end = 0.8)[4],
color = node_colors,
labels = names(bctdf_pa_combinedAgreementBcts),
label.cex = 0.75,
label.scale = FALSE,
label.color = c(rep("black", 9)),
theme = "colorblind")
from qgraph.
Same issue happens to me. I am thinking whether it is because the edge color specific in the mgm model does not inherit to the flow function. Any idea?
from qgraph.
Hi both,
Sorry for the late response. How do I read that cov matrix Matti? And do you possibly have an easier to reproduce example? It is possible indeed that this is due to the edge colors not being supplied. Perhaps try to store the results of flow(...)
and then manually change the edge colors in the qgraph object?
Best, Sacha
from qgraph.
Apologies for being a bit novice with this. I now tinkered a bit with what little I could simulate, and found a hopefully more reproducible way to come about those grey edges.
If you use 5000 instead of 200 in MASS::mvrnorm(n = 200, mu = mus, Sigma = S)
, you'll get blue/red edges instead of grey ones, even though the categorical variables have two levels and grey edges don't appear in the "normal" (non-flow) network.
# Make covariance matrix.
S <- matrix(c(1.0, 0.2, 0.1, 0.35, 0.0,
0.2, 1.0, 0.0, 0.4, 0.0,
0.1, 0.0, 1.0, 0.0, 0.4,
0.35, 0.4, 0.0, 1.0, 0.6,
0.0, 0.0, 0.4, 0.6, 1.0), ncol = 5)
colnames(S) <- c("Y1", "X1", "X2", "Z1" ,"Z2")
rownames(S) <- colnames(S)
# Make mean vector
mus <- c(1, 2, 3, 4, 5); names(mus) = colnames(S)
# Generate 5347 observations
obs <- MASS::mvrnorm(n = 200, mu = mus, Sigma = S)
obs <- data.frame(obs)
obs$categorical <- ifelse(obs$Y1 > 2, 1, 0)
obs$categorical2 <- ifelse(obs$X1 > 2, 1, 0)
bctdf_pa_combinedAgreementBcts <- obs
mgm_pa_variable_types <- c(rep("g", 5), "c", "c")
mgm_pa_variable_levels <- c(rep("1", 5), "2", "2")
mgm_obj <- mgm::mgm(data = bctdf_pa_combinedAgreementBcts,
type = mgm_pa_variable_types,
level = mgm_pa_variable_levels,
lambdaSel = "CV",
lambdaFolds = 10,
pbar = FALSE,
binarySign = TRUE)
# PLOT NETWORK
BCT_mgm <- qgraph::qgraph(mgm_obj$pairwise$wadj,
layout = "spring",
repulsion = 1, # To nudge the network from originally bad visual state
title = "agreement-measured BCTs and PA",
edge.color = ifelse(mgm_obj$pairwise$edgecolor == "darkgreen", "blue", mgm_obj$pairwise$edgecolor),
labels = names(bctdf_pa_combinedAgreementBcts),
label.cex = 0.75,
label.scale = FALSE,
label.color = c(rep("black", 9)),
theme = "colorblind")
qgraph::flow(BCT_mgm, from = "Y1")
from qgraph.
Related Issues (20)
- R 4.2.2 Crashes when using qgraph on Windows 10x64 HOT 1
- Legend disappears when setting edge.labels=TRUE HOT 2
- centralityPlot documentation says standardized by default, but actually raw0 HOT 1
- Help! EBICglasso return an empty network HOT 4
- Legend for correlation magnitude HOT 1
- "NA/NaN Hessian evaluation" error when calling cor_auto HOT 1
- pie in qgraph.loadings does not display when there are more than 4 latent factors HOT 2
- Incorperate bridge centrality in centralityPlot
- font support for CJK
- Can qgraph use more palette like jama style, etc.? HOT 4
- Error in flow HOT 2
- The colors of legend by groups was not worked HOT 3
- Conflict with `psych::score.multiple.choice()` HOT 2
- qgraph introduces a conflict with psych describe HOT 5
- Error in if (sign(tans) != sign(curve[i])) { : argument is of length zero HOT 1
- cor_auto fails with missing="fiml" but does not tell the user HOT 2
- Arrows not drawn when arrowheads are larger than the distance between two nodes
- No way to concisely depict networks with bidirectional arrows where each direction differs in strength HOT 1
- as.igraph gives error when trying to convert some valid qgraph objects
- Forcing nodes positions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qgraph.