Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Binomial Proportion Post Gists 2
### Function: Likelihood Plot Values
likelihood <- function(N,Y){
a <- Y + 1
b <- N - Y + 1
dom <- seq(0,1,0.005)
val <- dbeta(dom,a,b)
return(data.frame('x'=dom, 'y'=val))
}
### Function: Mean of Posterior Beta
mean_of_posterior <- function(m,n,N,Y){
a <- Y + (n*m) -1
b <- N - Y + (n*(1-m)) - 1
E_posterior <- a / (a + b)
return(E_posterior)
}
### Function: Mode of Posterior Beta
mode_of_posterior <- function(m,n,N,Y){
a <- Y + (n*m) -1
b <- N - Y + (n*(1-m)) - 1
mode_posterior <- (a-1)/(a+b-2)
return(mode_posterior)
}
### Function: Posterior Plot Values
posterior <- function(m,n,N,Y){
a <- Y + (n*m) -1
b <- N - Y + (n*(1-m)) - 1
dom <- seq(0,1,0.005)
val <- dbeta(dom,a,b)
return(data.frame('x'=dom, 'y'=val))
}
### Function: Prior Plot Values
prior <- function(m,n){
a = n * m
b = n * (1 - m)
dom <- seq(0,1,0.005)
val <- dbeta(dom,a,b)
return(data.frame('x'=dom, 'y'=val))
}
### Function: Std Dev of Posterior Beta
sd_of_posterior <- function(m,n,N,Y){
a <- Y + (n*m) -1
b <- N - Y + (n*(1-m)) - 1
sigma_posterior <- sqrt((a*b)/(((a+b)^2)*(a+b+1)))
return(sigma_posterior)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.