extract_EAP_by_array: Extract Etimates Preserving Array Format.

Description Usage Arguments Details Value Examples

View source: R/extract_EAP_by_array.R

Description

Extract posterior mean extimates (EAP) by array format.

Usage

1
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.

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.

Value

A list of datalists from the posterior predictive distribution

Examples

  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
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 ## 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).


## End(Not run)# Revised 2019 Jun 19

BayesianFROC documentation built on Jan. 23, 2022, 9:06 a.m.