@@ -100,7 +100,7 @@ auditBayesianEstimation <- function(jaspResults, dataset, options, ...) {
100
100
101
101
tb <- createJaspTable(title )
102
102
tb $ position <- position
103
- tb $ addColumnInfo(name = " estimate" , title = gettext(" Point estimate " ), type = " number" , format = " monetary" )
103
+ tb $ addColumnInfo(name = " estimate" , title = gettext(" Posterior mode " ), type = " number" , format = " monetary" )
104
104
tb $ addColumnInfo(name = " uncertainty" , title = gettext(" Precision" ), type = " number" , format = " monetary" )
105
105
tb $ addColumnInfo(name = " lower" , title = gettext(" Lower" ), type = " number" , format = " monetary" , overtitle = overTitle )
106
106
tb $ addColumnInfo(name = " upper" , title = gettext(" Upper" ), type = " number" , format = " monetary" , overtitle = overTitle )
@@ -147,54 +147,62 @@ auditBayesianEstimation <- function(jaspResults, dataset, options, ...) {
147
147
148
148
result <- jaspResults [[" state" ]]$ object
149
149
150
- if (options [[" priorKappa" ]] == 0 || options [[" priorNu" ]] == 0 ) {
151
- xseq <- seq(extraDistr :: qlst(0.0001 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ),
152
- extraDistr :: qlst(0.9999 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ),
153
- length.out = 1000
154
- )
155
- plotdata <- data.frame (x = xseq , y = extraDistr :: dlst(xseq , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ), type = rep(" Posterior" , length(xseq )))
156
- xBreaks <- pretty(plotdata $ x , min.n = 4 )
157
- yBreaks <- pretty(c(0 , plotdata $ y ), min.n = 4 )
158
- p <- ggplot2 :: ggplot(data = plotdata , mapping = ggplot2 :: aes(x = x , y = y , linetype = factor (type ))) +
159
- ggplot2 :: geom_line() +
160
- ggplot2 :: scale_x_continuous(name = gettext(" True population value" ), limits = range(xBreaks ), breaks = xBreaks ) +
161
- ggplot2 :: scale_y_continuous(name = gettext(" Density" ), limits = range(yBreaks ), breaks = yBreaks ) +
162
- ggplot2 :: scale_linetype_manual(name = NULL , values = 1 ) +
163
- jaspGraphs :: geom_rangeframe() +
164
- jaspGraphs :: themeJaspRaw(legend.position = c(0.8 , 0.9 )) +
165
- ggplot2 :: theme(
166
- axis.ticks.y = ggplot2 :: element_blank(),
167
- axis.text.y = ggplot2 :: element_blank()
150
+ pTry <- try({
151
+ if (options [[" priorKappa" ]] == 0 || options [[" priorNu" ]] == 0 || options [[" priorSigma2" ]] == 0 ) {
152
+ xseq <- seq(extraDistr :: qlst(0.0001 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ),
153
+ extraDistr :: qlst(0.9999 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ),
154
+ length.out = 1000
168
155
)
169
- } else {
170
- xseq <- seq(
171
- min (c(extraDistr :: qlst( 0.0001 , df = result $ prior $ nu , mu = result $ prior $ mu , sigma = result $ prior $ sigma ), extraDistr :: qlst( 0.0001 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ))),
172
- max(c( extraDistr :: qlst( 0.9999 , df = result $ prior $ nu , mu = result $ prior $ mu , sigma = result $ prior $ sigma ), extraDistr :: qlst( 0.9999 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ))),
173
- length.out = 1000
174
- )
175
- plotdata <- data.frame (
176
- x = c(rep( xseq , 2 )),
177
- y = c(
178
- extraDistr :: dlst( xseq , df = result $ prior $ nu , mu = result $ prior $ mu , sigma = result $ prior $ sigma ),
179
- extraDistr :: dlst( xseq , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma )
180
- ),
181
- type = c(rep(c( " Prior " , " Posterior " ), each = length( xseq )) )
182
- )
183
- plotdata $ type <- factor ( plotdata $ type , levels = c( " Posterior " , " Prior " ))
184
- xBreaks <- pretty( plotdata $ x , min.n = 4 )
185
- yBreaks <- pretty (c(0 , plotdata $ y ), min.n = 4 )
186
- p <- ggplot2 :: ggplot( data = plotdata , mapping = ggplot2 :: aes( x = x , y = y , linetype = type )) +
187
- ggplot2 :: geom_line() +
188
- ggplot2 :: scale_x_continuous( name = gettext( " True population value " ), limits = range( xBreaks ), breaks = xBreaks ) +
189
- ggplot2 :: scale_y_continuous( name = gettext( " Density " ), limits = range( yBreaks ), breaks = yBreaks ) +
190
- ggplot2 :: scale_linetype_manual( name = NULL , values = c(1 , 2 )) +
191
- jaspGraphs :: geom_rangeframe() +
192
- jaspGraphs :: themeJaspRaw( legend.position = c( 0.8 , 0.9 )) +
193
- ggplot2 :: theme(
194
- axis.ticks.y = ggplot2 :: element_blank( ),
195
- axis.text.y = ggplot2 :: element_blank( )
156
+ plotdata <- data.frame ( x = xseq , y = extraDistr :: dlst( xseq , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ), type = rep( " Posterior " , length( xseq )))
157
+ xBreaks <- pretty( plotdata $ x , min.n = 4 )
158
+ yBreaks <- pretty (c(0 , plotdata $ y ), min.n = 4 )
159
+ p <- ggplot2 :: ggplot( data = plotdata , mapping = ggplot2 :: aes( x = x , y = y , linetype = factor ( type ))) +
160
+ ggplot2 :: geom_line() +
161
+ ggplot2 :: scale_x_continuous( name = gettext( " True population value " ), limits = range( xBreaks ), breaks = xBreaks ) +
162
+ ggplot2 :: scale_y_continuous( name = gettext( " Density " ), limits = range( yBreaks ), breaks = yBreaks ) +
163
+ ggplot2 :: scale_linetype_manual( name = NULL , values = 1 ) +
164
+ jaspGraphs :: geom_rangeframe() +
165
+ jaspGraphs :: themeJaspRaw( legend.position = c( 0.8 , 0.9 )) +
166
+ ggplot2 :: theme(
167
+ axis.ticks.y = ggplot2 :: element_blank( ),
168
+ axis.text.y = ggplot2 :: element_blank( )
169
+ )
170
+ } else {
171
+ xseq <- seq(
172
+ min (c(extraDistr :: qlst( 0.0001 , df = result $ prior $ nu , mu = result $ prior $ mu , sigma = result $ prior $ sigma ), extraDistr :: qlst( 0.0001 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ))),
173
+ max(c( extraDistr :: qlst( 0.9999 , df = result $ prior $ nu , mu = result $ prior $ mu , sigma = result $ prior $ sigma ), extraDistr :: qlst( 0.9999 , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma ))),
174
+ length.out = 1000
175
+ )
176
+ plotdata <- data.frame (
177
+ x = c(rep( xseq , 2 )),
178
+ y = c(
179
+ extraDistr :: dlst( xseq , df = result $ prior $ nu , mu = result $ prior $ mu , sigma = result $ prior $ sigma ),
180
+ extraDistr :: dlst( xseq , df = result $ posterior $ nu , mu = result $ posterior $ mu , sigma = result $ posterior $ sigma )
181
+ ),
182
+ type = c(rep(c( " Prior " , " Posterior " ), each = length( xseq )) )
196
183
)
184
+ plotdata $ type <- factor (plotdata $ type , levels = c(" Posterior" , " Prior" ))
185
+ xBreaks <- pretty(plotdata $ x , min.n = 4 )
186
+ yBreaks <- pretty(c(0 , plotdata $ y ), min.n = 4 )
187
+ p <- ggplot2 :: ggplot(data = plotdata , mapping = ggplot2 :: aes(x = x , y = y , linetype = type )) +
188
+ ggplot2 :: geom_line() +
189
+ ggplot2 :: scale_x_continuous(name = gettext(" True population value" ), limits = range(xBreaks ), breaks = xBreaks ) +
190
+ ggplot2 :: scale_y_continuous(name = gettext(" Density" ), limits = range(yBreaks ), breaks = yBreaks ) +
191
+ ggplot2 :: scale_linetype_manual(name = NULL , values = c(1 , 2 )) +
192
+ jaspGraphs :: geom_rangeframe() +
193
+ jaspGraphs :: themeJaspRaw(legend.position = c(0.8 , 0.9 )) +
194
+ ggplot2 :: theme(
195
+ axis.ticks.y = ggplot2 :: element_blank(),
196
+ axis.text.y = ggplot2 :: element_blank()
197
+ )
198
+ }
199
+ })
200
+
201
+ if (jaspBase ::: isTryError(pTry )) {
202
+ jf $ setError(gettext(" Plotting not possible: %1$s" , jaspBase ::: .extractErrorMessage(pTry )))
203
+ return ()
197
204
}
205
+
198
206
fg $ plotObject <- p
199
207
}
200
208
0 commit comments