data("weight_behavior")
#binary x
#binary y
x=weight_behavior[,2:14]
y=weight_behavior[,15]
data.b.b.2.1<-data.org(x,y,pred=2,mediator=6:13,jointm=list(n=1,j1=c(6,8,10)),predref="M",
alpha=0.4,alpha2=0.4)
summary(data.b.b.2.1)
#Or you can specify the potential mediators and change the reference
#group for binary or categorical mediators. In the following code,
#potential continuous mediators are columns 8,9,10,12, and 13 of x,
#binary mediators are columns 7 and 11, and categorical mediator is
#column 6 of x with 1 to be the reference group for all categorical
#and binary mediators.
data.b.b.2<-data.org(x,y,pred=2,contmed=c(8:10,12:13),binmed=c(7,11),
binref=c(1,1),catmed=6,catref=1,jointm=list(n=1,j1=c(6,8,10)),predref="M",
alpha=0.4,alpha2=0.4)
summary(data.b.b.2)
#use the mediator argument instead of contmet, binmed and catmed
#continuous y
x=weight_behavior[,2:14]
y=weight_behavior[,1]
data.b.c.2<-data.org(x,y,pred=2,mediator=6:13,jointm=list(n=1,j1=8:10),
predref="M",alpha=0.4,alpha2=0.4)
summary(data.b.c.2)
#continuous x
#binary y
x=weight_behavior[,2:14]
y=weight_behavior[,15]
data.c.b.2<-data.org(x,y,pred=1,mediator=6:13,catref=1,jointm=list(n=2,j1=8:10,j2=c(6,8)),
alpha=0.4,alpha2=0.4)
summary(data.c.b.2)
#continuous y
x=weight_behavior[,2:14]
y=weight_behavior[,1]
data.c.c.2<-data.org(x,y,pred=1,contmed=c(8:10,12:13),binmed=c(7,11),
binref=c(1,1),catmed=6,catref=1,jointm=list(n=2,j1=8:10,j2=c(6,8)),
alpha=0.4,alpha2=0.4)
summary(data.c.c.2)
Run the code above in your browser using DataLab