This function can be compared to ergm::ergm.exact with the statistics not
centered at `x`

, the vector of observed statistics.

exact_loglik(x, params, ..., as_prob = FALSE) # S3 method for default exact_loglik( x, params, stats_weights, stats_statmat, target_offset = double(nrow(x)), stats_offset = lapply(stats_weights, function(i) double(length(i))), ..., as_prob = FALSE ) exact_gradient(x, params, ...) # S3 method for default exact_gradient( x, params, stats_weights, stats_statmat, target_offset = double(nrow(x)), stats_offset = lapply(stats_weights, function(i) double(length(i))), ... ) exact_hessian( params, stats_weights, stats_statmat, stats_offset = lapply(stats_weights, function(i) double(length(i))) )

x | Matrix. Observed statistics |
---|---|

params | Numeric vector. Parameter values of the model. |

... | Arguments passed to the default methods. |

as_prob | Logical scalar. When |

stats_weights | Either an integer vector or a list of integer vectors (see exact_loglik). |

stats_statmat | Either a matrix or a list of matrices (see exact_loglik). |

target_offset | Numeric vector of length |

stats_offset | List of numeric vectors, each of length equal to the
lengths of vectors in |

One of the most important components of `ergmito`

is calculating the full
support of the model's sufficient statistics. Right now, the package uses
the function ergm::ergm.allstats which returns a list of two objects:

`weights`

: An integer vector of counts.`statmat`

: A numeric matrix with the rows as unique vectors of sufficient statistics.

Since `ergmito`

can vectorize operations, in order to specify weights and
statistics matrices for each network in the model, the user needs to pass
two lists `stats_weights`

and `stats_statmat`

. While both lists have to
have the same length (since its elements are matched), this needs not to
be the case with the networks, as the user can specify a single set of
weights and statistics that will be recycled (smartly).

In the case of offset terms, these can be passed directly via `target_offset`

and `stats_offset`

. The first is a numeric vector of length equal to the
number of networks in the model. The later is a list of vectors that is
matched against `stats_weights`

, so each of it's elements must be a
numeric vector of the same length that in the list of weights. By default
the offset terms are set to equal zero.

#> Warning: The observed statistics (target.statistics) are near or at the boundary of its support, i.e. the Maximum Likelihood Estimates maynot exist or be hard to be estimated. In particular, the statistic(s) "edges", "nodematch.female".# This computes the likelihood for all the networks independently with(ans$formulae, { exact_loglik( x = target_stats, params = coef(ans), stats_weights = stats_weights, stats_statmat = stats_statmat ) })#> [1] -3.053823 -1.816668 -1.938485 -3.220780 -4.640788# This should be close to zero with(ans$formulae, { exact_gradient( x = target_stats, params = coef(ans), stats_weights = stats_weights, stats_statmat = stats_statmat ) })#> [,1] #> [1,] -1.246365e-06 #> [2,] -1.188743e-06# Finally, the hessian with(ans$formulae, { exact_hessian( params = coef(ans), stats_weights = stats_weights, stats_statmat = stats_statmat ) })#> [,1] [,2] #> [1,] -11.855204 -8.470588 #> [2,] -8.470588 -8.470588