Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by drammock for How to create a graph showing the predictive model, data and residuals in R

what you're looking for is resid(model). Try this:

library(dynlm)
x <- 10+rnorm(100)
y <- 10+rnorm(100)
model <- dynlm(x ~ y)

plot(x, type="l", col="red", ylim=c(min(c(x,y,resid(model))), max(c(x,y,resid(model)))))
lines(y, type="l", col="green")
lines(resid(model), type="l", col="blue")

Image may be NSFW.
Clik here to view.
enter image description here


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>