extract_EAP_CI: Extracts Estimates as vectors from stanfit objects

Description Usage Arguments Details Value See Also Examples

View source: R/extract_EAP_by_array.R

Description

We extract posterior means (in other words, Expected a Posterior:EAP) and credible intervals (CIs) from objects of stanfitExtended S4 class which is an inherited class of the stanfit S4 class.

Usage

1
2
3
4
5
6
7
extract_EAP_CI(
  StanS4class,
  parameter.name,
  dimension.of.parameter,
  dig = 5,
  summary = TRUE
)

Arguments

StanS4class

An S4 object of the class stanfit. No need that it is the S4 class stanfitExtended.

parameter.name

character vector. E.g., it is "aaa" for names of parameters described in the parameter block of stan file.

dimension.of.parameter

If parameter aaa is vector, i.e.,aaa[1],aaa[2],...aaa[6] then dimension.of.parameter = 6

dig

A variable to be passed to the function rstan::sampling() of rstan in which it is named ...??. A positive integer representing the Significant digits, used in stan Cancellation. Default = 5,

summary

Logical: TRUE of FALSE. Whether to print the verbose summary. If TRUE then verbose summary is printed in the R console. If FALSE, the output is minimal. I regret, this variable name should be verbose.

Details

Merely, extracts estimates from stanfit objects.

Value

EAPs, CI.

See Also

extract_estimates_MRMC

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
## Not run: 
# (1) we  fit a model to data and resulting object has the S4-class stanfitExtend.


   fit <- fit_Bayesian_FROC(
                       BayesianFROC::dataList.Chakra.Web.orderd, # data
                              ite = 1111,                        # MCMC iteration
                              summary = FALSE                    # vervose
   )



# (2) To extract the EAPs of the parameter z,
#     we need to specify the dimension of vector z as follows.


       extract_EAP_CI(

                 fit,  #  The above fitted model object
                 "z",  #  The parameter name described in parameter block of stan file
                  5    #  The dimension of vector z
                      )



# One more example: to extract the EAPs of the parameter dz,
# we need to specify its dimension of vector dz as follows.

          list.of.dz <-extract_EAP_CI(fit,"dz",4)

# One more example: to extract the EAPs of the parameter w,
# we need to specify its dimension of vector w as follows.

           list.w  <-extract_EAP_CI(fit,"w",1)


# Note that this function can extract only parameter of "vector" and not "array" !!
# To extract such an array, we provide the function "extract_estimates_MRMC()"
# which extract all parameters from a hierarchical Bayesian model
# estimated from user data. So, this function is no longer meaningless,
# and I will delete this.


# I forgot where I use this function
# 2019.05.21 Revised.
# 2020 Nov 17 Revised


#========================================================================================
#           the following gives convergence seed 2019 Oct 12
#========================================================================================
#'

f <- fit_Bayesian_FROC( ite  = 1111,  cha = 1, summary = TRUE, dataList = ddd ,see = 123456)
  z <- extract_EAP_CI(f,"z",f@dataList$C )$z.EAP
  #usethis::use_data(z)
  #usethis package cannot be to use since it is not declared in NAMESPACE.


  dz <- extract_EAP_CI(f,"dz",f@dataList$C-1 )$dz.EAP
  #usethis::use_data(dz)
  #usethis package cannot be to use since it is not declared in NAMESPACE.

## End(Not run)# dottest

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