77# ' @param ... Ignored.
88# '
99# ' @export
10- print.bgms <- function (x , ... ) {
11- arguments <- extract_arguments(x )
10+ print.bgms = function (x , ... ) {
11+ arguments = extract_arguments(x )
1212
1313 # Model type
1414 if (isTRUE(arguments $ edge_selection )) {
15- prior_msg <- switch (arguments $ edge_prior ,
15+ prior_msg = switch (arguments $ edge_prior ,
1616 " Bernoulli" = " Bayesian Edge Selection using a Bernoulli prior on edge inclusion" ,
1717 " Beta-Bernoulli" = " Bayesian Edge Selection using a Beta-Bernoulli prior on edge inclusion" ,
1818 " Stochastic-Block" = " Bayesian Edge Selection using a Stochastic Block prior on edge inclusion" ,
@@ -33,7 +33,7 @@ print.bgms <- function(x, ...) {
3333
3434 # Iterations and chains
3535 if (! is.null(arguments $ num_chains )) {
36- total_iter <- arguments $ iter * arguments $ num_chains
36+ total_iter = arguments $ iter * arguments $ num_chains
3737 cat(paste0(" Number of post-burnin MCMC iterations: " , total_iter , " \n " ))
3838 cat(paste0(" Number of MCMC chains: " , arguments $ num_chains , " \n " ))
3939 } else {
@@ -56,27 +56,27 @@ print.bgms <- function(x, ...) {
5656# '
5757# ' @return An object of class `summary.bgms` with posterior summaries.
5858# ' @export
59- summary.bgms <- function (object , ... ) {
60- arguments <- extract_arguments(object )
59+ summary.bgms = function (object , ... ) {
60+ arguments = extract_arguments(object )
6161
6262 if (! is.null(object $ posterior_summary_main ) && ! is.null(object $ posterior_summary_pairwise )) {
63- out <- list (
63+ out = list (
6464 main = object $ posterior_summary_main ,
6565 pairwise = object $ posterior_summary_pairwise
6666 )
6767
6868 if (! is.null(object $ posterior_summary_indicator )) {
69- out $ indicator <- object $ posterior_summary_indicator
69+ out $ indicator = object $ posterior_summary_indicator
7070 }
7171
7272 if (! is.null(object $ posterior_summary_pairwise_allocations )) {
73- out $ allocations <- object $ posterior_summary_pairwise_allocations
74- out $ mean_allocations <- object $ posterior_mean_allocations
75- out $ mode_allocations <- object $ posterior_mode_allocations
76- out $ num_blocks <- object $ posterior_num_blocks
73+ out $ allocations = object $ posterior_summary_pairwise_allocations
74+ out $ mean_allocations = object $ posterior_mean_allocations
75+ out $ mode_allocations = object $ posterior_mode_allocations
76+ out $ num_blocks = object $ posterior_num_blocks
7777 }
7878
79- class(out ) <- " summary.bgms"
79+ class(out ) = " summary.bgms"
8080 return (out )
8181 }
8282
@@ -89,20 +89,22 @@ summary.bgms <- function(object, ...) {
8989
9090
9191# ' @export
92- print.summary.bgms <- function (x , digits = 3 , ... ) {
92+ print.summary.bgms = function (x , digits = 3 , ... ) {
9393 cat(" Posterior summaries from Bayesian estimation:\n\n " )
9494
9595 if (! is.null(x $ main )) {
9696 cat(" Category thresholds:\n " )
97- print(round(head(x $ main , 6 ), digits = digits ))
97+ main = head(x $ main , 6 )
98+ main [] <- lapply(main , function (col ) ifelse(is.na(col ), " " , round(col , digits )))
99+ print(main )
98100 if (nrow(x $ main ) > 6 ) cat(" ... (use `summary(fit)$main` to see full output)\n " )
99101 cat(" \n " )
100102 }
101103
102104 if (! is.null(x $ pairwise )) {
103105 cat(" Pairwise interactions:\n " )
104- pair <- head(x $ pairwise , 6 )
105- pair [] <- lapply(pair , function (col ) ifelse(is.na(col ), " " , round(col , digits )))
106+ pair = head(x $ pairwise , 6 )
107+ pair [] = lapply(pair , function (col ) ifelse(is.na(col ), " " , round(col , digits )))
106108 print(pair )
107109 # print(round(head(x$pairwise, 6), digits = digits))
108110 if (nrow(x $ pairwise ) > 6 ) cat(" ... (use `summary(fit)$pairwise` to see full output)\n " )
@@ -116,8 +118,8 @@ print.summary.bgms <- function(x, digits = 3, ...) {
116118
117119 if (! is.null(x $ indicator )) {
118120 cat(" Inclusion probabilities:\n " )
119- ind <- head(x $ indicator , 6 )
120- ind [] <- lapply(ind , function (col ) ifelse(is.na(col ), " " , round(col , digits )))
121+ ind = head(x $ indicator , 6 )
122+ ind [] = lapply(ind , function (col ) ifelse(is.na(col ), " " , round(col , digits )))
121123 print(ind )
122124 if (nrow(x $ indicator ) > 6 ) cat(" ... (use `summary(fit)$indicator` to see full output)\n " )
123125 cat(" Note: NA values are suppressed in the print table. They occur when an indicator\n " )
@@ -168,29 +170,29 @@ print.summary.bgms <- function(x, digits = 3, ...) {
168170# ' }
169171# '
170172# ' @export
171- coef.bgms <- function (object , ... ) {
172- out <- list (
173+ coef.bgms = function (object , ... ) {
174+ out = list (
173175 main = object $ posterior_mean_main ,
174176 pairwise = object $ posterior_mean_pairwise
175177 )
176178 if (! is.null(object $ posterior_mean_indicator )) {
177- out $ indicator <- object $ posterior_mean_indicator
179+ out $ indicator = object $ posterior_mean_indicator
178180 }
179181
180182 if (! is.null(object $ posterior_mean_allocations )) {
181- out $ mean_allocations <- object $ posterior_mean_allocations
182- out $ mode_allocations <- object $ posterior_mode_allocations
183- out $ num_blocks <- object $ posterior_num_blocks
183+ out $ mean_allocations = object $ posterior_mean_allocations
184+ out $ mode_allocations = object $ posterior_mode_allocations
185+ out $ num_blocks = object $ posterior_num_blocks
184186 }
185187
186188 return (out )
187189}
188190
189191
190- .warning_issued <- FALSE
191- warning_once <- function (msg ) {
192+ .warning_issued = FALSE
193+ warning_once = function (msg ) {
192194 if (! .warning_issued ) {
193195 warning(msg , call. = FALSE )
194- .warning_issued <<- TRUE
196+ .warning_issued < = TRUE
195197 }
196198}
0 commit comments