Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 2.21 KB

ShinyProject.md

File metadata and controls

75 lines (61 loc) · 2.21 KB
<style> .small-code pre code { font-size: 1em; } </style>

Adding Data to a Model: A Shiny App

author: Paul Clark date: 06-04-2017 autosize: true css: ie11fix.css

See app at https://clarpaul.shinyapps.io/add_point/

For all code, see repo https://github.com/clarpaul/DevDataProducts_Project/
App code in subfolder "Add_Point"

The app is to learn about linear regression

Primary Goals

  • Visualize regression statistics
    • Correlation coefficients
    • P-values
  • Understand how adding data affects p-values
  • See how differently positioned points impact the regression
    • Which points most affect the best-fit line
    • I.e., which points are high vs. low leverage/influence
  • Have fun!

Operation of the app

  1. The app displays a 2D scatterplot and regression line
  2. The user clicks plot locations to add observations in red
  3. With each added observation, the app updates and displays...
    • the observation's coordinates
    • the regression line for the scatterplot
    • the equation for the line
    • the correlation coef and p-value of the slope/regression
  4. Input widgets include...
    • check-box to show or hide the original trend line
    • button to clear added points and start over

View 1: Regression plot before adding data

class: small-code

plot(mtcars$mpg, mtcars$hp, 
   main = paste0("Horsepower",
     " vs. Miles-per-gallon"), 
   xlab = "MPG", ylab = "HP", 
   bty = "n", pch = 16,
   xlim = c(10, 35), 
   ylim = c(50, 350))
mtext("R `mtcars` dataset")
model1 <- lm(hp ~ mpg,
   data = mtcars)
abline(model1, col = "red",
   lwd = 2)

plot of chunk initialplot_revealed

View 2: Full application after adding data