rm(list=ls()) # remove variables from previous session rm(list=ls()) # read file dfr <- read.csv(file="FCAT_Mult_grade3.csv",head=TRUE,sep=",") #ssrss03 = FCAT Reading Score #Orfwrcf = Oral Reading Fluency – FCAT Passages print(dfr$ssrss03) print(dfr$Orfwrcf) regr = lm(ssrss03 ~ Orfwrcf, data=dfr) plot(dfr$ssrss03, dfr$Orfwrcf) #create artificial data # objective: the line y = .4 x + 2 nb.pts = 50 x = sample(seq(-5,5,.01), nb.pts) #--------------------------------- par(mfrow=c(2,2)) fluct = c(.05,.25,.5,2.5) # Keep intercept fixed (=2) and change the slope slopes = c(-.5, 0., .5, 2.) y1 = slopes[1]*x + 2 y2 = slopes[2]*x + 2 y3 = slopes[3]*x + 2 y4 = slopes[4]*x + 2 # Add an error term (the same for each plot) y1 = y1+rnorm(nb.pts, sd=fluct[3]) y2 = y2+rnorm(nb.pts, sd=fluct[3]) y3 = y3+rnorm(nb.pts, sd=fluct[3]) y4 = y4+rnorm(nb.pts, sd=fluct[3]) plot(x,y1); plot(x,y2) plot(x,y3); plot(x,y4) #---------------------------------- plot(x,y1,ylim=c(-10,10),main="slope=-0.5",cex.main=2) plot(x,y2,ylim=c(-10,10),main="slope=0.",cex.main=2) plot(x,y3,ylim=c(-10,10),main="slope=0.5",cex.main=2) plot(x,y4,ylim=c(-10,10),main="slope=2",cex.main=2) par(mfrow=c(1,1))