Predict.Lm() in a Loop. Warning: Prediction from a Rank-Deficient Fit May Be Misleading

prediction from a rank-deficient fit may be misleading in geom_smooth()

You're encountering a numerical precision rounding problem.

You could center x by substracting mean(x).

ggplot(temp, aes(x, y)) +
geom_point() +
geom_smooth(method= "lm", formula = y ~ I(x-mean(x)))

Sample Image

error when adding lm to datetime data in ggplot2

Typically the package picks the orientation (x or y) automatically. However, when it becomes uncertain, you see that message. You don't need to specify the formula, you can just specify the orientation.

library("ggplot2")
library("scales")

ggplot(aes(x = Time, y = LIN), data = ToPlot) +
geom_point() +
geom_line() +
scale_x_datetime(labels = date_format("%H:%m:%S"))+
geom_smooth(method='lm', orientation = "y")

Sample Image



Related Topics



Leave a reply



Submit