-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T distribution #1
base: main
Are you sure you want to change the base?
Conversation
app t-dist, replicate from z_dist
# min = 1, max = 200, value = 1, step = 1 | ||
# ) | ||
), | ||
div(# critical values readout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added critical values readout back in - how this should look/feel/act is still up for debate
output$critical_values <- renderPrint({ | ||
tagList( | ||
tags$label("Critical values"), | ||
withMathJax(), | ||
labels() %>% pull(t, df) %>% label_p_value_html() %>% map(p) | ||
labels() %>% select(t, df) %>% purrr::pmap(label_p_value_html) %>% map(p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pt takes two inputs, need a different approach (purrr:pmap
maps over df rows)
outputOptions(output, "mode", suspendWhenHidden = FALSE) | ||
outputOptions(output, "help", suspendWhenHidden = FALSE) | ||
} | ||
|
||
shiny::shinyApp(ui, server) | ||
shiny::shinyApp(ui, server) %>% shiny::runApp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added for non-interactive use (as the file name is non-standard, and doesn't trigger Rstudio black magic integrations
@@ -0,0 +1,163 @@ | |||
library(shiny) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I actually forgot to push the progress I already made on the t-distribution app. Sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall!
I left some minor comments.
Suggested changes/improvements;
- dynamically extend plot range for low df
- fix y axis to show changes across df
- add toggleable normal distribution overlay
R/t-distribution
Outdated
@@ -0,0 +1,270 @@ | |||
# App: t_distribution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename should be app.R
for shiny and Rstudio integrations to work. .R
extension is also nice...
R/t-distribution
Outdated
STARTING_DF <- 2 | ||
STARTING_P_VALUE <- | ||
pt(STARTING_T_VALUE / 2, STARTING_DF, lower.tail = STARTING_T_VALUE <= 0) %>% round(3) | ||
RANGE <- c(-4, 4) # range for T value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to add dynamic range, as with low df the critical values fall outside of the -4, 4 range.
min/max(range, actual)
in the render should do the trick
R/t-distribution
Outdated
class = "d-flex", | ||
sliderInput("alpha", "Type I error, \\(\\alpha\\)", 0.01, 0.2, 0.05, 0.01) | ||
), | ||
div(# degree of freedom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
df is required in all modes, it also affects p-values, move outside of conditional panel
R/t-distribution
Outdated
crit_lower <- reactive(qt(input$alpha / 2, input$df)) # find lower critical value | ||
crit_upper <- reactive(qt(1 - input$alpha / 2, input$df)) # find upper critical value | ||
data <- reactive(tibble( | ||
t = c( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re; adaptive range, check if critical t falues fall outside of range, and if necessary, extend the range
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll need to see if that has implications for the precision, as for df=1 the range is ~-25,25 or so
R/t-distribution
Outdated
updateNumericInput(session, "t_value", value = tValue()) | ||
}) %>% bindEvent(input$p_to_t) | ||
|
||
output$critical_values <- renderPrint({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that this was unused, but also defective (can't pull 2 variables into a function like that, the function sees it as one variable.)
See update in my patch, and purrr:pmap
R/t-distribution
Outdated
|
||
## PLOT --------------------------------------------------------- | ||
output$distribution <- renderPlot({ | ||
plot <- data() %>% ggplot(aes(t, d)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that the y
scale depends on the degrees of freedom. We may want to fix the scale to 0,0.4 (ish, whatever is reasonable for df=\Inf
), so that changes in y scale are more obvious to see.
- Fixed y-axis to show changes across df - Modified dynamically extend plot range for low df - Add check box to show normal distribution - Fixed error not showing df in p_values mode - Fixed typo error: label_t_value => label_p_value
- Modified dynamically extend plot range for low df - Add check box to show normal distribution - Fixed error not showing df in p_values mode - Fixed typo error: label_t_value => label_p_value
Update display mode
…in previous versions, display breaks for t-values
…version, display breaks for z-values.
No description provided.