R/RcppExports.R

Defines functions create2x2TablesDAGRcpp simulateReport validReport

Documented in create2x2TablesDAGRcpp simulateReport validReport

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Valid Report
#' 
#' Checks whether the given report is 'valid'. A report should contain at least
#' one drug and at least one event (otherwise it would never been sent to the 
#' spontaneous reporitng sytem anyway).
#' 
#' @param report A logical matrix with one row and \code{n_drugs + n_events} columns
#' @param n_drugs The total number of drugs 
#' @param n_events The total number of events 
#' 
#' @return \code{TRUE} when the report is valid, \code{FALSE} otherwise
#' @export
validReport <- function(report, n_drugs, n_events) {
    .Call('_SRSim_validReport', PACKAGE = 'SRSim', report, n_drugs, n_events)
}

#' Simulate a single Report
#' 
#' Returns a single report for a spontaneous reporting system. 
#' Note that this function does not check whether the report is 
#' 'valid', see \code{\link{validReport}}
#' 
#' @param n_drugs The number of drugs 
#' @param n_events The number of events 
#' @param n_parents A vector with the number of parents for each of the nodes
#' @param beta0 A vector with the intercepts for the logistic regression models
#' @param beta1 A vector with the regression coefficients for each node 
#' @param parent_id A vector with the id of the parent 
#' 
#' @return A binary vector
simulateReport <- function(n_drugs, n_events, n_parents, beta0, beta1, parent_id) {
    .Call('_SRSim_simulateReport', PACKAGE = 'SRSim', n_drugs, n_events, n_parents, beta0, beta1, parent_id)
}

#' Create 2 x 2 Tables 
#' 
#' Creates a data frame containing all 2 x 2 contingency tables 
#' from the results generated by \code{\link{simulateSRS}}. 
#' See the R wrapper function \code{\link{convert2Tables}}
#' for more information. 
#' 
#' @param reports A binary matrix. Each row is a report
#' @param prob_drugs A vector with the marginal probabilities of the drugs 
#' @param prob_events A vector with the marginal probabilities of the events
#' @param n_parents A vector with the number of parents for each of the nodes
#' @param parent_id A vector with the id of the parent 
#' @param beta1 A vector with the regression coefficients for each node 
#' 
#' @return A dataframe. A description of the columns can be found in the commentary
#'         for the function \code{\link{convert2Tables}}
#' 
#' @seealso \code{\link{convert2Tables}}
create2x2TablesDAGRcpp <- function(reports, prob_drugs, prob_events, n_parents, parent_id, beta1) {
    .Call('_SRSim_create2x2TablesDAGRcpp', PACKAGE = 'SRSim', reports, prob_drugs, prob_events, n_parents, parent_id, beta1)
}
bips-hb/srsim documentation built on Dec. 10, 2020, 3:16 p.m.