SimulatedDataGenerator {BayesRGMM}R Documentation

Generate simulated data with either ARMA or MCD correlation structures.

Description

This function is used to generate simulated data for simulation studies with ARMA and MCD correlation structures.

Usage

SimulatedDataGenerator(
  Num.of.Obs,
  Num.of.TimePoints,
  Fixed.Effs,
  Random.Effs,
  Cor.in.DesignMat,
  Missing,
  Cor.Str,
  HSD.DesignMat.para,
  ARMA.para
)

Arguments

Num.of.Obs

the number of subjects will be simulated.

Num.of.TimePoints

the maximum number of time points among all subjects.

Fixed.Effs

a vector of regression coefficients.

Random.Effs

a list of covariance matrix and the degree of freedom,
e.g., list(Sigma = 0.5*diag(1), df=3).

Cor.in.DesignMat

the correlation of covariates in the design matrix.

Missing

a list of the missing mechanism of observations, 0: data is complete, 1: missing complete at random, 2: missing at random related to responses , and 3: 2: missing at random related to covariates and the corresponding regression coefficients (weights) on the previous observed values either responses or covariates, e.g., Missing = list(Missing.Mechanism = 3, RegCoefs = c(0.4, 1.2, -2.1)).

Cor.Str

the model for correlation structure, ⁠ARMA'' or ⁠HSD”.

HSD.DesignMat.para

if Cor.Str="HSD", you need to specify the list of parameters in HSD correlation structure,
e.g., HSD.DesignMat.para = list(HSD.para = HSD.para, DesignMat = w).

ARMA.para

if Cor.Str="ARMA", you need to specify the list of parameters in AMRA correlation structure, e.g., ARMA.para = list(AR.para=0.1, MA.para=0.2).

Value

a list containing the following components:

sim.data

The simulated response variables y, covariates x's, and subject identifcation ‘⁠id⁠’.

beta.true

The given values of fixed effects .

ARMA.para

The given values of parameters in ARMA model.

HSD.para

The given values of parameters in ARMA model.

Examples

## Not run: 
library(BayesRGMM)
rm(list=ls(all=TRUE))
Fixed.Effs = c(-0.2, -0.3, 0.8, -0.4) 
P = length(Fixed.Effs) 
q = 1 #number of random effects
T = 5 #time points
N = 100 #number of subjects
num.of.iter = 100 #number of iterations
HSD.para = c(-0.5,  -0.3) #the parameters in HSD model
a = length(HSD.para)
w = array(runif(T*T*a), c(T, T, a)) #design matrix in HSD model

for(time.diff in 1:a)
	w[, , time.diff] = 1*(as.matrix(dist(1:T, 1:T, method="manhattan")) 
 ==time.diff)

#Generate a data with HSD model
HSD.sim.data = SimulatedDataGenerator(Num.of.Obs = N, Num.of.TimePoints = T, 
Fixed.Effs = Fixed.Effs, Random.Effs = list(Sigma = 0.5*diag(1), df=3), 
Cor.in.DesignMat = 0., Missing = list(Missing.Mechanism = 2, 
 RegCoefs = c(-1.5, 1.2)), Cor.Str = "HSD", 
 HSD.DesignMat.para = list(HSD.para = HSD.para, DesignMat = w))

#the proportion of 1's
ones = sum(HSD.sim.data$sim.data$y==1, na.rm=T)
num.of.obs = sum(!is.na(HSD.sim.data$sim.data$y))
print(ones/num.of.obs) 

#the missing rate in the simulated data 
print(sum(is.na(HSD.sim.data$sim.data$y)))


#===========================================================================#
#Generate a data with ARMA model
ARMA.sim.data = SimulatedDataGenerator(Num.of.Obs = N, Num.of.TimePoints = T, 
	Fixed.Effs = Fixed.Effs, Random.Effs = list(Sigma = 0.5*diag(1), df=3), 
	Cor.in.DesignMat = 0., list(Missing.Mechanism = 2, RegCoefs = c(-1.5, 1.2)), 
	Cor.Str = "ARMA", ARMA.para=list(AR.para = 0.8))

## End(Not run)

[Package BayesRGMM version 2.2 Index]