How to plot a linear regression to a double logarithmic R plot?

882    Asked by CharlesParr in Data Science , Asked on Nov 5, 2019
Answered by Nitin Solanki

 Suppose we have following data

someFactor = 500

x = c(1:250)

y = x^-.25 * someFactor

Easiest way to add a regression line to plot

lines(log(x), exp(predict(model, newdata=list(x=log(x)))) ,col="red")



The range of values for x plotted on the log-scale and for log(x) being used as the independent variable are actually quite different. This will give us the full range

lines(x, exp(predict(model, newdata=list(x=x))) ,col="red")




Your Answer

Interviews

Parent Categories