statnet / tergm

Fit, Simulate and Diagnose Models for Network Evolution Based on Exponential-Family Random Graph Models
Other
27 stars 8 forks source link

Calling tergm() CMLE with networkDynamic input: Should times= be autodetected? #124

Open krivit opened 1 month ago

krivit commented 1 month ago

According to documentation, tergm(nwd~..., estimate="CMLE") with times= argument omitted should fit one transition, from time 0 to time 1. In actuality, it just crashes:

library(tergm)
dummy <- capture.output(example(networkDynamic))
cls33
#> NetworkDynamic properties:
#>   distinct change times: 513 
#>   maximal time range: 0 until  49 
#> 
#> Includes optional net.obs.period attribute:
#>  Network observation period info:
#>   Number of observation spells: 1 
#>   Maximal time range observed: 0 until 49 
#>   Temporal mode: continuous 
#>   Time unit: unknown 
#>   Suggested time increment: NA 
#> 
#>  Network attributes:
#>  ...
tergm(cls33~edges, estimate="CMLE")
#> Warning in min(times): no non-missing arguments to min; returning Inf
#> Warning in max(times): no non-missing arguments to max; returning -Inf
#> Error in abs(diff(times)): non-numeric argument to mathematical function

Since nobody is relying on the documented behaviour at the moment (because it doesn't work), we have some freedom to decide how we want it to behave. @martinamorris , @sgoodreau , @skyebend , @fl8410, thoughts?

  1. Fail with an informative error message.
  2. Plug in 0 -> 1 as documented with a warning.
  3. Use information in the networkDynamic object. (How?)
fl8410 commented 1 month ago

Hi Pavel, Thanks for looking into this!  As I was looking at the sample code and modifying it for my case, I noticed that the times argument was never used for the example with samplk1 and samplk2 even as the default looks only at 1 time change, assuming that the code would model all time points contrary to what is mentioned in the blurb about the times argument (which I admittedly skipped over just to do a basic test that my networkDynamic object was plausibly working).

For people like me who require more idiot-proofing, Option 1 (Fail with an informative error message about explicitly specifying time points would probably be the least hazardous for the thoughtless end user).  Yours,-Francis On Sunday, August 18, 2024 at 05:34:14 AM CDT, Pavel N. Krivitsky @.***> wrote:

According to documentation, tergm(nwd~..., estimate="CMLE") with times= argument omitted should fit one transition, from time 0 to time 1. In actuality, it just crashes: library(tergm) dummy <- capture.output(example(networkDynamic)) cls33

> NetworkDynamic properties:

> distinct change times: 513

> maximal time range: 0 until 49

>

> Includes optional net.obs.period attribute:

> Network observation period info:

> Number of observation spells: 1

> Maximal time range observed: 0 until 49

> Temporal mode: continuous

> Time unit: unknown

> Suggested time increment: NA

>

> Network attributes:

> ...

tergm(cls33~edges, estimate="CMLE")

> Warning in min(times): no non-missing arguments to min; returning Inf

> Warning in max(times): no non-missing arguments to max; returning -Inf

> Error in abs(diff(times)): non-numeric argument to mathematical function

Since nobody is relying on the documented behaviour at the moment (because it doesn't work), we have some freedom to decide how we want it to behave. @martinamorris , @sgoodreau , @skyebend , @fl8410, thoughts?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>