Last active
December 28, 2015 12:09
-
-
Save martin-smira/7498985 to your computer and use it in GitHub Desktop.
Verze pro 2 testy
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) { | |
# Potrebne vypocty | |
posteriorMean <- reactive({ | |
SEM1 <- 15 * sqrt(1 - as.numeric(input$reliability1)) | |
SEM2 <- 15 * sqrt(1 - as.numeric(input$reliability2)) | |
precSD <- 1 / 15^2 | |
precSEM1 <- 1 / SEM1^2 | |
precSEM2 <- 1 / SEM2^2 | |
precSD / (precSD + precSEM1 + precSEM2) * 100 + | |
sum(precSEM1 / (precSD + precSEM1 + precSEM2) * input$score1) + | |
sum(precSEM2 / (precSD + precSEM1 + precSEM2) * input$score2) | |
}) | |
posteriorScale <- reactive({ | |
SEM1 <- 15 * sqrt(1 - as.numeric(input$reliability1)) | |
SEM2 <- 15 * sqrt(1 - as.numeric(input$reliability2)) | |
precSD <- 1 / 15^2 | |
precSEM1 <- 1 / SEM1^2 | |
precSEM2 <- 1 / SEM2^2 | |
1 / sqrt(precSD + precSEM1 + precSEM2) | |
}) | |
probability <- reactive({ | |
round(pnorm(posteriorMean(), input$hranice, posteriorScale()) * 100, 2) | |
}) | |
##################### EXPERIMENTAL field ########################### | |
################################# ################################# | |
output$probability <- renderText({ | |
paste("Pravdepodobnost, ze ma mereny jedinec skutecne IQ rovno", | |
input$hranice, "a nebo vyssi, je rovna:", probability(), "%") | |
}) | |
output$descriptive <- renderText({ | |
paste("Prumerne hodnota IQ =", round(posteriorMean(), 2), | |
"(smerodnatna odchylka =", round(posteriorScale(), 2), ")") | |
}) | |
output$distPlot <- renderPlot({ | |
dist <- rnorm(100000, posteriorMean(), posteriorScale()) | |
plot(density(dist), xlim=c(55, 145), | |
main="Pravdepodobnostni rozlozeni skutecneho IQ skoru") | |
abline(v=input$hranice, lwd=2, lty=4, col="red") | |
}) | |
}) |
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
# Co dodat - manualni nastaveni reliabiliti nebo SEM | |
# napsat prumer a odchylku | |
library(shiny) | |
# Define UI for miles per gallon application | |
shinyUI(pageWithSidebar( | |
# Application title | |
headerPanel("true IQ skor"), | |
sidebarPanel( | |
# | |
numericInput("hranice", "Zadejte hodnotu, proti které chcete testovat:", 130), | |
numericInput("score1", "1. Naměřené IQ", 100), | |
selectInput("reliability1", "testem:", | |
list("Raven (0,88)" = 0.88, | |
"Nějakou sračkou (0,5)" = 0.5, | |
"Nějakou bombou (0,98)" = 0.98)), | |
numericInput("score2", "2. Naměřené IQ", 100), | |
selectInput("reliability2", "testem:", | |
list("Raven (0,88)" = 0.88, | |
"Nějakou sračkou (0,5)" = 0.5, | |
"Nějakou bombou (0,98)" = 0.98)) | |
################################################################# | |
# , | |
# numericInput("lat", "Latitude"), | |
# numericInput("long", "Longitude"), | |
# uiOutput("cityControls") | |
################################################################## | |
), | |
mainPanel( | |
h5(textOutput("probability")), | |
# h3("pokud je zobrazena hodnota '0', pak je pravděpodobnost nižší než 0,005") | |
h5(textOutput("descriptive")), | |
plotOutput("distPlot") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment