Displaying 2 results from an estimated 2 matches for "xylm".
Did you mean:
mylm
2012 Aug 28
3
date in plot, can't add regression line
...method 1):
xdates <- tradeflavorbyday$timestamp[tradeflavorbyday$tradeflavor == 1]
ydata <- tradeflavorbyday$x[tradeflavorbyday$tradeflavor == 1]
plot(xdates, ydata, col="black", xlab="Dates", ylab="Count")
Up to here it works great.
Now a abline through lm:
xylm <- lm(ydata~xdates) <------ this fails, can't do dates as below
abline(xylm, col="black")
> lm(ydata~xdates)
Error in model.frame.default(formula = ydata ~ xdates, drop.unused.levels = TRUE) :
invalid type (list) for variable 'xdates'
So I try this instead (m...
2007 Jan 12
5
Regression lines
My simpleminded understanding of simple regression is that when
plotting regression lines for x on y and y on x in the same plot, the
lines should cross each other at the respective means. But, given the
R function below, abline (lm(y~x)) works fine, but abline (lm(x~y))
does not. Why?
function () {
attach (attitude)
x <- rating
y <- learning
detach (attitude)
plot (x, y)