ConfirmConvergence: Check R hat criterion

Description Usage Arguments Details Value References See Also Examples

View source: R/ConfirmConvergence.R

Description

Calculates the maximum and the minimal values of R hat over all parameters. In addition, it returns a loginal R object whether R hat is good (TRUE) or bad (FALSE).

Usage

1
ConfirmConvergence(StanS4class, summary = TRUE, digits = 2)

Arguments

StanS4class

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

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.

digits

A positive integer, indicating digits for R hat statistics.

Details

Evaluates convergence criterion based on only the R hat statistics for a fitted model object. Revised Nov 23.

Value

Logical: TRUE of FALSE. If model converges ( all R hat are closed to 1) then it is TRUE, and if not( some R hat is far from 1), then FALSE.

References

Gelman A. & Rubin, D.B. (1992). Inference from Iterative Simulation Using Multiple Sequences, Statistical Science, Volume 7, Number 4, 457-472.

See Also

check_rhat(), which is made by Betanalpha.

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
## Not run: 
#================The first example======================================

            #((Primitive way)).
#1) Build the data for a singler reader and a single modality  case.

dat <- list(c=c(3,2,1),    #Confidence level
            h=c(97,32,31), #Number of hits for each confidence level
            f=c(1,14,74),  #Number of false alarms for each confidence level

            NL=259,       #Number of lesions
            NI=57,        #Number of images
            C=3)          #Number of confidence level

# where, c denotes Confidence level,
#        h denotes number of Hits for each confidence level,
#        f denotes number of False alarms for each confidence level,
#        NL denotes Number of Lesions,
#        NI denotes Number of Images,









#2) Fit the FROC model.
  #Since the above dataset  "dat" are single reader and single modality,
  #the following function fit the non hierarchical model.

          fit <-   BayesianFROC::fit_Bayesian_FROC(dat,ite=1111)



#  Where, the variable "ite" specifies the iteration of MCMC samplings.
#  Larger iteration is better.



#3.1) Confirm whether our estimates converge.




          ConfirmConvergence(fit)



# By the above R script,
# the diagnosis of convergence will be printed in the R (R-studio) console.
# The diagnosis is based on only the R hat statistic.
# It also return the logical vector indicating whether or not the MCMC converge,
# if MCMC converges, then the return value is TRUE and if not, then FALSE.

# This logical return value is used in this package development
# and the user should not be interested.

# The following was useful for programming.
#3.2) The return value is TRUE or FALSE.

     x <- ConfirmConvergence(fit)

#3.3) If you do not want to print the results in the R (Studio) console, then

      x <- ConfirmConvergence(fit,summary=FALSE)



# 2019.05.21 Revised.
# 2019.12.02 Revised.



## End(Not run)# dontrun

BayesianFROC documentation built on Jan. 13, 2021, 5:22 a.m.