R/is.valued.R

Defines functions is.valued.network is.valued.ergm is.valued.edgelist is.valued.ergm_state is.valued

Documented in is.valued is.valued.edgelist is.valued.ergm is.valued.ergm_state is.valued.network

#  File R/is.valued.R in package ergm, part of the
#  Statnet suite of packages for network analysis, https://statnet.org .
#
#  This software is distributed under the GPL-3 license.  It is free,
#  open source, and has the attribution requirements (GPL Section 7) at
#  https://statnet.org/attribution .
#
#  Copyright 2003-2023 Statnet Commons
################################################################################
#' Function to check whether an ERGM fit or some aspect of it is valued
#' @param object the object to be tested.
#' @param ... additional arguments for methods, currently unused.
#' @export
is.valued <- function(object, ...) UseMethod("is.valued")

#' @describeIn is.valued a method for [`ergm_state`] objects.
#' @export
is.valued.ergm_state <- function(object, ...){
  is.valued(object$el)
}

#' @describeIn is.valued a method for [`edgelist`] objects.
#' @export
is.valued.edgelist <- function(object, ...){
  ncol(object)>2
}

#' @describeIn is.valued a method for [`ergm`] objects.
#' @export
is.valued.ergm <- function(object, ...){
  # TODO: Delete the fallback after a few releases.
  NVL(object$info$valued, is.valued(object$network))
}

#' @describeIn is.valued a method for [`network`] objects that tests whether the network has been instrumented with a valued [`%ergmlhs%`] `"response"` specification, typically by [ergm_preprocess_response()]. Note that it is *not* a test for whether a network has edge attributes. This method is primarily for internal use.
#' @export
is.valued.network <- function(object, ...){
  NVL(attr(object %ergmlhs% "response", "valued"), FALSE)
}

Try the ergm package in your browser

Any scripts or data that you put into this service are public.

ergm documentation built on May 31, 2023, 8:04 p.m.