# NOT RUN {
#========================================================================================
# 0) 0-th example
#========================================================================================
datasets <-error_srsc(
NLvector = c(100,10000,1000000),
ite = 2222
)
# By the following, we can extract only datasets whose
# model has converged.
datasets$convergent.dataList.as.dataframe
#========================================================================================
# 1) 1-st example
#========================================================================================
# Long width is required in R console.
datasets <-error_srsc(NLvector = c(
50L,
111L,
11111L
),
# NIvector,
ratio=2,
replicate.datset =3,
ModifiedPoisson = FALSE,
mean.truth=0.6,
sd.truth=5.3,
z.truth =c(-0.8,0.7,2.38),
ite =2222
)
#========================================================================================
# 2) Plot the error of AUC with respect to NI
#========================================================================================
a <-error_srsc(NLvector = c(
33L,
50L,
111L,
11111L
),
# NIvector,
ratio=2,
replicate.datset =3,
ModifiedPoisson = FALSE,
mean.truth=0.6,
sd.truth=5.3,
z.truth =c(-0.8,0.7,2.38),
ite =2222
)
aa <- a$Bias.for.various.NL
error.of.AUC <- aa[8,]
y <- subset(aa[8,], select = 2:length(aa[8,]))
y <- as.numeric(y)
y <- abs(y)
upper_y <- max(y)
lower_y <- min(y)
x <- 1:length(y)
plot(x,y, ylim=c(lower_y, upper_y))
# From this plot, we cannot see whether the error has decreased or not.
# Thus, we replot with the log y-axis, the we will see that the error
# has decreased with respect to number of images and lesions.
ggplot(data.frame(x=x,y=y), aes(x = x, y = y)) +
geom_line() +
geom_point() +
scale_y_log10()
# Revised 2019 Sept 25
# General print of log scale
df<-data.frame(x=c(10,100,1000,10,100,1000),
y=c(1100,220000,33000000,1300,240000,36000000),
group=c("1","1","1","2","2","2")
)
ggplot2::ggplot(df, aes(x = x, y = y, shape = group)) +
ggplot2::geom_line(position = position_dodge(0.2)) + # Dodge lines by 0.2
ggplot2::geom_point(position = position_dodge(0.2), size = 4)+ # Dodge points by 0.2
ggplot2::scale_y_log10()+
ggplot2::scale_x_log10()
#========================================================================================
# 2) Add other param into plot plain of the error of AUC with respect to NI
#========================================================================================
a <-error_srsc(NLvector = c(
111L,
11111L
),
# NIvector,
ratio=2,
replicate.datset =3,
ModifiedPoisson = FALSE,
mean.truth=0.6,
sd.truth=5.3,
z.truth =c(-0.8,0.7,2.38),
ite =2222
)
aa <- a$Bias.for.various.NL
error.of.AUC <- aa[8,]
y1 <- subset(aa[8,], select = 2:length(aa[8,]))
y1 <- as.numeric(y1)
y1 <- abs(y1)
LLL <-length(y1)
y2 <- subset(aa[7,], select = 2:length(aa[7,]))
y2 <- as.numeric(y2)
y2 <- abs(y2)
y <- c(y1,y2)
upper_y <- max(y)
lower_y <- min(y)
group <- rep(seq(1,2,1),1 , each=LLL)
x <- rep(seq(1,LLL,1),2 , each=1)
group <- as.character(group)
df <- data.frame(x=x,y=y,group=group)
ggplot2::ggplot(df, aes(x = x, y = y, shape = group)) +
ggplot2::geom_line(position = position_dodge(0.2)) + # Dodge lines by 0.2
ggplot2::geom_point(position = position_dodge(0.2), size = 4)+ # Dodge points by 0.2
ggplot2::scale_y_log10()
# ggplot2::scale_x_log10()
#========================================================================================
# Confidence level = 4
#========================================================================================
datasets <-error_srsc(NLvector = c(
111L,
11111L
),
# NIvector,
ratio=2,
replicate.datset =3,
ModifiedPoisson = FALSE,
mean.truth=-0.22,
sd.truth=5.72,
z.truth =c(-0.46,-0.20,0.30,1.16),
ite =2222
)
error_srsc_variance_visualization(datasets)
# The parameter of model is 7 in which the ggplot2 fails with the following warning:
# The shape palette can deal with a maximum of 6 discrete values because more than 6
# becomes difficult to
# discriminate; you have 7. Consider specifying shapes manually if you must have them.
#========================================================================================
# NaN ... why? 2021 Dec
#========================================================================================
fits <- validation.dataset_srsc()
f <-fits$fit[[2]]
rstan::extract(f)$dl
sum(rstan::extract(f)$dl)
Is.nan.in.MCMCsamples <- as.logical(!prod(!is.nan(rstan::extract(f)$dl)))
rstan::extract(f)$A[525]
a<-rstan::extract(f)$a
b<-rstan::extract(f)$b
Phi( a[525]/sqrt(b[525]^2+1) )
a[525]/sqrt(b[525]^2+1)
Phi( a/sqrt(b^2+1) )
x<-rstan::extract(f)$dl[2]
a<-rstan::extract(f)$a
b<-rstan::extract(f)$b
a/(b^2+1)
Phi(a/(b^2+1))
mean( Phi(a/(b^2+1)) )
#'
# }
# NOT RUN {
# dontrun
# }
Run the code above in your browser using DataLab