R: How to fix "Error: unused argument (verbose = FALSE)"?
01:33 01 Oct 2026

I'm conducting an MGM network analysis in R (via the bootnet package) and am trying to compare edge weights across two networks (via the NetworkComparisonTest package). I have missing data, so I'm using an imputation estimator function for MGMs (source: https://osf.io/vufj4/files/watkp) that I made very minor modifications to to fit my data.

The code works up until I try to run NCT(), which throws the error:

Error in (function (x, nImpute = 10, type, level) : unused argument (verbose = FALSE)

It appears the issue lies with the impute_estimator function, but I can't figure out what I'm doing wrong. Admittedly I'm not good or experienced at defining my own functions, but I've tried some things (e.g., defining the verbose argument within the NCT function, adding ", ..." to the end of the impute_estimator function) and the error persists.

Below is a minimum, reproducible example that should reproduce the error using a small dataset from the mice package. Would really appreciate any assistance or insight!

library(readxl)
library(tidyverse)
library(mice)

# creating sample data; need to make sure all categories are represented for age and hyp #### 
data1 <- nhanes |> slice_sample(n=50, replace=TRUE) |> mutate(hyp=hyp-1)
data2 <- nhanes |> slice_sample(n=50, replace=TRUE) |> mutate(hyp=hyp-1)

# Multiple imputation estimator function for mgm:
impute_estimator <- function(x, nImpute = 10, type, level){
        library("mice")
        library("bootnet")
        library("abind")
        library("mgm")
        
        # Impute missing data:
        miceres <- mice(x, m = nImpute, seed = 500, use.matcher = TRUE)
        
        # Results:
        graphs <- lapply(seq_len(nImpute), function(i){
                imp <- complete(miceres, i)
                
                # Estimate the network:
                net <- estimateNetwork(imp, default = "mgm", type = type, level = level, 
                                           criterion  = "EBIC", rule="AND", tuning = 0.25,
                                           binarySign = TRUE)
                
                # Return graph:
                return(net$graph)                
        })
        
        # Make array:
        array <- do.call(abind,c(graphs,list(along=3)))
        
        # Average and retain only edges included in all imputations:
        final <- apply(array,1:2,function(x){
                (mean(x!=0)>=0.9) * mean(x)
        })
        
        # Return:
        return(final)
} 

type_mgm=c("c","g","c","g")
level_mgm=c("3","1","2","1")

# computing networks ####
library(bootnet)
network1 <- estimateNetwork(
  data=data1,
  fun=impute_estimator,
  type=type_mgm,
  level=level_mgm
)
network2 <- estimateNetwork(
  data=data2,
  fun=impute_estimator,
  type=type_mgm,
  level=level_mgm
)

# NCT #### (where error pops up) 
library(NetworkComparisonTest)

NCT(network1, network2, 
           it=2, 
           test.edges=T, 
           edges="all",
           p.adjust.methods = "holm"
          )
r r-mice network-analysis