Re: [R] Put a normal curve on plot

2006-10-31 Thread Greg Snow
] (801) 408-8111 -Original 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 surroundin

Re: [R] Put a normal curve on plot

2006-10-31 Thread David Barron
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=T

[R] Put a normal curve on plot

2006-10-31 Thread Doran, Harold
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 <- m