| sim_data_exp | R Documentation |
Simulate experiment-like data with independent binary Xs.
sim_data_exp(
n,
r.xy,
approx = TRUE,
tol = 0.01,
max.iter = 30,
verbose = FALSE,
seed = NULL
)
n |
Number of observations (cases). |
r.xy |
A vector of expected correlations of each X (binary independent variable: 0 or 1) with Y. |
approx |
Make the sample correlation matrix approximate more to values as specified in |
tol |
Tolerance of absolute difference between specified and empirical correlations. Defaults to |
max.iter |
Maximum iterations for approximation. More iterations produce more approximate correlations, but the absolute differences will be convergent after about 30 iterations. Defaults to |
verbose |
Print information about iterations that satisfy tolerance. Defaults to |
seed |
Random seed for replicable results. Defaults to |
Return a data.frame of simulated data.
sim_data()
data = sim_data_exp(n=1000, r.xy=c(0.5, 0.3), seed=1)
cor(data) # tol = 0.01
data = sim_data_exp(n=1000, r.xy=c(0.5, 0.3), seed=1,
verbose=TRUE)
cor(data) # print iteration information
data = sim_data_exp(n=1000, r.xy=c(0.5, 0.3), seed=1,
verbose=TRUE, tol=0.001)
cor(data) # more approximate, though not exact
data = sim_data_exp(n=1000, r.xy=c(0.5, 0.3), seed=1,
approx=FALSE)
cor(data) # far less exact
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.