statnet / lolog

Latent Order Logistic (LOLOG) Graph Models
Other
5 stars 1 forks source link

nodeMix not available in directed network #7

Closed mds-hopp closed 8 months ago

mds-hopp commented 8 months ago

I'm using R v4.3.2 and lolog v1.3.1. As data I use a directed friendship network. When I run the estimation with "nodeMix" included, I received the following error message:

Error in .makeCppModelFromTerms(terms, net, theta, modelClass) : Error in model$addStatistic(names(stats)[i], stats[[i]]) : Unknown statistic: nodeMix

Other effects, such as nodeCov work flawlessly.

Code to reproduce the error:

library(lolog)
suppressPackageStartupMessages(library(ergm))
data(samplk)

lolog(samplk1 ~ edges() + 
        mutual() + 
        triangles() + 
        nodeMix("cloisterville"))
handcock commented 8 months ago

I think it is because nodeMix in lolog currently only supports undirected networks. For example,

suppressPackageStartupMessages(library(ergm))
data(florentine)
fnet <- as.BinaryNet(flomarriage)
fnet$variableNames()
# Create a discrete version of priorates
fnet[["priorates_cat"]] <- cut(flomarriage %v% "priorates",2)
fnet$variableNames()
# Fit, but edges() not needed
lolog(fnet ~  triangles() + 
        nodeMix("priorates_cat"))

It would be easy to add.

ifellows commented 8 months ago

Mark is correct. I believe it is just that it isn't exported in StatController.cpp. I've assigned myself the task.

ifellows commented 8 months ago

NodeMix has now been added for directed networks. @mds-hopp , install the package from github and the stat should be available.