File: methods_ergm.R

package info (click to toggle)
r-cran-parameters 0.24.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,852 kB
  • sloc: sh: 16; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# .ergm, btergm -----------------------

#' @export
ci.btergm <- function(x, ci = 0.95, ...) {
  as.data.frame(ci(as.data.frame(x@boot$t), ci = ci, ...))
}


#' @export
standard_error.btergm <- function(model, ...) {
  cf <- model@coef
  bootstraps <- model@boot$t

  sdev <- sapply(seq_len(ncol(bootstraps)), function(i) {
    cur <- (bootstraps[, i] - cf[i])^2
    sqrt(sum(cur) / length(cur))
  })

  .data_frame(
    Parameter = insight::find_parameters(model, flatten = TRUE),
    SE = as.vector(sdev)
  )
}


#' @export
p_value.btergm <- function(model, ...) {
  stat <- insight::get_statistic(model)
  pval <- 2 * stats::pnorm(abs(stat$Statistic), lower.tail = FALSE)

  .data_frame(
    Parameter = stat$Parameter,
    p = pval
  )
}