Skip to content
Extraits de code Groupes Projets
Valider f81403d8 rédigé par Eugen Pircalabelu's avatar Eugen Pircalabelu
Parcourir les fichiers

Add new file

parent
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #33 en échec
###########################################################################
## typeIvsII Shiny/R app ui.R ##
## ##
## Author Eugen Pircalabelu https://perso.uclouvain.be/eugen.pircalabelu ##
## For RShiny@UCLouvain http://sites.uclouvain.be/RShiny ##
## ##
## Licences : CC-BY for http://sites.uclouvain.be/RShiny ##
## GPL for source code on ##
## https://forge.uclouvain.be/rshiny_uclouvain/typeIvsII ##
###########################################################################
library(shiny)
library(shinyjs)
shinyUI(pageWithSidebar(
headerPanel("Erreurs de type I et II"),
sidebarPanel(
tags$head(
tags$style(type="text/css", "label { display: inline; }"),
tags$style(type="text/css", '.checkbox input[type="checkbox"],.radio input[type="radio"] { float: none; }')
),
HTML(" H<sub>1</sub> est vrai et H<sub>0</sub> est faux <br>"),
HTML(" &mu;<sub>0</sub> :moyenne sous H<sub>0</sub> <br>" ),#Label put outside of sliderInput because HTML is not rendered inside sliderInput label
sliderInput("mu0", " " , value=0, min = -2, max = 0,step=0.1),
HTML(" &mu;<sub>1</sub> : moyenne sous H<sub>1</sub> <br>"),
sliderInput("mu1", " " , min = 0.5,max = 2,value = 0.5, step=0.1,animate = TRUE),
HTML(" &sigma; : &eacute;cart-type de la population d'origine "),
sliderInput("sigma", " " , min = 1.5,max = 2.5,value = 1.5, step=0.1,animate = TRUE),
HTML(" n : nombre d'individus par échantillon "),
sliderInput("n"," ",min = 10,max = 100,value = 10, step=5,animate = TRUE),
HTML(" &alpha; : type I error "),
sliderInput("alpha","",min = 0.01,max = 0.1,value = 0.01, step=0.01,animate = TRUE),
p(HTML("<A HREF=\"javascript:history.go(0)\">Cliquez ici pour relancer l'expérience</A>")),
HTML('<hr style="border:1px solid #ccc;"/>'),
HTML('<a rel="license" href="http://creativecommons.org/licenses/by/2.0/be/"><img alt="Licence Creative Commons" style="border-width:0"
src="http://i.creativecommons.org/l/by/2.0/be/80x15.png" /></a> Ce(tte) oeuvre de <span xmlns:cc="http://creativecommons.org/ns#"
property="cc:attributionName"> <font face="Courier"> RShiny@UCLouvain </font> </span> est mise à disposition selon les termes de la <a rel="license"
href="http://creativecommons.org/licenses/by/2.0/be/">licence Creative Commons Attribution 2.0 Belgique</a>.'),
HTML('<p>Détails sur l\'utilisation de cette ressource sur <a href="http://sites.uclouvain.be/RShiny"
target="_blank"><font face="Courier"> RShiny@UCLouvain </font></a><br/>
Code source disponible sur <a href="https://forge.uclouvain.be/rshiny_uclouvain/typeIvsII " target="_blank">GitLab</a></p>')
),
mainPanel(
plotOutput("Plot")
)
))
# Define a server for the Shiny app
function(input, output) {
# Fill in the spot we created for a plot
output$Plot <- renderPlot({
# mu=seq(0,1,length=100)
# mypow1=ifelse(mu==input$mu0,input$myalpha1,
# 1-pnorm((sqrt(input$n)/input$sigma)*(input$mu0-mu)+qnorm(1-input$myalpha1)))
# plot(mu,mypow1,type="l",lwd=2,ylim=c(0,1),cex.lab=2.2,xlab=expression(mu-mu[0]),
# main="",ylab=expression(pi[n](mu)),cex=1.4, cex.axis=2,bty="n",
# xlim=c(0,1),col="black")
disable("mu")
myalpha1=0.01
mu0=1
sigma=input$sigma
n=input$n
mu=seq(0,2,length=100)
mypow1=ifelse(mu==mu0,myalpha1,1-pnorm((sqrt(n)/sigma)*(mu0-mu)+qnorm(1-myalpha1)))
par(mar=c(4,5.5, 0.5, 0.5))
plot(mu-mu0,mypow1,type="l",lwd=2,ylim=c(0,1),cex.lab=2.2,xlab=expression(mu*-~mu[0]),
main="",ylab=expression(pi[n](mu)),cex=1.4, cex.axis=2,bty="n",
xlim=c(-1,1),col="black",xaxt="n")
axis(1, c(-1,0,1),labels=c(-1,0,1),cex.axis=2, tck=-.02)
myalpha2=0.05
mypow2=ifelse(mu==mu0,myalpha2,1-pnorm((sqrt(n)/sigma)*(mu0-mu)+qnorm(1-myalpha2)))
lines(mu-mu0,mypow2,cex.lab=2.2,xlab="",ylab="",col=c("red"),cex=1.4,
yaxt="n", xaxt="n",bty="n",type="l",lty=2,lwd=2)
myalpha3=0.1
mypow3=ifelse(mu==mu0,myalpha3,1-pnorm((sqrt(n)/sigma)*(mu0-mu)+qnorm(1-myalpha3)))
lines(mu-mu0,mypow3,cex.lab=2.2,xlab="",ylab="",col=c("blue"),cex=1.4,
yaxt="n", xaxt="n",bty="n",type="l",lty=3,lwd=3)
legend("topleft",lty=c(NA,1,2,3),col=c("black","black","red","blue"),bty="n",
cex=2,lwd=3,legend=c(
as.expression(bquote(n*"="*.(n))),
as.expression(bquote(alpha*"="*.(format(myalpha1, digits = 2)))),
as.expression(bquote(alpha*"="*.(format(myalpha2, digits = 2)))),
as.expression(bquote(alpha*"="*.(format(myalpha3, digits = 2))))))
})
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter