predict.formula | R Documentation |
Calculate model-predicted conditional and unconditional tie probabilities for dyads in the given network. Conditional probabilities of a dyad given the state of all the remaining dyads in the graph are computed exactly. Unconditional probabilities are computed through simulating networks using the given model. Currently there are two methods implemented:
Method for formula objects requires (1) an ERGM model formula with an existing network object on the left hand side and model terms on the right hand side, and (2) a vector of corresponding parameter values.
Method for ergm
objects, as returned by ergm()
, takes both the formula
and parameter values from the fitted model object.
Both methods can limit calculations to specific set of dyads of interest.
## S3 method for class 'formula'
predict(
object,
theta,
conditional = TRUE,
type = c("response", "link"),
nsim = 100,
output = c("data.frame", "matrix"),
...
)
## S3 method for class 'ergm'
predict(object, ...)
object |
a formula or a fitted ERGM model object |
theta |
numeric vector of ERGM model parameter values |
conditional |
logical whether to compute conditional or unconditional predicted probabilities |
type |
character element, one of |
nsim |
integer, number of simulated networks used for computing unconditional probabilities. Defaults to 100. |
output |
character, type of object returned. Defaults to |
... |
other arguments passed to/from other methods. For the |
Type of object returned depends on the argument output
. If
output="data.frame"
the function will return a data frame with columns:
tail
, head
– indices of nodes identifying a dyad
p
– predicted conditional tie probability
If output="matrix"
the function will return an "adjacency matrix" with the
predicted probabilities. Diagonal values are 0s.
# A three-node empty directed network
net <- network.initialize(3, directed=TRUE)
# In homogeneous Bernoulli model with odds of a tie of 1/5 all ties are
# equally likely
predict(net ~ edges, log(1/5))
# Let's add a tie so that `net` has 1 tie out of possible 6 (so odds of 1/5)
net[1,2] <- 1
# Fit the model
fit <- ergm(net ~ edges)
# The p's should be identical
predict(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.