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

Revision 19ab2d14a3bb5e3488ed946dc4191d32c64bcf52 authored by Sacha Epskamp on 19 June 2015, 00:00:00 UTC, committed by Gabor Csardi on 19 June 2015, 00:00:00 UTC
version 0.1.3
1 parent c678bf0
  • Files
  • Changes
  • b257cb1
  • /
  • R
  • /
  • SparseTSCGM_lambdas.R
Raw File Download

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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:19ab2d14a3bb5e3488ed946dc4191d32c64bcf52
directory badge
swh:1:dir:4bba10eb89d72166348e50de7257b82617f32fa5
content badge
swh:1:cnt:93c263cbf8d451385ee9e58c17a8eb2cfaa9bff3

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.

  • revision
  • directory
  • content
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 ...
SparseTSCGM_lambdas.R
SparseTSCGM_lambdas <-
function(X, Y, nlambda = 100){
  # From SparseTSCGM package:
  lambda.seq <- function(SS, SA,nlambda)
  {
    if (length(nlambda)==1) nlambda <- rep(nlambda,2)
    lambda.min.ratio=0.1
    d= dim(SS)[2]
    lambda.max1 = max(max(SS-diag(d)),-min(SS-diag(d)))
    lambda.min1 = lambda.min.ratio*lambda.max1
    lambda1 = exp(seq(log(lambda.max1), log(lambda.min1), length = nlambda[1]))
    lambda.min.ratio2=0.15
    lambda.max2 = max(max(SA),-min(SA))
    lambda.min2 = lambda.min.ratio2*lambda.max2
    lambda2 = exp(seq(log(lambda.max2), log(lambda.min2), length = nlambda[2]))
    return(list(lambda1=lambda1, lambda2=lambda2))
  }
  
  T <- dim(Y)[1]
  p <- dim(X)[2]
  n <- 1
  q <- dim(Y)[2]
  xtyi <- array(NA, c(p,q,n))
  xtxi <- array(NA, c(p,p,n))
  ytyi <- array(NA, c(q,q,n))
  
    XX <- X
    YY <- Y
    XX2 <- X^2
    YY2 <- Y^2
    xtyi <- crossprod(XX,YY)
    xtxi <- crossprod(XX)
    ytyi <- crossprod(YY)

  xty=apply(xtyi, c(1,2), sum)
  xtx=apply(xtxi, c(1,2), sum)
  yty=apply(ytyi, c(1,2), sum)
  xtxt=apply(xtxi, c(1,2), sum)/(n*T)
  xtx2=(n*T)*colMeans(apply(XX2, c(1,2), sum))
  yty2=(n*T)*colMeans(apply(YY2, c(1,2), sum))
  
  SX <- xtx/(n*T)
  mSX <- glasso(SX,0.05,penalize.diagonal=FALSE)
  
  SX <- xtx/(n*T)
  mSX <- glasso(SX,0.05,penalize.diagonal=FALSE)
  SXi <- mSX$wi
  SS =(yty)/(n*T)
  SS = cov2cor(SS)
  SAs = xty/(n*T)
  SA = SAs %*% SXi
  
  lambda <-  lambda.seq(SS=SS,SA=SA, nlambda=nlambda)
  lam1 <- round(lambda$lambda1,3) 
  lam2 <- round(lambda$lambda2,3)
  lam2 <- round(lam2/max(lam2),3)    
  return(list(lambda_kappa = lam1, lambda_beta = lam2))
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, 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— Content policy— Contact— JavaScript license information— Web API