# Simulate Residual Plots par(mfrow=c(3,3)) for (i in 1:9) plot(1:50, rnorm(50)) for (i in 1:9) plot(1:50, (1:50)*rnorm(50)) for (i in 1:9) plot(1:50, sqrt(1:50)*rnorm(50)) for (i in 1:9) plot(1:50, cos((1:50)*pi/25+rnorm(50))) par(mfrow=c(1,1)) par(mfrow=c(3,3)) for (i in 1:9) plot(1:50, rt(50,df=2),ylim=c(-6,6)) for (i in 1:9) hist(rt(50,df=2)) for (i in 1:9) plot(1:50, rchisq(50,df=2),ylim=c(0,12)) for (i in 1:9) hist(rchisq(50,df=2)) for (i in 1:9) plot(1:50, 2+3*rnorm(50)) for (i in 1:9) hist(2+3*rnorm(50)) par(mfrow=c(1,1)) # Simulations-homework x1<-seq(from=-3,to=3,by=0.2) x2<-x1+0.8*rnorm(length(x1)) # add some random scatter to x1 plot(x1,x2) a<-seq(from=-3,to=3,by=0.2) a1<-rep(a,length(a)) a2<-rep(a,each=length(a)) x<-cbind(a1,a2) # Create grid s<-sample(seq(1:length(a1)),size=length(a),replace=FALSE) # Choose random points from the grid x<-x[s,] x1<-x[,1] x1<-x[,2] plot(x1,x2)