Skip to content
Permalink
339bb5649d
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
39 lines (36 sloc) 1.11 KB
#' Function to compute regularized DPM
#'
#' @param data is a matrix containing samples in rows and variables in columns
#'
#' @return a nvar*nvar matrix containing reg.DPM scores for all links (edges) where nvar is the number of variables
#'
#' @import corpcor
#'
#' @examples
#' example1:
#' ## Generate non-linear data with 100 samples (from the network discussed in the paper) where the gaussian noise with standard deviation of sigma=0.2 is added to the generated data
#' data <- nldata(nsamp=100,sigma=0.2)$data
#'
#'## run regularized DPM
#' reg.dpm(data)
#'
#' example2:
#' ##load DREAM4 data
#' data(dream4)
#'
#'## Run regularized DPM
#' res <- reg.dpm(data)
#'
#'
#' @export
###########################################
### Function to compute regularized DPM ###
###########################################
reg.dpm <- function(data) {
# compute the double-centred vectors of each variable and concatenate them into the columns of matrix d
d <- apply(as.matrix(data), 2, Dcenter)
# compute the regularised precision matrix of d
res <- corpcor::pcor.shrink(d)
res <- matrix(res,nrow(res),ncol(res))
return(res)
}