Efficient way of doing linear regression

You can do exactly that already. I will agree that it isn’t as “in your face” or easy to find as it could be though.

using GLM
x = [...]
y = [...]
reg = lm(x,y)
scatter(x,y)
plot!(x,predict(reg),label="R^2=$(r2(reg))")

also Plots.jl or StatsPlots.jl (I can’t remember which one) provides a direct option in the scatter command to put the regression line on the plot for you.

8 Likes