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

  • 901326c
  • /
  • diagnosticBoxplots.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.

  • content
  • directory
content badge
swh:1:cnt:1b514f38bb8f3c201fd79f5d34ca0a78fa27d92f
directory badge
swh:1:dir:901326ca4b947cf045195ee799572e4832d86525

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
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
diagnosticBoxplots.R
# Function for plotting the diagnostic plots which auto detects the type of HLSM object and plots accordingly

HLSMcovplots<-function(fitted.model,burnin=0,thin=1)
{
  fitted.model=list(fitted.model)
  length(fitted.model)
  if(fitted.model[[1]]$call[[1]]=="HLSMfixedEF"){
    HLSMfixed.covplots(m=fitted.model[[1]],burninvalue=burnin,thinvalue=thin)
    
  }else if(fitted.model[[1]]$call[[1]]=="HLSMrandomEF"){
   HLSMrandom.covplots(m=fitted.model[[1]],burninvalue=burnin,thinvalue=thin)
  }
}

# Function that plots the diagnostic boxplots for fixed effects model
HLSMfixed.covplots<-function(m,burninvalue,thinvalue){
  if(length(m$draws$ZZ)<=4000){
    t=paste("Try running a chain length greater than 4000 to see parameter plots")
    return(t)
  }
  else{
  i=getIntercept(m,burnin = burninvalue,thin = thinvalue)
  betas=getBeta(m,burnin = burninvalue,thin = thinvalue)
  beta_table=as.data.frame(betas)
  beta_mcmc=as.mcmc(beta_table)
  intercept_mcmc=as.mcmc(i)
  ri=raftery.diag(intercept_mcmc)
  #getting the burnin and the optimum chain length based on the betas
  rb=raftery.diag(beta_table)
  rdf=data.frame(rb[[2]])
  chain_length=max(sapply(rdf[,2],max))
  burnin_value =rdf[which.max(rdf[,2]),1]
  thinnin_value=rdf[which.max(rdf[,2]),4]
  #plotting the boxplots 
  g= plotHLSM.fixed.fit(m,parameter="Beta",burnin=burnin_value,thin=thinnin_value)
  return (c(g))
  }
}

# Function that plots the diagnostic bocplots for random effects model
HLSMrandom.covplots<-function(m,burninvalue,thinvalue){
  if(length(m$draws$ZZ)<=4000){
    t=paste("Try running a chain length greater than 4000 to see the parameter plots")
    return(t)
  }
  else{
  intercept=getIntercept(m,burnin=burninvalue,thin=thinvalue)
  beta_list <- list()
  for(i in 1:ncol(intercept))
  {
    beta_list[[i]]=m$draws$Beta[,,i]
  }
  
  beta_list_df=do.call(cbind.data.frame, beta_list)
  beta_mcmc=as.mcmc(beta_list_df)
  #getting the burnin and the optimum chain length based on the betas
  rb=raftery.diag(beta_list_df)
  rdf=data.frame(rb[[2]])
  chain_length=max(sapply(rdf[,2],max))
  burnin_value =rdf[which.max(rdf[,2]),1]
  thinnin_value=rdf[which.max(rdf[,2]),4]
  #plotting the boxplots 
  g= plotHLSM.random.fit(m,parameter="Beta",burnin=burnin_value,thin=thinnin_value)
  return (c(g))
  }
}

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