GithubHelp home page GithubHelp logo

paytonjjones / networktree Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 2.0 36.86 MB

Recursive partitioning (tree models) of psychometric networks

Home Page: https://paytonjjones.github.io/networktree/

R 100.00%
network-analysis psychometrics tree-models

networktree's People

Contributors

paytonjjones avatar zeileis avatar

Stargazers

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

Watchers

 avatar  avatar

networktree's Issues

comparetree

RStudio not recognizing compare tree; see below error. Thanks Payton!

comparetree(tree1, id1 = 1,id2 = 2, plot=TRUE)
Error in comparetree(tree1, id1 = 1, id2 = 2, plot = TRUE) :
could not find function "comparetree"

installation problem due to data/dass.rda file type

Hi Payton,
the files tipi.rda and dass.rda are "gzip compressed data, from HPFS filesystem (OS/2, NT)."
This means that I get the message

Warning: file ‘dass.rda’ has magic number 'RDX3' Use of save versions prior to 2 is deprecated
Error in load(zfile, envir = envir) : bad restore file magic number (file may be corrupted) -- no data loaded

when trying to install networktree.
The file workaholic.rda is "bzip2 compressed data, block size = 900k" and gives no problem.

Bye

Errors in plotting

I get a weird looking plot when I tried to plot:
image

code:
tree <- networktree(nodevars=all_var[,2:28],
splitvars=all_var[,c("age","Marital","Education","pride","life",
"family","economy","contribute","threats","perception")],
type="glasso")
plot(tree, layout="spring")

Warning messages:
1: In graphics::par(fig = gridBase::gridFIG(), mar = rep(0, 4), new = TRUE) :
calling par(new=TRUE) with no plot
2: In doTryCatch(return(expr), name, parentenv, handler) :
cannot pop the top-level viewport ('grid' and 'graphics' output mixed?)
3: In doTryCatch(return(expr), name, parentenv, handler) :
cannot pop the top-level viewport ('grid' and 'graphics' output mixed?)

Robust Estimation?

Hello,

I've been trying to run networktree on the attached data (which I understand to be a random sample of the publicly available BIG 5 data from IPIP), I'm guessing that the reason why networktree fails to run is because there are some sub-groups that have too small a sample relative to the number of nodes in the network.

Would there be a way to perhaps persist on computing the network on the sub-group either by using some variant of GLASSO or simply throwing up a warning message for the sub-groups on which a correlational network could not be estimated?

library(data.table)
library(networktree)
d_efa <- data.table::fread(input = here::here("data/EFA_BIG5.csv"))
col_idx <- colnames(d_efa)[-1:-6]
networktree::networktree(
  nodevars = d_efa[, col_idx, with = FALSE],
  splitvars = d_efa[, c("race", "age", "engnat", "gender", "hand", "country")],
  method = "mob",
  model = "correlation",
  transform = "cor"
)

#> Error in fit(y = y, x = x, start = start, weights = weights, offset = offset, : mvnfit: n < k*(k-1)/2, correlation matrix is not identified.

Created on 2024-04-29 with reprex v2.1.0

Plot tree in new device

In some cases plotting a network tree in a new device fails.
I detected the problem writing a vignette:

# plot(tr, type = "pcor", posCol = "#008585", negCol = "#C7522B", maximum = 1)

which plots into png device.

However, the issue also occurs when plotting in an interactive R session, e.g.:

library("networktree")
set.seed(111)

data("FXRatesCHF", package = "fxregime")
currencies <- c("USD", "JPY", "DUR", "CNY", "INR", "GBP", "ZAR")
returns <- fxregime::fxreturns(currencies, data = FXRatesCHF)
returns <- na.omit(returns)

returns$year   <- as.POSIXlt(zoo::index(returns))$year
returns$isLeap <- (returns$year %% 4) == 0
returns$yday   <- as.POSIXlt(zoo::index(returns))$yday
returns$time   <- 1900 + returns$year + returns$yday / ifelse(returns$isLeap, 366, 365)

f  <- paste(paste(currencies, collapse = " + "), "~ time")
f  <- as.formula(f)
tr <- networktree(f, data = returns, cor = TRUE, maxdepth = 3)

plot(tr, type = "pcor", posCol = "#008585", negCol = "#C7522B", maximum = 1)

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.