R Tutorial #10 – Linear Regression

Part 10 of my series about the statistical programming language R! In this video I show how a linear regression line can be added to your data-plot. Also I show how you can add lines to your plot manually. Finally you will learn how to generate normal-distributed random values and a line will be generated that fits those random numbers best.


Chris Terrell says:

Nice… file.choose() really cool

Feeluck says:

please do a tutorial for non-linear regression 🙂

Jing Wang says:

Thank you very much. I learn all your 10 videos.

Dani G says:

Thank you for this video. Do you know if there are any resources for multivariate multiple regression in r?

Krzysztof S says:

Very good video. Thank you for educating community. Best regards from Poland!

aniththa inthirarajah says:

I have GCSE results want to do linear regression, first I want to analysis the data, then I want to predicate results for summer. how do I do it?

BTinHD says:

I have put names on my x-axis and they are too big to be all displayed. Adjusting the size of the font does not help. Can you rotate the names 90 degrees?

davilla721 says:

abline(lm(y~x)) draws the line on the graph as you already know.

To get the value of the slope, all you have to is write the same thing without the abline. So:
lm(y~x). This will spit out the coefficient and the slope.

Long Zhao says:

very good, thank you

David Buchatz says:

hey, do you know how it is possible to do a multivariate regression/fitting with legendre polynomials (or other orthogonal polynomials) ?

Huang Huan says:

very example oriented, useful!

User1dentification says:

*th* … german sickness 😀

monika sharma says:

anbline is showing error , how to solve that?

Abdirahman Ahmed says:

thanks it was useful

AAmadeusz says:

thank you, you helped me a lot!

Joseph Robertson says:

Excellent collection. Thanks for taking time. Your method is really captivating. I am not sure if you are intentionally making the typos, but those makes me think about what is wrong and makes my learning more effective!!!

Also, the timing is just right to learn a concept without overdose!

Thanks for taking time to do this.

Ulf Leisner says:

Hi, how can I get a putout about the slope, once i have created abline? I need the value..

Archana Ahuja says:

Thankyou sooooooooo much for putting all this together… 🙂

Gyve P. says:

ah good catch! Today. its 102 and problem solved x = 1:102

Ted says:

Thanks a lot dear,,, please keep going; more Plot pleaseeeeeeeeeeee

dfsfklsj says:

It’s line of best fit

Clyde Lee says:

Thank you for sharing this video clip 🙂

Ricardo Junior says:

Do you have a tutorial for quantile regression and nonparametric quantile regression? If not, can you make plis?

neem33 says:

Thank you very much, nice intro and good example

Graham Rimmington says:

awesome job…………. thanks for your efforts, teaching this monkey R 🙂

Murphy Pascual says:

Thank you very much. It’s very helpful

jd baba says:

Awesome tutorial. Thank you so much for sharing.

Anna says:

When I write > abline(lm(y~x))
I receive
Error in model.frame.default(formula = y ~ x, drop.unused.levels = TRUE) :
variable lengths differ (found for ‘x’)
What is the problem here?

foxhands says:

Thank you very much for your work 🙂

A. M. Goudarzi says:

Vielen dank 🙂

fearthswrm says:

Thanks though 🙂

captainrwb says:

Outstanding. How do you obtain numerically, a—the y intercept—and b the slope after it has been plotted?

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!