Learn R Programming

RRreg (version 0.4.1)

RRsimu: Monte Carlo simulation for one or two RR variables

Description

Simulate and analyse bivariate data including either one RR variable (either correlation, logistic, or linear regression model) or two RR variables (only correlations). Useful for power analysis, parametric bootstraps or for testing the effects of noncompliance on the stability of estimates.

Usage

RRsimu(numRep, n, pi, model, p, cor = 0, b.log = 0, complyRates = c(1, 1),
  sysBias = c(0, 0), method = c("RRuni", "RRcor", "RRlog", "RRlin"),
  alpha = 0.05, groupRatio = 0.5, MLest = TRUE, getPower = TRUE,
  nCPU = 1)

Arguments

numRep
number of replications
n
sample size
pi
true proportion of carriers of sensitive attribute (for 2 RR variables: vector)
model
either one or two RR model (as vector), see RRuni
p
randomization probability (for 2 RR variables: a list). See RRuni for details.
cor
true Pearson-correlation used for data generation (for RRcor). Can also be used to generate data with two dichotomous RR variables.
b.log
true regression coefficient in logistic regression (for RRlog)
complyRates
vector with two values giving the proportions of participants who adhere to the instructions in the subset with or without the sensitive attribute, respectively (for 2 RR variables: a list)
sysBias
probability of responding 'yes' (coded as 1 in the RR variable) in case of non-compliance for carriers and non-carriers, respectively. See RRgen
method
vector specifying which RR methods to be used in each replication. For a single RR variable, the methods RRuni, RRcor,RRlog

Value

  • A list containing
  • parEstsmatrix containing the estimated parameters
  • resultsmatrix with mean parameters, standard errors, and number of samples to which the respective method could not be fitted
  • powervector with the estimated power of the selected randomized response procedures

Details

For a single RR variable: The parameter b.log is the slope-coefficient for the true, latent values in a logistic regression model that is used for data generation. The argument cor is used for data generation for linear models. The directly measured covariate is sampled from a normal distribution with shifted means, depending on the true state on the sensitive attribute (i.e., the true, underlying values on the RR variable). For dichotomous RR variables, this corresponds to the assumption of an ordinary t-test, where the dependent variable is normally distributed within groups with equal variance. The difference in means is chosen in a way, to obtain the point-biserial correlation defined by cor. For two RR variables: cor has to be used. In case of two dichotomous RR variables, the true group membership of individuals is sampled from a 2x2 cross table. Within this table, probabilities are chosen in a way, to obtain the point-tetrachoric correlation defined by cor Note, that for the FR model with multiple response categories (e.g., from 0 to 4), the specified cor is not the exact target of the sampling procedure. It assumes a normal distribution for each true state, with constant differences between the groups (i.e., it assumes an interval scaled variable).

Examples

Run this code
# Not run: Simulate data according to the Warner model
# mcsim <-  RRsimu(numRep=100, n=300, pi=.4,
#                  model="Warner", p=.2, cor=.3)
# print(mcsim)

Run the code above in your browser using DataLab