Learn R Programming

BayesianFROC (version 1.0.0)

extract_EAP_by_array: Extract Etimates Preserving Array Format.

Description

Extract posterior mean extimates (EAP) by array format.

Usage

extract_EAP_by_array(StanS4class, name.of.parameter)

Arguments

StanS4class

An S4 object of class stanfitExtended which is an inherited class from the S4 class stanfit. This R object is a fitted model object as a return value of the function fit_Bayesian_FROC().

To be passed to DrawCurves() ... etc

name.of.parameter

An parameter name (given as a character string, should not surround by ""). The name of parameter which user want to extract. Parameters are contained in the parameter block of each Stan file in the path: inst/extdata.

Value

A list of datalists from the posterior predictive distribution

Details

If an estimate is an array, then this function extract estimated parameters preserving an array format. The rstan also has such function, i.e., rstan::get_posterior_mean(). However this function does not extract paramter as an array but coerce to the class matrix.

Examples

Run this code
# NOT RUN {
 
# }
# NOT RUN {
#=================================The first example: MRMC case ========================
#========================================================================================
#             MRMC case: Extract a estimates from fitted model objects
#========================================================================================


# Make a fitted model object of class stanfitExtended
# which is inherited from the S4class stanfit.
# The following example, fitted model is the hierarchical Bayesian FROC model
# which is used to compare modality.

 fit <- fit_Bayesian_FROC( ite  = 1111 ,
                           summary = FALSE   ,
                           dataList = dataList.Chakra.Web.orderd,
                           cha=1
                            )

#  Extract one dimensional array "z = z[]",

                  z   <- extract_EAP_by_array(
                                               fit,  # The above fitted model object
                                               z     # One of the parameter in "fit"
                                               )



#  Extract two dimensional array "AA = AA[ , ]",

                  AA  <- extract_EAP_by_array(
                                              fit,
                                              AA
                                              )


#  Extract three dimensional array "ppp = ppp[ , , ]",

                  ppp <- extract_EAP_by_array(fit,ppp)



#================= The second example: singler reader and single modality ==============
#========================================================================================
#             srsc case: Extract a estimates from fitted model objects
#========================================================================================


#   Of course, for the case of srsc, it is also available.
#   We shall show the case of srsc in which case the parameters are not array,
#   but in such a case we can extract estimates preserving its format such as vector.

 fit <- fit_Bayesian_FROC( ite  = 1111 ,
                           summary = FALSE   ,
                           dataList = dataList.Chakra.1,
                           cha=2
                            )

#  To extract the posterior mean for parameter "A" representing AUC, we run the following;


          A <- extract_EAP_by_array(
                                    fit,
                                     A
                                     )




#  To extract the posterior mean for parameter "z" indicating decision thresholds;


          z <- extract_EAP_by_array(
                                     fit,
                                     z
                                     )



# 2019.05.21 Revised.


#========================================================================================
#              name.of.parameter surrounded by double quote is also available
#========================================================================================


#      Let fit be the above fitted model object.
#      Then the following two codes are same.



                              extract_EAP_by_array( fit, "A" )

                              extract_EAP_by_array( fit,  A  )


# Unfortunately, the later case sometimes cause the R CMD check error which said
# that no visible binding, since object A is not defined.
# For example, if we use the later in the functiton: metadata_to_DrawCurve_MRMC
# Then R command said some NOTE that

# > checking R code for possible problems ... NOTE
# metadata_to_DrawCurve_MRMC: no visible binding for global variable 'A'
# Undefined global functions or variables: A

# Revised 2019 Oct 19





# I am not sure, does this package development make me happy?
# Back pain being due to an abnormality in my immune system, which is caused
# my exposure to surfactants or latex (not LaTeX).

# }
# NOT RUN {
# Revised 2019 Jun 19

# }

Run the code above in your browser using DataLab