May 28, 2017

Overview

This app allows you to display diferents types of regression models using the variables Weight Motor and Miles per Galon from the mtcars data set. You can choose the following models from the Main Panel to display:

  • Fitting Linear Model (lm)
  • Fitting Generalized Linear Model (glm)
  • Generalized additive models with integrated smoothness estimation (gam)
  • Local Polynomial Regression Fitting (loess)
  • Robust Fitting of Linear Models (rlm)

Similarly, you can view the model details like: formula, parameters, errors, etc. You can also explore interactively the data used to built the model and plot.

The app is hosted in the shinyapps server, you can access from here: https://lsantonio.shinyapps.io/regression_models_display_and_calculation/

The source code of the project can be found here: https://github.com/LsAntonio/shinyApp

App Functionality

Select the type of regression model that you would like to view from the Main Panel, once you selected one a plot will be displayed in the Display Area, the model details are generated into the Model Tab, each time you select a different model the Plot Tab and Model Tab will be updated according with the model type that you selected.

Code

Here we show the code for the linear model option (selected from the Main panel), the results of this computation are displayed in the Model tab and the model plot are generated in the Plot tab

data("mtcars")
model <- lm(mpg ~ wt, data = mtcars)
summary(model)
Call:
lm(formula = mpg ~ wt, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-4.5432 -2.3647 -0.1252  1.4096  6.8727 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  37.2851     1.8776  19.858  < 2e-16 ***
wt           -5.3445     0.5591  -9.559 1.29e-10 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.046 on 30 degrees of freedom
Multiple R-squared:  0.7528,    Adjusted R-squared:  0.7446 
F-statistic: 91.38 on 1 and 30 DF,  p-value: 1.294e-10
# https://www.uvm.edu/rsenr/vtcfwru/R/fledglings/14_Slideshows.html

Plot

Here is the plot produced by the choice of a linear model from the Main Panel