DOPE: Generate a distribution of possible effects.

Description Usage Arguments Value Examples

View source: R/combined.R

Description

Wrapper for parallel simfun. Takes a linear regression model fit by lm and returns the results information on the distribution of possible effects. Currently implimented in both R and C++. The C++ version is faster while the R version is easier for the expected user base to read and modify as needed.

Usage

1
  DOPE(mod,nsims=10000,language="cpp",n.cores=1,buff=sqrt(.Machine$double.eps))

Arguments

mod

A linear regression model fit by lm.

nsims

numeric. How many draws to take?

language

character, either "cpp" or "R" determining which implimentation to use.

n.cores

numeric. How many cores should the simulation be run on?

buff

numeric. A buffer to avoid numeric positive non-definiteness.

Value

Returns a data.frame of nsims + 1 rows, with the last row containing the input coefficients. Includes intercept, regressor coefficients, control function coefficient, and R-squared as columns.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  set.seed(8675309)
  x_vars <- 5
  n_obs <- 1000
  corm <- RandomCormCPP(nvars = x_vars)
  X_mat <- MASS::mvrnorm(n_obs, rep(0,x_vars), Sigma = corm, empirical = TRUE)
  
  betas <- 1:x_vars
  
  y <- X_mat 
  
  dat <- data.frame(y,X_mat)
  
  mod <- lm(y ~ ., data=dat)
  dope <- DOPE(mod, nsims = 3000, n.cores = parallel::detectCores())

christophercschwarz/DOPE documentation built on April 10, 2020, 4:43 a.m.