spass (version 1.2)

r.1subgroup: Generate dataset of normal distributed observations in a one subgroup design

Description

r.1subgroup generates data for a design with one subgroup within a full population. Each observation is normal distributed with mean 0 in the placebo group and a potential effect in the treatment group. Whether the effect is solely in the subgroup or additionally a certain amount outside of the subgroup can be specified as well as potentially different variances within the subgroup and outside of the subgroup.

Usage

r.1subgroup(n, delta, sigma, tau, fix.tau = c("YES", "NO"), k)

Arguments

n

number of observations. If length(n) > 1, the length is taken to be the number required.

delta

vector of treatment effects in the treatment group, c(outside subgroup, within subgroup).

sigma

vector of standard deviations, c(outside subgroup, inside subgroup).

tau

subgroup prevalence.

fix.tau

subgroup prevalence fix or simulated according to tau, see 'Details'.

k

sample size allocation factor between groups: see 'Details'.

Value

r.1subgroup returns a data matrix of dimension n x 3. The first column TrPl defines whether the observation belongs to the treatment group (TrPl=0) or to the placebo group (TrPl=1). Second column contains the grouping variable FS. For FS=1 the observation stems from the subgroup, for FS=0 from the full population without the subgroup. In the last column value the observation can be found. between time points.

Details

For delta\(=(\Delta_F\S, \Delta_S)'\) and sigma\(=(\sigma_F\S, \sigma_S)'\) this function r.1subgroup generates data as follows:

Placebo group outside of subgroup \(~N(0,\sigma^2_F\S)\), Placebo group within subgroup \(~N(0,\sigma^2_S)\), Treatment group outside of subgroup \(~N(\Delta_F\S,\sigma^2_F\S)\), Treatment group within subgroup \(~N(\Delta_S,\sigma^2_S)\).

If fix.tau=YES the subgroup size is generated according to the prevalence tau, i.e. \(n_S=\tau*n\). If fix.tau=YES, then each new generated observations probability to belong to the subgroup is \(Ber(\code{tau})\) distributed and therefore only \(E(n_s)=\tau*n\) holds.

The argument k is the sample size allocation factor, i.e. let \(n_C\) and \(n_T\) denote the sample sizes of of the control and treatment group, respectively, then \(k = n_T/n_C\).

Examples

Run this code
# NOT RUN {
set.seed(142)
random<-r.1subgroup(n=50, delta=c(0,1), sigma=c(1,1), tau=0.4, fix.tau="YES", k=2)
random 
# }

Run the code above in your browser using DataCamp Workspace