Suppress warnings in l1()?
Closed this issue · 5 comments
Hi,
We just added a new method to the development version of R package netmeta which uses l1() inside netcontrib() to calculate network contributions (guido-s/netmeta@2bf0066).
Due to the network structure we have many zeros resulting in loads of warnings like
warning: solve(): system is singular; attempting approx solution
and
warning: solve(): system is singular (rcond: 1.38373e-39); attempting approx solution
Would it be possible to add an argument to l1() to suppress these warnings?
Or is there another possibility to get rid of the warnings?
Best,
Guido
P.S. See, e.g., the output of the following commands:
library("netmeta")
example(netcontrib)
netcontrib(net1, method = "cccp")
I should have said that we are already using this argument in our l1() call. Here is the printout for a reduced example (which produces fewer warnings):
> res <- l1(A1, optctrl = ctrl(trace=FALSE))
warning: solve(): system is singular (rcond: 1.90474e-18); attempting approx solution
warning: solve(): system is singular (rcond: 1.90474e-18); attempting approx solution
>
> res <- l1(A1, optctrl = ctrl(trace=TRUE))
warning: solve(): system is singular (rcond: 1.90474e-18); attempting approx solution
warning: solve(): system is singular (rcond: 1.90474e-18); attempting approx solution
Optimal solution found.
Does this mean that the argument ctrl(trace=FALSE) doesn't work as expected?
Neither suppressWarnings()
nor options(warn = -1)
suppresses the warnings.
Best wishes,
Guido
I fixed the problem in guido-s/netmeta@b376499 using
invisible(capture.output(..., type = "message"))
Thanks to @wviechtb to point me at https://stackoverflow.com/questions/49694552/suppress-messages-from-underlying-c-function-in-r .