Great video, but I am trying to do just this, had the same code you used. R didnt return any errors, but my regression line does not show up on my scatterplot. Any help on why that is would be appreciated.
Sorry this is 3 months past the question, it looks like a lot of people are having this issue based on the number of thumbs on this post. If you, or anyone who is having this issue could post their code I could take a closer look. I know it's only two lines, but it only takes something small for it not to work. Without seeing the code, I would guess that the variables need to be switched on abline. So where we have plot(x-variable, y-variable) we need abline(lm(y-variable ~ x-variable, data = data))
For people looking at this in the future, the most common mistake is in the abline. Here it's abline(lm(mpg ~ hp)...... try switching the mpg and hp around in that part of your code. So for example, if you have plot(X,Y), then it would look like abline(lm(Y ~ X, .........
Please make more videos on R. I am a psychologist who likes your simple and easy method of teaching stats with R. Please also cover non linear models, ancova, manova, repeated measures etc in your future videos. But using the same easy method. Great stuff.
Thank you for the feedback! I do have one video on ANOVA if you want to check it out here... ruclips.net/video/qrP7evoNCy4/видео.html The rest are great ideas for future videos for me to work on!
Please I am working with several subsets of data, can I get an explanation on what to do. The question goes like this, for birth weights and pregnancy, I should assign women who smoke to 1, those who don't to 2, and those who never tried to 3. Them I should later plot a graph of the birth weight in addition to the pregnancy of those who didn't, thus 2.
Hey! Thank you very much for your useful video. I was just wonderin though: somehow I have made it such that my plots appear in a new window (i.e not in the console). Every plot I do, it makes a new window that minimises when I change my code. How do I change it bac so that my plots appear only in the plot section of the console?
is it necessary to specify the data source in the abline function? I tried with specifying it and without it and the same regression line still plots the same either way.
I keep getting these errors when I plot 2 independent ad one dependent variable. How do I fix it??? ## Warning in scatterplot.default(X[, 2], X[, 1], groups = X[, 3], xlab = xlab, : number of groups exceeds number of available colors ## colors are recycled
I am a complete beginner in programming. Can someone tell me the proper way to enter ~ within the lm() function please? I have tried shift # but didn't work. Thanks
Hi. Thank you for this video. I have one question: How can I get the R -squared value or other information about regression, for each regression line recognized trough a third variable with "car-scatterplot"? If I use summary(lm(y~x,data=mydata)) I have information about the whole selected dataset and not about each subgroup recognized trough "car-scatterplot" and a third variable. I hope the question is clear. Sorry, but I'm newbie of R.
I would use the ggplot2 package and ggpmisc package to get that information. For this dataset, this should do it ... (If packages are not installed you must install them) library(ggpmisc) library(ggplot2) library(datasets) ggplot(mtcars, aes(x = hp, y = mpg, col = factor(cyl))) + geom_point() + geom_smooth(method = 'lm') + stat_poly_eq(formula = y ~ x, aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")), parse = TRUE) So what this code does is says we are using ggplot on the mtcars dataset, x is horse power, y is mpg, and the colors for our graph are going to be based on cyl (which we have to make a factor since right now it is numeric). Then we plot the points on the graph. Put a linear regression line through the three sets of points with confidence bands around them. Plot the linear equation for three separate lines as well as their R^2 values. Hopefully this is of help to you!
Thank you! Quickly and easily explained!
Dude thankyou so much been stuck on this all day!! You’ve helped massively!!
thank you! very simple, straight to the point and very organized
You explained that easy and short and I understood it and it really helped right away, thanks alot!
Thank you! Glad you enjoyed.
Great video, but I am trying to do just this, had the same code you used. R didnt return any errors, but my regression line does not show up on my scatterplot. Any help on why that is would be appreciated.
Sorry this is 3 months past the question, it looks like a lot of people are having this issue based on the number of thumbs on this post. If you, or anyone who is having this issue could post their code I could take a closer look. I know it's only two lines, but it only takes something small for it not to work. Without seeing the code, I would guess that the variables need to be switched on abline. So where we have plot(x-variable, y-variable) we need abline(lm(y-variable ~ x-variable, data = data))
For people looking at this in the future, the most common mistake is in the abline. Here it's abline(lm(mpg ~ hp)...... try switching the mpg and hp around in that part of your code. So for example, if you have plot(X,Y), then it would look like abline(lm(Y ~ X, .........
thanks. your video helps me a lot.
You're welcome! Glad it helped.
The abline doesnt work for me
Thanks for the help! Very easy to follow
Please make more videos on R. I am a psychologist who likes your simple and easy method of teaching stats with R. Please also cover non linear models, ancova, manova, repeated measures etc in your future videos. But using the same easy method. Great stuff.
Thank you for the feedback! I do have one video on ANOVA if you want to check it out here... ruclips.net/video/qrP7evoNCy4/видео.html
The rest are great ideas for future videos for me to work on!
@@thatrnerd4265
Thank you so much for the link and for listening to my suggestions. Cheers.
That was really helpful, THANK YOU!
Please I am working with several subsets of data, can I get an explanation on what to do. The question goes like this, for birth weights and pregnancy, I should assign women who smoke to 1, those who don't to 2, and those who never tried to 3. Them I should later plot a graph of the birth weight in addition to the pregnancy of those who didn't, thus 2.
Thank you very much
this is really helpful, thanks!!
Thank you!
Awesome vid, so much out of so little
Is your third variable on your 'Enhanced Scatter Plot' a control or an instrument? Thanks for the video!
Hey! Thank you very much for your useful video. I was just wonderin though: somehow I have made it such that my plots appear in a new window (i.e not in the console). Every plot I do, it makes a new window that minimises when I change my code. How do I change it bac so that my plots appear only in the plot section of the console?
Thx sir
is it necessary to specify the data source in the abline function? I tried with specifying it and without it and the same regression line still plots the same either way.
thank you
Wow. This is awesome.
My scatter plots don’t look right, what am I doing wrong? Please help because my assignment is due Tuesday!
I keep getting these errors when I plot 2 independent ad one dependent variable. How do I fix it???
## Warning in scatterplot.default(X[, 2], X[, 1], groups = X[, 3], xlab = xlab, : number of groups exceeds number of available colors
## colors are recycled
Same issue
I am a complete beginner in programming. Can someone tell me the proper way to enter ~ within the lm() function please? I have tried shift # but didn't work. Thanks
Press shift and then the button to the left of 1.
Thanks
I cant find the package car when you did library(cars)
Hi.
Thank you for this video.
I have one question:
How can I get the R -squared value or other information about regression, for each regression line recognized trough a third variable with "car-scatterplot"?
If I use summary(lm(y~x,data=mydata)) I have information about the whole selected dataset and not about each subgroup recognized trough "car-scatterplot" and a third variable.
I hope the question is clear.
Sorry, but I'm newbie of R.
I would use the ggplot2 package and ggpmisc package to get that information. For this dataset, this should do it ...
(If packages are not installed you must install them)
library(ggpmisc)
library(ggplot2)
library(datasets)
ggplot(mtcars, aes(x = hp, y = mpg, col = factor(cyl))) +
geom_point() +
geom_smooth(method = 'lm') +
stat_poly_eq(formula = y ~ x, aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")), parse = TRUE)
So what this code does is says we are using ggplot on the mtcars dataset, x is horse power, y is mpg, and the colors for our graph are going to be based on cyl (which we have to make a factor since right now it is numeric).
Then we plot the points on the graph.
Put a linear regression line through the three sets of points with confidence bands around them.
Plot the linear equation for three separate lines as well as their R^2 values.
Hopefully this is of help to you!
Thank you very much for the help.
I will try it, immediately!
displacement wtf?!?!?!