[R-meta] rma.mv predict() with newmods

Gram, Gil (IITA) G@Gr@m @end|ng |rom cg|@r@org
Wed Apr 17 15:39:38 CEST 2019


Dear Wolfgang and the Metafor community,


I’m running in the same problem Cesar Terrer Moreno ran into a while ago without response (https://stat.ethz.ch/pipermail/r-sig-meta-analysis/2018-February/000582.html). When running the predict(newmods) function on my rma.mv model, I get the error "Multiple matches for the same variable name.” I’ve tried 2 different ways, and also tried looking at the function code on Github, in vain.

# My model based on a dataset of 3941 rows:
# ML_intRate_TiQ2 = rma.mv(yi, vi, method = 'ML', struct="UN", sparse=TRUE, data=dat, # mods = ~ classOR:totalN + classMR:totalN + classMR:classOR:totalN + classOR:I(totalN^2) + classMR:I(totalN^2) + classMR:classOR:I(totalN^2) + classMR:classOR:time:totalN + cropSys + idF, # random = list(~1|ref, ~1|idRow, ~ treatment|idSite, ~ treatment|idSite.time))
# where
# classOR —> "zero" "one" "two" "three" "four" "Manure"
# classMR —> "0" “1"
# totalN —> numerical value ranging [0:720]
# time —> numerical value ranging [0:26]
# First level of cropSys = ‘biomass'
# First level of idF = ’NPK’
# treatment —> "Control" "MR" "OR" "ORMR"

# 1. First method X <- expand.grid(totalN = 0:250 , classOR = levels(dtRMA$classOR) , classMR = levels(dtRMA$classMR) # , time = 0:26 , cropSys = levels(dtRMA$cropSys)[1] , idF = levels(dtRMA$idF)[1]) predict(MOD, newmods = X, tau2.levels = c('Control', 'OR', 'MR', 'ORMR'), gamma2.levels = c('Control', 'OR', 'MR', 'ORMR'))
# 2. Second method X <- model.matrix(~ classOR:totalN + classMR:totalN + classMR:classOR:totalN + classOR:I(totalN^2) + classMR:I(totalN^2) + classMR:classOR:I(totalN^2) + classMR:classOR:time:totalN + cropSys + idF, data=dtRMA_rate) predict(MOD, newmods = X, tau2.levels = c('Control', 'OR', 'MR', 'ORMR'), gamma2.levels = c('Control', 'OR', 'MR', 'ORMR'))


Looking forward to some feedback!



Gil Gram
PhD researcher  |  Natural resource management/CCAFS
International Institute of Tropical Agriculture (IITA)
East African Hub/Kampala/Country office
Address: IITA-Uganda Plot 15B, Naguru East Road. P.O Box 7878, Kampala
Mobile: +256 755 315236  |  Belgium Mobile: +32 484 981200
Skype: gil.gram


	[[alternative HTML version deleted]]



More information about the R-sig-meta-analysis mailing list