# testplan output ----------
output$result_sample_size_attributiv <- renderUI({
# determine minimal sample-size
for (sample_size in 1:1000){
#browser()
if (input$test_power_attributiv/100 < pbinom(q = 0, size = sample_size, prob = (1 - input$p_min_attributiv/100), lower.tail = FALSE)){
minimal_sample_size <- sample_size
break;
}
minimal_sample_size <- ">1000"
}
tags$b("(n =", minimal_sample_size, ", c = 0)", style="align:center;")
})
# display oc-kurven --------------------
output$oc_kurven_attributiv <- renderPlot({
oc_data <-
expand.grid(
p = seq(0, 1, by = 0.005)*100,
sample_size = input$n
) %>%
mutate(
test_plan = paste("(", sample_size, ",",input$c,")", sep = ""),
p_reject = pbinom(q = input$c, size = sample_size, prob = (1-p/100), lower.tail = FALSE)*100
)
oc_data %>%
ggplot(aes(x = p, y = p_reject)) +
geom_line() +
scale_x_continuous("p [%] ('wahre' i.o.-rate des Produktionsprozesses)", breaks = seq(0, 100, by = 5)) +
scale_y_continuous("Wahrscheinlichkeit für Testergebnis: Design ist n.i.o.", breaks = seq(0, 100, by = 5)) +
geom_hline(yintercept = input$test_power_attributiv, alpha = 0.5, linetype = "dashed") +
geom_vline(xintercept = input$p_min_attributiv, alpha = 0.5, linetype = "dashed") +
geom_text(x = 10, y = input$test_power_attributiv, label = "geforderte Power des Tests", hjust = 0, vjust = 0) +
geom_text(x = input$p_min_attributiv, y = 95, label = "geforderte minimale i.o.-Rate", hjust = 0, vjust = 0, angle = -90)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.