Simple linear regression is a statistical method to summarize and study relationships between two variables. When more than two variables are of interest, it is referred as multiple linear regression.
In this article, we focus only on a Shiny app which allows to perform simple linear regression by hand and in R:
Here is the entire code in case you would like to enhance it (see how to use this app after the embedded code):
For further details about what is linear regression and when it is used, please see the numerous resources on the topic available in textbooks and online.
Note that the link may not work if the app has hit the monthly usage limit. Try again later if that is the case.
How to use this app?
Follow these steps:
- Open the app via this link
- Enter your data in the x and y fields. The x field corresponds to the independent variable, while the y field corresponds to the dependent variable
- If you do not want to display the confidence interval around the regression line, uncheck the checkbox under Plot
- Change the x and y-axis labels for the regression plot if needed
In the results panel (on the right side or below depending on the size of your screen), you will see:
- a recap of your dataset together with some appropriate descriptive statistics
- the estimates \(\beta_0\), \(\beta_1\) and the regression model computed by hand
- the results of the model computed in R
- the regression plot with some key measures
- and the interpretations
All formulas, steps and computations to arrive at the final results are also provided. Note that it is your responsibility to check the validity of your linear model. This app only serves you to compute the results of the linear model given the data but it does not check whether the assumptions are met. Last but not least, you can download a report of the results by clicking on the Download button. You can choose the format of the report (i.e., HTML, PDF or Word) and whether you want to include the R code or not.
Thanks for reading. I hope you will find this app useful to do simple linear regression by hand and in R.
As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.