# R/412.p-Confidence_p-Bias_ADJ_All_Graph.R In proportion: Inference on Single Binomial Proportion and Bayesian Computations

#### Documented in PlotpCOpBIAAllPlotpCOpBIAASPlotpCOpBIALRPlotpCOpBIALTPlotpCOpBIASCPlotpCOpBIATWPlotpCOpBIAWD

#########################################################################################
#' Plots  p-confidence and p-bias for a given n and alpha level for
#' 6 adjusted methods (Wald, Wald-T, Likelihood, Score, Logit-Wald, ArcSine)
#' @param n - Number of trials
#' @param alp - Alpha value (significance level required)
#' @param h - Adding factor
#' @details  Plots of p-confidence and p-bias for 6 adjusted methods
#' (Wald, Wald-T, Likelihood, Score, Logit-Wald, ArcSine)
#' @family p-confidence and p-bias of adjusted methods
#' @examples
#' \dontrun{
#' n=5; alp=0.05;h=2
#' PlotpCOpBIAAll(n,alp,h)
#' }
#' @export
####3.All methods plots of p-confidence and p-bias
PlotpCOpBIAAll<-function(n,alp,h)
{
if (missing(n)) stop("'n' is missing")
if (missing(alp)) stop("'alpha' is missing")
if (missing(h)) stop("'h' is missing")
if (alp>1 || alp<0 || length(alp)>1) stop("'alpha' has to be between 0 and 1")
if ((class(n) != "integer") & (class(n) != "numeric") || n<=0 ) stop("'n' has to be greater than 0")
if ((class(h) != "integer") & (class(h) != "numeric") || length(h) >1|| h<0  || !(h%%1 ==0)) stop("'h' has to be an integer greater than or equal to 0")

nAll = pCOpBIAAll(n,alp,h)
nndf=rbind(pc,pb)

ggplot2::ggplot(nndf, ggplot2::aes(x=x, y=val))+
ggplot2::labs(title = "p-Confidence & p-Bias - Adjusted methods") +
ggplot2::labs(y = "Confidence ") +
ggplot2::labs(x = "No of successes") +
values=c(

}

######################################################################
#' Plots  p-confidence and p-bias for adjusted Wald method
#' @param n - Number of trials
#' @param alp - Alpha value (significance level required)
#' @param h - Adding factor
#' @details  p-confidence and p-bias plots for adjusted Wald method
#' @family p-confidence and p-bias of adjusted methods
#' @examples
#' n=5; alp=0.05;h=2
#' PlotpCOpBIAWD(n,alp,h)
#' @export
PlotpCOpBIAWD<-function(n,alp,h)
{
if (missing(n)) stop("'n' is missing")
if (missing(alp)) stop("'alpha' is missing")
if (missing(h)) stop("'h' is missing")
if ((class(n) != "integer") & (class(n) != "numeric") || length(n)>1 || n<=0 ) stop("'n' has to be greater than 0")
if (alp>1 || alp<0 || length(alp)>1) stop("'alpha' has to be between 0 and 1")
if ((class(h) != "integer") & (class(h) != "numeric") || length(h)>1 || h<0  ) stop("'h' has to be greater than or equal to 0")

CBEX = pCOpBIAWD(n,alp,h)

gdf=rbind(W1,W2)

ggplot2::ggplot(gdf, ggplot2::aes(x=x, y=Value)) +
ggplot2::labs(title = "p-Confidence & p-Bias - Adjusted Wald method") +
ggplot2::labs(y = "Confidence ") +
ggplot2::labs(x = "No of successes") +
ggplot2::geom_line(data=gdf,ggplot2::aes(x=x, y=Value))

}

######################################################################
#' Plots  p-confidence and p-bias for adjusted Likelihood Ratio method
#' @param n - Number of trials
#' @param alp - Alpha value (significance level required)
#' @param h - Adding factor
#' @details  p-confidence and p-bias plots for adjusted Likelihood Ratio method
#' @family p-confidence and p-bias of adjusted methods
#' @examples
#' n=5; alp=0.05;h=2
#' PlotpCOpBIALR(n,alp,h)
#' @export
PlotpCOpBIALR<-function(n,alp,h)
{
if (missing(n)) stop("'n' is missing")
if (missing(alp)) stop("'alpha' is missing")
if (missing(h)) stop("'h' is missing")
if ((class(n) != "integer") & (class(n) != "numeric") || length(n)>1 || n<=0 ) stop("'n' has to be greater than 0")
if (alp>1 || alp<0 || length(alp)>1) stop("'alpha' has to be between 0 and 1")
if ((class(h) != "integer") & (class(h) != "numeric") || length(h) >1|| h<0  || !(h%%1 ==0)) stop("'h' has to be an integer greater than or equal to 0")

CBEX = pCOpBIALR(n,alp,h)

gdf=rbind(W1,W2)

ggplot2::ggplot(gdf, ggplot2::aes(x=x, y=Value)) +
ggplot2::labs(title = "p-Confidence & p-Bias - Adjusted Likelihood Ratio method") +
ggplot2::labs(y = "Confidence ") +
ggplot2::labs(x = "No of successes") +
ggplot2::geom_line(data=gdf,ggplot2::aes(x=x, y=Value))

}

######################################################################
#' Plots  p-confidence and p-bias for adjusted Wald-T method
#' @param n - Number of trials
#' @param alp - Alpha value (significance level required)
#' @param h - Adding factor
#' @details  p-confidence and p-bias plots for adjusted Wald-T method
#' @family p-confidence and p-bias of adjusted methods
#' @examples
#' n=5; alp=0.05;h=2
#' PlotpCOpBIATW(n,alp,h)
#' @export
PlotpCOpBIATW<-function(n,alp,h)
{
if (missing(n)) stop("'n' is missing")
if (missing(alp)) stop("'alpha' is missing")
if (missing(h)) stop("'h' is missing")
if ((class(n) != "integer") & (class(n) != "numeric") || length(n)>1 || n<=0 ) stop("'n' has to be greater than 0")
if (alp>1 || alp<0 || length(alp)>1) stop("'alpha' has to be between 0 and 1")
if ((class(h) != "integer") & (class(h) != "numeric") || length(h)>1 || h<0  ) stop("'h' has to be greater than or equal to 0")

CBEX = pCOpBIATW(n,alp,h)

gdf=rbind(W1,W2)

ggplot2::ggplot(gdf, ggplot2::aes(x=x, y=Value)) +
ggplot2::labs(title = "p-Confidence & p-Bias - Adjusted Wald-T method") +
ggplot2::labs(y = "Confidence ") +
ggplot2::labs(x = "No of successes") +
ggplot2::geom_line(data=gdf,ggplot2::aes(x=x, y=Value))

}

######################################################################
#' Plots  p-confidence and p-bias for adjusted Logit Wald method
#' @param n - Number of trials
#' @param alp - Alpha value (significance level required)
#' @param h - Adding factor
#' @details  p-confidence and p-bias plots for adjusted Logit Wald method
#' @family p-confidence and p-bias of adjusted methods
#' @examples
#' n=5; alp=0.05;h=2
#' PlotpCOpBIALT(n,alp,h)
#' @export
PlotpCOpBIALT<-function(n,alp,h)
{
if (missing(n)) stop("'n' is missing")
if (missing(alp)) stop("'alpha' is missing")
if (missing(h)) stop("'h' is missing")
if ((class(n) != "integer") & (class(n) != "numeric") || length(n)>1 || n<=0 ) stop("'n' has to be greater than 0")
if (alp>1 || alp<0 || length(alp)>1) stop("'alpha' has to be between 0 and 1")
if ((class(h) != "integer") & (class(h) != "numeric") || length(h)>1 || h<0  ) stop("'h' has to be greater than or equal to 0")

CBEX = pCOpBIALT(n,alp,h)

gdf=rbind(W1,W2)

ggplot2::ggplot(gdf, ggplot2::aes(x=x, y=Value)) +
ggplot2::labs(title = "p-Confidence & p-Bias - Adjusted Logit Wald method") +
ggplot2::labs(y = "Confidence ") +
ggplot2::labs(x = "No of successes") +
ggplot2::geom_line(data=gdf,ggplot2::aes(x=x, y=Value))

}

######################################################################
#' Plots  p-confidence and p-bias for adjusted Score method
#' @param n - Number of trials
#' @param alp - Alpha value (significance level required)
#' @param h - Adding factor
#' @details  p-confidence and p-bias plots for adjusted Score method
#' @family p-confidence and p-bias of adjusted methods
#' @examples
#' n=5; alp=0.05;h=2
#' PlotpCOpBIASC(n,alp,h)
#' @export
PlotpCOpBIASC<-function(n,alp,h)
{
if (missing(n)) stop("'n' is missing")
if (missing(alp)) stop("'alpha' is missing")
if (missing(h)) stop("'h' is missing")
if ((class(n) != "integer") & (class(n) != "numeric") || length(n)>1 || n<=0 ) stop("'n' has to be greater than 0")
if (alp>1 || alp<0 || length(alp)>1) stop("'alpha' has to be between 0 and 1")
if ((class(h) != "integer") & (class(h) != "numeric") || length(h)>1 || h<0  ) stop("'h' has to be greater than or equal to 0")

CBEX = pCOpBIASC(n,alp,h)

gdf=rbind(W1,W2)

ggplot2::ggplot(gdf, ggplot2::aes(x=x, y=Value)) +
ggplot2::labs(title = "p-Confidence & p-Bias - Adjusted Score method") +
ggplot2::labs(y = "Confidence ") +
ggplot2::labs(x = "No of successes") +
ggplot2::geom_line(data=gdf,ggplot2::aes(x=x, y=Value))

}

######################################################################
#' Plots  p-confidence and p-bias for adjusted ArcSine method
#' @param n - Number of trials
#' @param alp - Alpha value (significance level required)
#' @param h - Adding factor
#' @details  p-confidence and p-bias plots for adjusted ArcSine method
#' @family p-confidence and p-bias of adjusted methods
#' @examples
#' n=5; alp=0.05;h=2
#' PlotpCOpBIAAS(n,alp,h)
#' @export
PlotpCOpBIAAS<-function(n,alp,h)
{
if (missing(n)) stop("'n' is missing")
if (missing(alp)) stop("'alpha' is missing")
if (missing(h)) stop("'h' is missing")
if ((class(n) != "integer") & (class(n) != "numeric") || length(n)>1 || n<=0 ) stop("'n' has to be greater than 0")
if (alp>1 || alp<0 || length(alp)>1) stop("'alpha' has to be between 0 and 1")
if ((class(h) != "integer") & (class(h) != "numeric") || length(h)>1 || h<0  ) stop("'h' has to be greater than or equal to 0")

CBEX = pCOpBIAAS(n,alp,h)

gdf=rbind(W1,W2)

ggplot2::ggplot(gdf, ggplot2::aes(x=x, y=Value)) +