Created
January 5, 2014 22:34
-
-
Save bayesball/8274967 to your computer and use it in GitHub Desktop.
Shiny application to fit a beta curve given the median and 90th percentile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer(function(input, output) { | |
output$distPlot <- renderPlot({ | |
library(LearnBayes) | |
quantile1 = list(p=.5, x=input$p50) | |
quantile2 = list(p=.9, x=input$p90) | |
ab = beta.select(quantile1, quantile2) | |
curve(dbeta(x, ab[1], ab[2]), 0, 1, ylab="Density", | |
main=paste("a = ",ab[1]," b = ", ab[2])) | |
}) | |
output$summary <- renderPrint( { | |
library(LearnBayes) | |
quantile1 = list(p=.5, x=input$p50) | |
quantile2 = list(p=.9, x=input$p90) | |
ab = beta.select(quantile1, quantile2) | |
q = qbeta(c(0.05, 0.25, 0.50, 0.75, 0.95), | |
ab[1], ab[2]) | |
names(q) = c("5th Percentile", "Lower Quartile", | |
"Median", "Upper Quartile", "95th Percentile") | |
q | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
# Define UI for application that plots random distributions | |
shinyUI(pageWithSidebar( | |
# Application title | |
headerPanel("Beta Curve"), | |
# Sidebar with a slider input for number of observations | |
sidebarPanel( | |
sliderInput("p50", | |
"Median of beta curve:", | |
min = 0, | |
max = 1, | |
value = 0.5), | |
sliderInput("p90", | |
"90th Percentile:", | |
min = 0, | |
max = 1, | |
value = 0.8) | |
), | |
# Show a plot of the generated distribution | |
mainPanel( | |
plotOutput("distPlot") , | |
verbatimTextOutput("summary") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment