Created
March 27, 2011 03:02
-
-
Save Protonk/888873 to your computer and use it in GitHub Desktop.
plot for a reddit question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ####Context: http://www.reddit.com/r/statistics/comments/gc7zn/how_do_you_quantify_the_goodness_of_a_fit/ | |
| #dput() is freakin' awesome | |
| slope<-structure(list(x0 = c(90L, 90L, 90L, 75L, 75L, 75L, 75L, 60L, | |
| 60L, 60L, 30L, 30L, 30L, 30L, 90L, 90L, 90L, 75L, 75L, 75L, 75L, | |
| 60L, 60L, 60L, 30L, 30L, 30L, 30L), y0 = c(0.87355252855632, | |
| 0.96510036804794, 0.99961155254449, 0.83250156448838, 0.90994111936252, | |
| 0.81220807703055, 0.88450841597365, 0.93325151195878, 0.88359117143352, | |
| 0.85099464726141, 0.88641984414472, 0.88585837018634, 0.86312678397544, | |
| 0.87395793611538, 0.95257033724407, 0.96405226327959, 1.24511295032759, | |
| 0.87511994935464, 0.909246441656, 0.88225329421107, 0.92980597874911, | |
| 0.95485054561817, 0.8753713639181, 0.8489278433822, 0.93234996072948, | |
| 0.966867344616, 0.94658251862214, 0.86651964545681)), .Names = c("x", | |
| "y"), class = "data.frame", row.names = c(NA, -28L)) | |
| slope.lm<-lm(y ~ x, data=slope) | |
| #I forgot that base plot is not like ggplot2. type plot(resid.den) to see the plot for this guy | |
| resid.den<- density(resid(slope.lm)) | |
| full.plot<- function() { | |
| with(slope,plot(x,y,ylim=c(0.6,1.4))) | |
| abline(a=confint(slope.lm)[1,2],b=confint(slope.lm)[2,2],lwd=0.5,lty=2) | |
| abline(a=confint(slope.lm)[1,1],b=confint(slope.lm)[2,1],lwd=0.5,lty=2) | |
| abline(a=coef(slope.lm)[[1]],b=coef(slope.lm)[[2]],lwd=0.5,col="blue") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment