Skip to content

Commit 5f9a285

Browse files
Update examples
1 parent 14a804a commit 5f9a285

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

R/ccdrAlgorithm-main.R

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,22 @@ NULL
5858
#'
5959
#' @examples
6060
#'
61-
#' \dontrun{
62-
#'
6361
#' ### Generate some random data
6462
#' dat <- matrix(rnorm(1000), nrow = 20)
65-
#' dat <- sparsebnData(dat, type = "continuous")
63+
#' dat <- sparsebnUtils::sparsebnData(dat, type = "continuous")
6664
#'
6765
#' # Run with default settings
68-
#' ccdr.run(data = dat)
66+
#' ccdr.run(data = dat, lambdas.length = 20)
6967
#'
7068
#' ### Optional: Adjust settings
71-
#' pp <- ncol(dat)
69+
#' pp <- ncol(dat$data)
7270
#'
7371
#' # Initialize algorithm with a random initial value
7472
#' init.betas <- matrix(0, nrow = pp, ncol = pp)
7573
#' init.betas[1,2] <- init.betas[1,3] <- init.betas[4,2] <- 1
7674
#'
7775
#' # Run with adjusted settings
78-
#' ccdr.run(data = dat, betas = init.betas, lambdas.length = 10, alpha = 10, verbose = TRUE)
79-
#' }
76+
#' ccdr.run(data = dat, betas = init.betas, lambdas.length = 20, alpha = 10, verbose = TRUE)
8077
#'
8178
#' @export
8279
ccdr.run <- function(data,
@@ -223,6 +220,7 @@ ccdr_call <- function(data,
223220
# Still need to set start = 0, though.
224221
betas$start <- 0
225222
} # Type-checking for betas happens in ccdr_singleR
223+
226224
# This parameter can be set by the user, but in order to prevent the algorithm from taking too long to run
227225
# it is a good idea to keep the threshold used by default which is O(sqrt(pp))
228226
if(is.null(max.iters)){

R/ccdrAlgorithm-mvn.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@
2222
#' @param ivn List of interventions (see \code{\link[sparsebnUtils]{sparsebnData}}). Must be a \code{list} with exactly \code{n} components.
2323
#' @param ivn.rand If \code{TRUE}, random N(0,1) values will be drawn for each intervention. Otherwise, these values need to supplied manually in \code{ivn}.
2424
#'
25+
#' @examples
26+
#'
27+
#' ### Generate observational data
28+
#' gr <- sparsebnUtils::random.graph(5, 5) # use sparsebnUtils package to generate a random graph
29+
#' gr.params <- runif(10) # there are 5 coefficients + 5 variances
30+
#' data.obs <- ccdrAlgorithm::generate_mvn_data(graph = gr,
31+
#' n = 100,
32+
#' params = gr.params)
33+
#'
34+
#' ### Generate experimental data
35+
#' ivn <- as.list(c(rep("V1", 50), rep("V2", 50))) # 50 interventions on V1, 50 interventions on V2
36+
#' data.ivn <- ccdrAlgorithm::generate_mvn_data(graph = gr,
37+
#' n = 100,
38+
#' params = gr.params,
39+
#' ivn = ivn)
40+
#'
2541
#' @export
2642
generate_mvn_data <- function(graph, params, n = 1, ivn = NULL, ivn.rand = TRUE){
2743

man/ccdr.run.Rd

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/generate_mvn_data.Rd

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)