Learn R Programming

NetMix (version 0.2.0.3)

predict.mmsbm: Predict edges based on estimated mmsbm model

Description

The function produces expected posterior edges based on estimated parameters and (optionally new) predictor data

Usage

# S3 method for mmsbm
predict(
  object,
  new.data.dyad = NULL,
  new.data.monad = NULL,
  forecast = FALSE,
  type = c("link", "response", "mm"),
  ...
)

Value

If new.data.dyad = NULL, vector of length nrow(object$dyadic.data). Else, vector of length nrow(new.data.dyad).

Arguments

object

Object of class mmsbm.

new.data.dyad

An optional data.frame object.

new.data.monad

An optional data.frame object.

forecast

Boolean. Should prediction forcast one step into the future? Defaults to FALSE.

type

Character string. The default is to use the linear predictor of edges. The alternative "response" returns predicted probabilities. The alternative "mm" returns predicted mixed-membership vectors.

...

Currently ignored

Author

Santiago Olivella (olivella@unc.edu), Adeline Lo (aylo@wisc.edu), Tyler Pratt (tyler.pratt@yale.edu), Kosuke Imai (imai@harvard.edu)

Examples

Run this code
library(NetMix)
## Load datasets
data("lazega_dyadic")
data("lazega_monadic")
## Estimate model with 2 groups
lazega_mmsbm <- mmsbm(SocializeWith ~ Coworkers,
                      ~  School + Practice + Status,
                      senderID = "Lawyer1",
                      receiverID = "Lawyer2",
                      nodeID = "Lawyer",
                      data.dyad = lazega_dyadic,
                      data.monad = lazega_monadic,
                      n.blocks = 2,
                      mmsbm.control = list(seed = 123,
                                           conv_tol = 1e-2, 
                                           hessian = FALSE))

## Get in-sample predicted edge probabilities
lazega_preds <- predict(lazega_mmsbm, type = "response")

Run the code above in your browser using DataLab