ErrorCheck: ErrorCheck

Description Usage Arguments Value Author(s)

View source: R/ErrorCheck.R

Description

Performs error checks on the input for the Umediation function.

Usage

1
2
3
   ErrorCheck<-function(n=1000,Atype="D",Mtype="C",Ytype="C",Ctype="C",Utype="C",interact=FALSE,muC=0,varC=1,muU=0,varU=1,
                        gamma0=0,gammaC=0,gammaU=0,varA=1,alpha0=0,alphaA=0,alphaC=0,alphaU=0,varM=1,beta0=0,betaA=0,betaM=0,
                        betaI=0,betaC=0,betaU=0,varY=1,alpha=0.05,nSim=300,nBoot=500)

Arguments

n

is the sample size of the population that is being simulated.

Atype

is either "C" for continuous, normally distributed exposure A or "D" for dichotomous, binary exposure A (i.e. Atype=”D”).

Mtype

is either "C" continuous, normally distributed mediator M or "D" for dichotomous, binary mediator M (i.e. Mtype=”C”).

Ytype

is either "C" for continuous, normally distributed outcome Y or "D" for dichotomous, binary outcome Y (i.e. Ytype=”D”).

Ctype

is either "C" for continuous, normally distributed measured confounder C or "D" for dichotomous, binary measured confounder C. Ctype can be a single value (i.e. Ctype=”C”) or a vector for multiple measured confounders (i.e. Ctype=c(”C”,”C”,”D”) ).

Utype

is either "C" for continuous, normally distributed unmeasured confounder U or "D" for dichotomous, binary unmeasured confounder U. Utype can be a single value (i.e. Utype=”C”) or a vector for multiple measured confounders (i.e. Utype=c(”C”,”C”,”D”) ).

interact

Using the flag interact=TRUE allows for an interaction between the exposure A and the mediator M on the outcome Y (i.e. E[Y]=beta0+betaA*A+betaM*M+betaC*C+betaU*U+betaI*A*M). By default, interact=FALSE (i.e. E[Y]=beta0+betaA*A+betaM*M+betaC*C+betaU*U).

muC

is the mean vector for the measured confounder C. For continuous measured confounder (i.e. Ctype=”C”), muC is the mean of C. For dichotomous measured confounder C (i.e. Ctype=”D”), muC is the probability C=1.

varC

is the variance of the measured confounder C when Ctype=”C”. For multiple measured confounders, the length of varC must match muC and Ctype (i.e. Ctype=c(”C”,”C”,”D”) and muC=c(-0.1,0.2,0.3) and varC=c(1,1,1))

muU

is the mean vector for the unmeasured confounder U. For continuous unmeasured confounder (i.e. Utype=”C”), muU is the mean of U. For dichotomous unmeasured confounder U (i.e. Utype=”D”), muU is the probability U=1.

varU

is the variance of the unmeasured confounder U when Utype=”C”. For multiple unmeasured confounders, the length of varU must match muU and Utype (i.e. Utype=c(”C”,”C”,”D”) and muU=c(-0.1,0.2,0.3) and varU=c(1,1,1))

gamma0

specifies the intercept for the exposure A (i.e. logit(P(A=1)) or E[A]=gamma0+gammaU*U+gammaC*C).

gammaC

specifies the relationship between the measured confounder C and the exposure A (i.e. logit(P(A=1)) or E[A]=gamma0+gammaU*U+gammaC*C).

gammaU

specifies the relationship between the measured confounder U and the exposure A (i.e. logit(P(A=1)) or E[A]=gamma0+gammaU*U+gammaC*C).

varA

is the variance of the exposure A when Atype=”C”. Default is varA=1.

alpha0

specifies the intercept for the mediator M (i.e. Logit(P(M=1)) or E[M]=alpha0+alphaA*A+alphaC*C+alphaU*U).

alphaA

specifies the relationship between the exposure A and the mediator M (i.e logit(P(M=1)) or E[M]=alpha0+alphaA*A+alphaC*C+alphaU*U).

alphaC

specifies the relationship between the measured confounder C and the mediator M (i.e. E[M] or logit(P(M=1))=alpha0+alphaA*A+alphaC*C+alphaU*U).

alphaU

specifies the relationship between the unmeasured confounder U and the mediator M (i.e. E[M] or logit(P(M=1))=alpha0+alphaA*A+alphaC*C+alphaU*U).

varM

is the variance of the mediator M when Mtype=”C”. Default is varM=1.

beta0

specifies the intercept for the outcome Y (i.e. logit(P(Y=1)) or E[Y]=beta0+betaA*A+betaM*M+betaI*A*M+betaC*C+betaU*U).

betaA

specifies the relationship between the exposure A and the outcome Y (i.e. E[Y] or logit(P(Y=1))=beta0+betaA*A+betaM*M+betaI*A*M+betaC*C+betaU*U).

betaM

specifies the relationship between the mediator M and the outcome Y (i.e. E[Y] or logit(P(Y=1))=beta0+betaA*A+betaM*M+betaI*A*M+betaC*C+betaU*U).

betaI

specifies the interaction between the mediator M and the exposure A on the outcome Y (i.e. E[Y] or logit(P(Y=1))= beta0+betaA*A+betaM*M+betaI*A*M+betaC*C+betaU*U) when the flag interact=TRUE.

betaC

specifies the relationship between the measured confounder C and the outcome Y (i.e. E[Y] or logit(P(Y=1))=beta0+betaA*A+betaM*M+betaI*A*M+betaC*C+betaU*U).

betaU

specifies the relationship between the unmeasured confounder U and the outcome Y (i.e. E[Y] or logit(P(Y=1))=beta0+betaA*A+betaM*M+betaI*A*M+betaC*C+betaU*U).

varY

is the variance of the outcome Y when Ytype=”C”. Default is varY=1.

alpha

is the significance level. Default value is alpha=0.05.

nSim

is the number of simulations run for the function. The more simulations run, the more accurate the results, but this will make the function slower.

nBoot

is the number of Monte Carlo draws for nonparametric bootstrap or quasi-Bayesian approximation for the mediate function.

seed

sets the seed used for the random generator.

seed

sets the seed used for the random generator.

atreat

sets the treatment group for the exposure A.

acontrol

sets the control group for the exposure A.

Value

The function exits with an error message if the error checks are not met.

Author(s)

Sharon Lutz, Annie Thwing


SharonLutz/Umediation documentation built on May 28, 2021, 6:39 a.m.