11# Bayesian --------------------------------------------------------------
22# =======================================================================
33
4-
54# ' @rdname get_predicted
65# ' @export
7- get_predicted.stanreg <- function (x ,
8- data = NULL ,
9- predict = " expectation" ,
10- iterations = NULL ,
11- ci = NULL ,
12- ci_method = NULL ,
13- include_random = " default" ,
14- include_smooth = TRUE ,
15- verbose = TRUE ,
16- ... ) {
6+ get_predicted.stanreg <- function (
7+ x ,
8+ data = NULL ,
9+ predict = " expectation" ,
10+ iterations = NULL ,
11+ ci = NULL ,
12+ ci_method = NULL ,
13+ include_random = " default" ,
14+ include_smooth = TRUE ,
15+ verbose = TRUE ,
16+ ... ) {
1717 check_if_installed(" rstantools" )
1818
1919 if (is.null(ci_method )) {
@@ -51,7 +51,8 @@ get_predicted.stanreg <- function(x,
5151 # }
5252
5353 # prepare arguments, avoid possible matching by multiple actual arguments
54- fun_args <- list (x ,
54+ fun_args <- list (
55+ x ,
5556 newdata = my_args $ data ,
5657 re.form = my_args $ re.form ,
5758 dpar = my_args $ distributional_parameter ,
@@ -82,8 +83,10 @@ get_predicted.stanreg <- function(x,
8283 model_family <- get_family(x )
8384 # exceptions
8485 is_wiener <- inherits(model_family , " brmsfamily" ) && model_family $ family == " wiener"
85- is_rtchoice <- model_family $ family == " custom" && model_family $ name == " lnr"
86- is_mixture <- model_family $ family == " mixture"
86+ is_rtchoice <- inherits(model_family , " brmsfamily" ) &&
87+ model_family $ family == " custom" &&
88+ model_family $ name == " lnr"
89+ is_mixture <- inherits(model_family , " brmsfamily" ) && model_family $ family == " mixture"
8790
8891 # Special case for rwiener (get choice 1 as negative values)
8992 # Note that for mv models, x$family returns a list of families
@@ -101,7 +104,10 @@ get_predicted.stanreg <- function(x,
101104 }
102105
103106 # Handle special cases
104- if (! my_args $ predict %in% c(" expectation" , " response" , " link" ) && inherits(model_family , " brmsfamily" )) {
107+ if (
108+ ! my_args $ predict %in% c(" expectation" , " response" , " link" ) &&
109+ inherits(model_family , " brmsfamily" )
110+ ) {
105111 if (is_wiener ) {
106112 # Wiener (Drift Diffusion) Models --------------------
107113 # ----------------------------------------------------
@@ -146,7 +152,7 @@ get_predicted.stanreg <- function(x,
146152 # pp_mixture returns an array with probs, SE and intervals.
147153 # if requested, we extract the intervals here for the "ci_data"
148154 # data.frame
149- res <- lapply (seq_len(nrow(mixture_output )), function (i ) {
155+ res <- lapply(seq_len(nrow(mixture_output )), function (i ) {
150156 max_prob <- which.max(mixture_output [i , 1 , ])
151157 data.frame (
152158 Probability = mixture_output [i , 1 , max_prob ],
0 commit comments