modmedEquation: Make moderated mediation equation

Description Usage Arguments Examples

View source: R/modmedEquation.R

Description

Make moderated mediation equation

Usage

1
2
3
4
5
6
7
8
9
modmedEquation(
  X = "",
  M = NULL,
  Y = "",
  moderator = list(),
  labels = NULL,
  range = FALSE,
  covar = list()
)

Arguments

X

A character vectors indicating independent variables

M

A character vectors indicating mediators

Y

A character vectors indicating dependent variables

moderator

moderator

labels

labels

range

Whether or not add range equation

covar

Optional list of covariates

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
X="X";Y="Y"
moderator=list(name=c("Z"),site=list(c("a","c")))
cat(modmedEquation(X=X,Y=Y,moderator=moderator,range=TRUE))
X="X";M="M";Y="Y"
cat(modmedEquation(X=X,M=M,Y=Y,range=TRUE))
X="X";M="M";Y="Y"
moderator=list(name=c("Z"),site=list(c("a","c")))
cat(modmedEquation(X=X,M=M,Y=Y,moderator=moderator,range=TRUE))
X="X";M="M";Y="Y";labels=NULL;range=FALSE
moderator=list(name=c("X"),site=list(c("b")))
cat(modmedEquation(X=X,M=M,Y=Y,moderator=moderator,range=FALSE))
X="X";Y="Y"
moderator=list(name=c("Z"),site=list(c("c")))
cat(modmedEquation(X=X,Y=Y,moderator=moderator,range=FALSE))
covar=list(name=c("C1","C2","C3"),label=c("ese","sex","tenure"),site=list(c("M","Y"),"Y","Y"))
cat(modmedEquation(X=X,M="M",Y=Y,moderator=moderator,range=FALSE,covar=covar))

Example output

Registered S3 methods overwritten by 'broom':
  method            from  
  tidy.glht         jtools
  tidy.summary.glht jtools
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'. 

Y ~ c1*X+c2*Z+c3*X:Z
Z ~ Z.mean*1
Z ~~ Z.var*Z
M ~ a*X
Y ~ c*X + b*M
indirect :=(a)*(b)
direct :=c
total := direct + indirect
indirect.SDbelow :=(a)*(b)
indirect.SDabove :=(a)*(b)
direct.SDbelow:=c
direct.SDabove:=c
total.SDbelow := direct.SDbelow + indirect.SDbelow
total.SDabove := direct.SDabove + indirect.SDabove
prop.mediated.SDbelow := indirect.SDbelow / total.SDbelow
prop.mediated.SDabove := indirect.SDabove / total.SDabove
M ~ a1*X+a2*Z+a3*X:Z
Y ~ c1*X+c2*Z+c3*X:Z + b*M
Z ~ Z.mean*1
Z ~~ Z.var*Z
indirect :=(a1+a3*Z.mean)*(b)
direct :=c1+c3*Z.mean
total := direct + indirect
indirect.SDbelow :=(a1+a3*(Z.mean-sqrt(Z.var)))*(b)
indirect.SDabove :=(a1+a3*(Z.mean+sqrt(Z.var)))*(b)
direct.SDbelow:=c1+c3*(Z.mean-sqrt(Z.var))
direct.SDabove:=c1+c3*(Z.mean+sqrt(Z.var))
total.SDbelow := direct.SDbelow + indirect.SDbelow
total.SDabove := direct.SDabove + indirect.SDabove
prop.mediated.SDbelow := indirect.SDbelow / total.SDbelow
prop.mediated.SDabove := indirect.SDabove / total.SDabove
index.mod.med := a3*b
M ~ a*X
Y ~ c*X + b1*M+b2*M:X
X ~ X.mean*1
X ~~ X.var*X
indirect :=(a)*(b1+b2*X.mean)
direct :=c
total := direct + indirect

Y ~ c1*X+c2*Z+c3*X:Z
Z ~ Z.mean*1
Z ~~ Z.var*Z
M ~ a*X
Y ~ c1*X+c2*Z+c3*X:Z + b*M + g1*C1 + g2*C2 + g3*C3
Z ~ Z.mean*1
Z ~~ Z.var*Z
indirect :=(a)*(b)
direct :=c1+c3*Z.mean
total := direct + indirect

processR documentation built on Jan. 7, 2021, 9:06 a.m.