Learn R Programming

ergm (version 3.0-3)

logLik.ergm: A logLik method for ergm.

Description

A function to return the log-likelihood associated with an ergm fit, evaluating it if necessary.

Usage

## S3 method for class 'ergm':
logLik(object, 
                      add=FALSE, 
                      force.reeval=FALSE, 
                      eval.loglik=add || force.reeval, 
                      control=control.logLik.ergm(), 
                      ...)

Arguments

object
An ergm fit, returned by ergm.
add
Logical: If TRUE, instead of returning the log-likelihood, return object with log-likelihood value set.
force.reeval
Logical: If TRUE, reestimate the log-likelihood even if object already has an estiamte.
eval.loglik
Logical: If TRUE, evaluate the log-likelihood if not set on object.
control
A list of control parameters for algorithm tuning. Constructed using control.logLik.ergm.
...
Other arguments to the likelihood functions.

Value

  • If add=FALSE (the default), a logLik object. If add=TRUE (the default), an ergm object with the log-likelihood set.

Details

If the log-likelihood was not computed for object, produces an error unless eval.loglik=TRUE

References

Hunter, D. R. and Handcock, M. S. (2006) Inference in curved exponential family models for networks, Journal of Computational and Graphical Statistics.

See Also

logLik, ergm.bridge.llr, ergm.bridge.dindstart.llk

Examples

Run this code
# See help(ergm) for a description of this model:
data(florentine)
gest <- ergm(flomarriage ~ kstar(1:2) + absdiff("wealth") + triangle, eval.loglik=FALSE)
# Log-likelihood is not evaluated, so no deviance, AIC, or BIC:
summary(gest)
# Evaluate the log-likelihood and attach it to the object.
gest <- logLik(gest, add=TRUE)
# Deviances, AIC, and BIC now shown:
summary(gest)

Run the code above in your browser using DataLab