Quantcast
Channel: How to create a graph showing the predictive model, data and residuals in R - Stack Overflow
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

$
0
0

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")

enter image description here


Viewing all articles
Browse latest Browse all 3

Trending Articles