Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/cran/graphicalVAR
15 March 2024, 11:27:55 UTC
  • Code
  • Branches (14)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/0.1.1
    • refs/tags/0.1.2
    • refs/tags/0.1.3
    • refs/tags/0.1.4
    • refs/tags/0.2
    • refs/tags/0.2.1
    • refs/tags/0.2.2
    • refs/tags/0.2.3
    • refs/tags/0.2.4
    • refs/tags/0.3
    • refs/tags/0.3.1
    • refs/tags/0.3.3
    • refs/tags/0.3.4
    No releases to show
  • 37363ec
  • /
  • R
  • /
  • mlGraphicalVAR.R
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:e44cf8022f305366079d23239d1ce859a43b8013
origin badgedirectory badge Iframe embedding
swh:1:dir:e63664a84ffd9e1f75cb4620cdef548098120a7b
origin badgerevision badge
swh:1:rev:5ec0fee4721f06734fa9952c26bdf6f2128cac0d
origin badgesnapshot badge
swh:1:snp:9d71d524f3f98b6820bf7864b20870c1d9d25774
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 5ec0fee4721f06734fa9952c26bdf6f2128cac0d authored by Sacha Epskamp on 21 February 2024, 04:10:03 UTC
version 0.3.4
Tip revision: 5ec0fee
mlGraphicalVAR.R
# Multi-level like graphical VAR:
  
mlGraphicalVAR <- function(
  data,
  vars,
  beepvar,
  dayvar,
  idvar,
  scale = TRUE,
  centerWithin = TRUE,
  gamma = 0.5, # Gamma used in glasso in qgraph
  verbose = TRUE,
  subjectNetworks = TRUE, # Or a vector of which subjects to use!
  lambda_min_kappa_fixed = 0.001,
  lambda_min_beta_fixed = 0.001,
  lambda_min_kappa = 0.05,
  lambda_min_beta = lambda_min_kappa,
  lambda_min_glasso = 0.01,
  ... # Args sent to graphicalVAR
){
  if (missing(idvar)) stop("'idvar' must be assigned")
  
  # Prep data:
  dataPrepped <- tsData(data,vars=vars,beepvar=beepvar,dayvar=dayvar,idvar=idvar,scale=scale,centerWithin=centerWithin)
  
  if (verbose){
    message("Estimating fixed networks")
  }
  
  # Fixed effects:
  ResFixed <- graphicalVAR(dataPrepped, lambda_min_kappa = lambda_min_kappa_fixed, lambda_min_beta = lambda_min_beta_fixed, gamma=gamma,...)
  
  # Between-subjects:
  if (verbose){
    message("Estimating between-subjects network")
  }
  meansData <- dataPrepped$data_means
  meansData <- meansData[,names(meansData) != idvar]
  meansData <- meansData[rowMeans(is.na(meansData))!=1,]
  ResBetween <- qgraph::EBICglasso(cov(meansData),nrow(meansData),gamma,returnAllResults = TRUE,lambda.min.ratio=lambda_min_glasso)
  
  # Computing model per person:
 
  
  IDs <- unique(dataPrepped$data[[idvar]])
  idResults <- list()
  if (!identical(subjectNetworks,FALSE)){
    if (isTRUE(subjectNetworks)){
      subjectNetworks <- IDs
    }
    
    if (verbose){
      message("Estimating subject-specific networks")
      pb <- txtProgressBar(max=length(subjectNetworks),style=3)
    }
    for (i in seq_along(subjectNetworks)){
      capture.output({idResults[[i]] <- try(suppressWarnings(graphicalVAR(dataPrepped$data[dataPrepped$data[[idvar]] == subjectNetworks[i],],
                                                          vars=dataPrepped$vars,
                                                          beepvar=dataPrepped$beepvar,
                                                          dayvar=dataPrepped$dayvar,
                                                          idvar=dataPrepped$idvar,
                                                          scale = scale,
                                                          lambda_min_kappa=lambda_min_kappa,
                                                          lambda_min_beta=lambda_min_beta,
                                                          gamma=gamma,
                                                          centerWithin = centerWithin,...,verbose = FALSE)))})
      if (verbose){
        setTxtProgressBar(pb,i)
      }
      if (is(idResults[[i]], "try-error")){
        idResults[[i]] <- list()
      }
    }   
    if (verbose){
      close(pb)
    }
  } else {
    idResults <- lapply(seq_along(IDs),function(x)list())
  }
  

  
  # Aggregate results:
  Results <- list(fixedPCC = ResFixed$PCC, 
                  fixedPDC = ResFixed$PDC,
                  fixedResults = ResFixed,
                  betweenNet = ResBetween$optnet,
                  betweenResults = ResBetween,
                  ids = IDs,
                  subjectPCC = lapply(idResults, '[[', 'PCC'),
                  subjectPDC = lapply(idResults, '[[', 'PDC'),
                  subjecResults = idResults)
  class(Results) <- "mlGraphicalVAR"
  return(Results)
}

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top