Learn R Programming

NetMix (version 0.1.5)

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,
  parametric_mm = FALSE,
  forecast = FALSE,
  type = c("link", "response"),
  ...
)

Arguments

object

Object of class mmsbm.

new.data.dyad

An optional data.frame object.

new.data.monad

An optional data.frame object.

parametric_mm

oolean. Should the variational posterior be used for sampling the mixed-memberships (FALSE), or should the mixed-meberships be formed using the parameters in the monadic regression equation (TRUE)? Defaults to FALSE. If (new.data.monad | forcast) = TRUE, setting this to FALSE will produce an error.

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.

...

Currently ignored

Value

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

Examples

Run this code
# NOT RUN {
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,
                                           hessian = FALSE))

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

# }

Run the code above in your browser using DataLab