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
[R-meta] rma.mv predict() with newmods
2 messages · Gram, Gil (IITA), Wolfgang Viechtbauer
13 days later
Dear Gil, I have a hard time reading this code. A small and fully reproducible example that illustrates the problem would be much easier to work with. But did you read the rest of the thread you posted? Especially: https://stat.ethz.ch/pipermail/r-sig-meta-analysis/2018-February/000585.html So, in case you haven't done so, make sure you (re)install the latest 'devel' version of the metafor package. Best, Wolfgang -----Original Message----- From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On Behalf Of Gram, Gil (IITA) Sent: Wednesday, 17 April, 2019 15:40 To: r-sig-meta-analysis at r-project.org Subject: [R-meta] rma.mv predict() with newmods 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