stocnet/rsiena

sienaDependent() from sparse matrices not accepted as valid object without covariate in sienaDataCreate()

Closed this issue · 2 comments

Describe the bug
An object created by sienaDependent from a list of sparse matrices is not accepted as a valid object in sienaDataCreate

To Reproduce
Sébastien described how to reproduce the error on groups.io in https://groups.io/g/RSiena/message/945

I tried running the lines proposed as example in the doc (https://search.r-project.org/CRAN/refmans/RSiena/html/sienaDependent.html):
sp501 <- as(Matrix(s501), "TsparseMatrix")
sp502 <- as(Matrix(s502), "TsparseMatrix")
sp503 <- as(Matrix(s503), "TsparseMatrix")
mymatlist <- list(sp501, sp502, sp503)
mynet.sp <- sienaDependent(mymatlist)
and then creating a sienaData object:
data.sp <- sienaDataCreate(mynet.sp)
but it gives me the same error as I had with my own data:
Error : invalid object in sienaDataCreate: argument number 1 is of class dgTMatrix , which is not a valid ... argument.
However, when I integrate some coCovar object in the sienaDataCreate function, it runs without problem:
smoke <- s50s
smoke1 <- coCovar(smoke[ , 1 ])
data.spbis <- sienaDataCreate(mynet.sp, smoke1)
returns no error.

I could solve Sébastien's issue temporarily by supplying sienaDependent via list():
data.sp <- sienaDataCreate(list(mynet.sp))

Using this circumvents the error, which might happen due to some interaction of sparse matrices with the substitution for an object with one argument in sienaDataCreate():

dots <- as.list(substitute(list(...)))[-1]
if (length(dots) == 1) {
        ldots <- list(...)
        dotsIsList <- (is.list(ldots[[1]]))
        if (dotsIsList) {
            dots <- as.list(substitute(...))[-1]
            narg <- length(ldots)
        } 

Expected behavior
sienaDependent() and sienaDataCreate() should work with a list of sparse matrices without a covariate.

Desktop (please complete the following information):

  • OS: Windows 10
  • R 4.2.1
  • RSiena 1.4.1 (but happens in 1.4.2 as well) and Matrix 1.6-4.

There's another issue with sparse matrices with just one tie in the first observed network described on groups.io Sébastien encountered and is due to some edge case behavior for sparse matrices with just one tie: https://groups.io/g/RSiena/message/946

Should I create a seperate issue for that or include it in this bug report?

Best Regards,

Daniel

I have been working on both problems and hope to have corrected them in the next version. No need to open a new issue.