Reputation: 59
I am trying to perform some mediation analysis with multiple binary mediators using the R package 'mma'.
I am using the following code:
dta <- read.dta13("Mediation_Dataset_R-R.dta")
dta <- na.omit(dta)
y <-dta[,12]
x <- dta[,c(1:6, 8:11, 13, 14)]
dta.bin <- data.org(x, y, pred = 8, binmed=c(4, 11, 12))
summary(dta.bin)
Where y is the binary dependent variable and x is a dataset that contains the covariates, mediators, and predictor variables. I then use the data.org function, assign the predictor and the binary mediators from the dataset x.
I keep getting the following error:
Error in family$linkfun(mustart) : Argument mu must be a nonempty numeric vector
From my understanding the purpose of this function is to determine whether the mediators are correlated with the predictor as well as the outcome. This function also structures the data for mediation analysis. I would greatly appreciate any insights.
Upvotes: 1
Views: 539
Reputation: 21
From help("data.org", "mma")
:
pred - the column or matrix of predictor(s): the predictor is the exposure variable, it can be a binary or multi-categorical factor or one/a few contiuous variable(s).
pred =
is the column or data frame of predictor(s). It is separate from x, the data frame of covariates and mediators. It cannot be 8, maybe dta[,8]
?
Upvotes: 1