I would like to be able to place a normal distribution surrounding the
predicted values at various places on a plot. Below is some toy code
that creates a scatterplot and plots a regression line through the data.
library(MASS)
mu - c(0,1)
Sigma - matrix(c(1,.8,.8,1), ncol=2)
set.seed(123)
x -
Something like this?
library(MASS)
mu - c(0,1)
Sigma - matrix(c(1,.8,.8,1), ncol=2)
set.seed(123)
x - mvrnorm(50,mu,Sigma)
dta - data.frame(x=x[,1],y=x[,2])
plot(x)
fit - lm(y~x, data=dta)
sfit - summary(fit)
se - sfit$sigma
abline(fit)
yhat - predict(fit,data.frame(x=c(-1,0,1)),se.fit=TRUE)
Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold
Sent: Tuesday, October 31, 2006 6:26 AM
To: R-help@stat.math.ethz.ch
Subject: [R] Put a normal curve on plot
I would like to be able to place a normal distribution surrounding the
predicted values at various