R-studio and meta-analysis

Hi, I have been using Rstudio to do meta-analysis and meta-regression using metafor package. Recently, I updated Rstduio after which I am unable to do meta-regression. It keeps giving me the output - is.vector(x) is missing: argument (x) is missing. Thought if you guys could help.

Hi,

Welcome to the RStudio community!

Could you create us a reprex to show how the error is generated. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:

If the error is not because of an error in coding, it might be due to updates. Did you just update RStudio, or also R itself? The latest version of R (4.0) brought some new changes that might induce errors in packages that were not updated correctly. I don't know if this would be the case for the metaphor package, but it potentially could. You can see which version of R using when you open RStudio (console). The RStudio version can be found under help -> about RStudio.

PJ

Hello,

I am using Rstuido (Version 1.0.136 – © 2009-2016 RStudio, Inc). To estimate the effect size for binary outcomes between two groups, I am using metabin as

mor <-metabin(Ee, Ne, Ec, Nc, data = dataset, Authors, label.e = "experimental", label.c = "control")
mor

meta-regression for DM

metareg (mor, DM)
Error in is.vector(x) : argument "x" is missing, with no default

DM is identified by Rstudio when I summarize it. I tried working on csv, thought it could be excel related issue. No luck! It used to work fine but not sure what happened recently.

Hi,

Again, could you try and create a reprex. I can't really know for sure where the error lies if I can't recreate the issue. Try and provide my with a dummy dataset (doesn't need to be the one you're using) and the lines you need to run. (see the reprex link in my first post how to do this).

Also, your RStudio version is very much out of date though (2016), the current version is 1.2.5042 (2020). I suggest you update to the latest version, and also install the latest R version. Since R 4.0 should be the best, it still could be that the package has not updated, so you can also install R 3.6.3 and switch between versions in RStudio to see if it makes a difference. (tools -> global options -> general -> rversion).

Hope this helps,
PJ

Hello PJ,

I updated the Rstudio and R as you advised above. I re-ran the meta-regression and again noticed the same issue:

head(Book1)

A tibble: 6 x 9

Authors Ne Nc Ee Ec Age Male HTN DM

1 K et al 112 115 48 27 57 75 39 24
2 L et al 273 265 95 82 65 80 48 18
3 M et l 39 40 3 6 71 68 NA 20.5
4 N et al 275 524 96 251 65 79 26 13
5 O et al 18 18 9 6 61 86 42 17
6 P et al 130 73 35 23 55 77 44 18

mort<-metabin(Ee, Ne, Ec, Nc, data = Book1, Authors)
mort
RR 95%-CI %W(fixed) %W(random)
K et al 1.8254 [1.2320; 2.7047] 8.2 19.2
L et al 1.1246 [0.8826; 1.4329] 25.7 22.9
M et l 0.5128 [0.1378; 1.9079] 1.8 5.3
N et al 0.7288 [0.6060; 0.8764] 53.3 24.0
O et al 1.5000 [0.6739; 3.3388] 1.9 10.6
P et al 0.8545 [0.5497; 1.3283] 9.1 18.0

Number of studies combined: k = 6

                     RR           95%-CI     z p-value

Fixed effect model 0.9424 [0.8296; 1.0705] -0.91 0.3614
Random effects model 1.0467 [0.7458; 1.4691] 0.26 0.7919

Quantifying heterogeneity:
tau^2 = 0.1156; tau = 0.3399; I^2 = 77.9% [51.2%; 90.0%]; H = 2.13 [1.43; 3.17]

Test of heterogeneity:
Q d.f. p-value
22.67 5 0.0004

Details on meta-analytical method:

  • Mantel-Haenszel method
  • DerSimonian-Laird estimator for tau^2
  • Mantel-Haenszel estimator used in calculation of Q and tau^2 (like RevMan 5)

metareg(mort, Age)
Error in is.vector(x) : argument "x" is missing, with no default
metareg(mort, Male)
Error in is.vector(x) : argument "x" is missing, with no default

Looking forward for your input.

Hello,

Thanks for the more detailed explanation.

Unfortunately for me, you did not provide the data in format I could readily use, so I spent most of the time trying to get it into the correct format. Just for your information, these were the steps I had to perform before I could use the data

library(tidyverse)
library(datapasta)
#Select the tibble in the 'reprex' and copy it to clipboard
datapasta::df_paste()
test = data.frame(
                     stringsAsFactors = FALSE,
  cols = c("1 K et al 112 115 48 27 57 75 39 24",
                                          "2 L et al 273 265 95 82 65 80 48 18",
                                          "3 M et l 39 40 3 6 71 68 NA 20.5",
                                          "4 N et al 275 524 96 251 65 79 26 13",
                                          "5 O et al 18 18 9 6 61 86 42 17",
                                          "6 P et al 130 73 35 23 55 77 44 18")
)

test = test %>% 
  separate(cols, convert = T,
           into = c("Authors", "Ne", "Nc", "Ee", "Ec", "Age", "Male", 
                    "HTN", "DM", "w","x", "y", "z"))

test = test %>% mutate(Authors = paste(Ne, Nc, Ee))

test[2:9] = test[,5:12]
test = test[,1:9]
test[3,"DM"] = 20.5

head(test)
  Authors  Ne  Nc Ee  Ec Age Male HTN   DM
1 K et al 112 115 48  27  57   75  39 24.0
2 L et al 273 265 95  82  65   80  48 18.0
3  M et l  39  40  3   6  71   68  NA 20.5
4 N et al 275 524 96 251  65   79  26 13.0
5 O et al  18  18  9   6  61   86  42 17.0
6 P et al 130  73 35  23  55   77  44 18.0

So I recommend you read the reprex guide again so that in future you can provide us with a dataset that looks like this:

#Generate a table that can be copy pasted into a reprex
datapasta::tribble_paste(test)

tibble::tribble(
~Authors, ~Ne, ~Nc, ~Ee, ~Ec, ~Age, ~Male, ~HTN, ~DM,
"K et al", 112L, 115L, 48L, 27L, 57L, 75L, 39L, 24,
"L et al", 273L, 265L, 95L, 82L, 65L, 80L, 48L, 18,
"M et l", 39L, 40L, 3L, 6L, 71L, 68L, NA, 20.5,
"N et al", 275L, 524L, 96L, 251L, 65L, 79L, 26L, 13,
"O et al", 18L, 18L, 9L, 6L, 61L, 86L, 42L, 17,
"P et al", 130L, 73L, 35L, 23L, 55L, 77L, 44L, 18
)

Anyway :slight_smile: I get the following when I then run your code:

library(tidyverse)
library(metafor)
library(meta)

test = tibble::tribble(
  ~Authors,  ~Ne,  ~Nc, ~Ee,  ~Ec, ~Age, ~Male, ~HTN,  ~DM,
  "K et al", 112L, 115L, 48L,  27L,  57L,   75L,  39L,   24,
  "L et al", 273L, 265L, 95L,  82L,  65L,   80L,  48L,   18,
  "M et l",  39L,  40L,  3L,   6L,  71L,   68L,   NA, 20.5,
  "N et al", 275L, 524L, 96L, 251L,  65L,   79L,  26L,   13,
  "O et al",  18L,  18L,  9L,   6L,  61L,   86L,  42L,   17,
  "P et al", 130L,  73L, 35L,  23L,  55L,   77L,  44L,   18
)

mort<-metabin(Ee, Ne, Ec, Nc, data = test, Authors)
class(mort)
#> [1] "metabin" "meta"
metareg(mort, Age)
#> 
#> Mixed-Effects Model (k = 6; tau^2 estimator: DL)
#> 
#> tau^2 (estimated amount of residual heterogeneity):     0.1072 (SE = 0.1283)
#> tau (square root of estimated tau^2 value):             0.3274
#> I^2 (residual heterogeneity / unaccounted variability): 76.08%
#> H^2 (unaccounted variability / sampling variability):   4.18
#> R^2 (amount of heterogeneity accounted for):            7.17%
#> 
#> Test for Residual Heterogeneity:
#> QE(df = 4) = 16.7211, p-val = 0.0022
#> 
#> Test of Moderators (coefficient 2):
#> QM(df = 1) = 1.1886, p-val = 0.2756
#> 
#> Model Results:
#> 
#>          estimate      se     zval    pval    ci.lb   ci.ub 
#> intrcpt    2.4587  2.2202   1.1075  0.2681  -1.8927  6.8102    
#> Age       -0.0392  0.0360  -1.0902  0.2756  -0.1097  0.0313    
#> 
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

It seems that I am getting the correct results. Do you still get the error when you'd run my code?

PJ

Hi PJ,

Thank you for looking into it. I apologize for the data in reprex. I re-ran the metaregression and still getting the same error!

metareg(mort, Age)
Error in is.vector(x) : argument "x" is missing, with no default.

Not sure what am I doing incorrect.

Best,
R

Hi,

Just to be clear. You opened a new R-script, copy pasted the code I gave you and ran it, and then still got this error? In that case I don't really know what's going on since I can't recreate it. I might be able to alert the folk at RStudio of this, maybe they can help, but please first verify you did use my example in a new document.

PJ

Hi PJ,

After I opened a new R-script, I was able to run the meta-regression. Thank you so much for your help and patience. Just curious to know what was the issue.

Best,
r

1 Like