dosresmeta - Error on restricted cubic spline modeling

Hi, fellow statisticians! I am very new to R.

I am currently trying to learn to do dose-response meta-analysis using the command dosresmeta. !

I used the dataset published by Shim et al

When I tried to test for non-linearity with the restricted cubic spline model, the commands returned error:

knots_bin <- quantile(databin$dose, c(.05, .35, .65, .95))
> spline <- dosresmeta(formula=logrr ~ rcs(dose, knots_bin), type=type, id=id, se=se, cases=cases, n=n, method="fixed", data=databin)

## This is the error code
Error in[v != 0, , drop = FALSE], Z[v != 0, , drop = FALSE],  : 
  A two-stage approach requires that each study provides at least p non-referent obs (p is the number of columns of the design matrix X)

note that databin is the dataset I am using

I tried to look up to the [source code] for dosresmeta, and the syntax states the following:

   m <- length(unique(id))
   k <- table(id)
   p <- ncol(X)
   q <- ncol(Z)
   nay <-
   n <- nrow(y)
   nall <- sum(!nay)
   ## names for coefficient
   np <- colnames(X)
   if (is.null(np))
      np <- paste("X", seq(p), sep = "")
   nq <- colnames(Z)
   if (is.null(nq))
      nq <- paste("Z", seq(q), sep = "")
   ny <- colnames(y)
   if (is.null(ny))
      ny <- "y"
   ylist <- lapply(unique(id), function(j) y[id == j, ][!nay[j, ]])
   Xlist <- lapply(unique(id), function(j) X[id == j, , drop = FALSE][
      !nay[j, ], , drop = FALSE])
   Zlist <- lapply(unique(id), function(j) Z[id == j, , drop = FALSE][
      !nay[j, ], , drop = FALSE])
   nalist <- lapply(unique(id), function(j) nay[id == j])

## This is the source code for the error
   if (proc == "2stage"){
      if (any(k < p)){
         stop("A two-stage approach requires that each study provides at least p non-referent obs (p is the number of columns of the design matrix X)")

Does anyone know which part of my spline command caused the error? I managed to do the command with one-stage process, but I think with this model, two-stage process is more appropriate.

Please help, any help will be much appreciated. Thank you very much


looking up shows

   k <- table(id)
   p <- ncol(X)

Thank you very much for your answer.

I noticed the statement that k might be smaller than p

k <- table(id)
   p <- ncol(X)

I assume the variable k returns value 4, but how can I check the value of p? And possible, which value can I modify to correct the error?

Once again, thanks


i think id refers to the id you passed in, id 3 has 3 rows in your screenshot so sometimes its less than 4.
I don't know the genesis of X...
it might be

X <- model.matrix(attr(mfmX, "terms"), data = mfmX)[, 
        -1, drop = FALSE]

and it seems like

fmX <- model.frame(formulaMod, data)

I see, so is it a limitation of the dosresmeta package?

I think Stata's glst command computes study-specific non-linear slopes and combines them at the end; so the number of non-referent obs does not matter as long as it is >2 obs...

I am referring to the dose-response meta-analysis tutorial in Stata by Shim et al.

Reference: Shim SR, Shin IS, Yoon BH, Bae J-M. Dose-response meta-analysis using STATA software. J Health Info Stat. 2016;41(3):351-8

Is there any alternative to solve this matter?

Thank you very much


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.