A Shiny app for simple linear regression by hand and in R

[This article was first published on R on Stats and R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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:

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.

How to use this app?

Follow these steps:

  1. Open the app via this link
  2. 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
  3. If you do not want to display the confidence interval around the regression line, uncheck the checkbox under Plot
  4. 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.

I hope you will find this app useful to do simple linear regression by hand and in R. See all other articles related to Shiny here. As always, if you find a mistake/bug or if you have any questions do not hesitate to let me know in the comment section below, raise an issue on GitHub or contact me. Get updates every time a new article is published by subscribing to this blog.

To leave a comment for the author, please follow the link and comment on their blog: R on Stats and R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)