R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > y <- c(16,15,16,15,17,14,15,16,16,15,13,12,13,13,12,10,14,14,15,16,16,15,15,13,15,15,15,13,16,16,14,16,15,14,15,15,14,13,12,13,12,9,10,8,11,8,8,8,4,6,8,10,5,6,5,9,8,6,9,11,11) > x <- c(20.3,20,19.2,21.8,21.3,21.5,19.5,19.5,19.7,18.7,19.7,20,19.7,19.2,19.7,22,21.8,22.8,21,25,23.3,25,26.8,25.3,26.5,27.8,22,22.3,28,25,27.3,25.8,27.3,23.5,24.5,18,21.3,21.8,20.5,22.3,18.7,22.3,17.7,19.7,20.5,18.5,10,14.2,15.5,16.5,20.5,15.7,11.7,7.5,3.5,4.5,2.2,5,2.3,6.1,3.3) > par2 = '36' > par1 = '0' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: > par1 <- as.numeric(par1) > par2 <- as.numeric(par2) > x <- as.ts(x) > y <- as.ts(y) > mylm <- lm(y~x) > cbind(mylm$resid) [,1] 1 3.22974617 2 2.33471286 3 3.61462402 4 1.70491273 5 3.87985721 6 0.80987942 7 2.50965733 8 3.50965733 9 3.43967954 10 2.78956850 11 0.43967954 12 -0.66528714 13 0.43967954 14 0.61462402 15 -0.56032046 16 -3.36506506 17 0.70491273 18 0.35502377 19 1.98482390 20 1.58526806 21 2.18007929 22 0.58526806 23 -0.04453206 24 -1.51969862 25 0.06043463 26 -0.39442102 27 1.63493494 28 -0.47003175 29 0.53560119 30 1.58526806 31 -1.21947654 32 1.30535690 33 -0.21947654 34 0.11010150 35 0.76021254 36 3.03449077 37 0.87985721 38 -0.29508727 39 -0.84023162 40 -0.47003175 41 -0.21043150 42 -4.47003175 43 -1.86054254 44 -4.56032046 45 -1.84023162 46 -4.14045371 47 -1.16639756 48 -2.63593119 49 -7.09078683 50 -5.44067579 51 -4.84023162 52 -1.16076462 53 -4.76120879 54 -2.29167516 55 -1.89211933 56 1.75799171 57 1.56273632 58 -1.41695277 59 2.52774742 60 3.19816938 61 4.17785846 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1nms11258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(y,type='l',main='Run Sequence Plot of Y[t]',xlab='time or index',ylab='value') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2pjmb1258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,type='l',main='Run Sequence Plot of X[t]',xlab='time or index',ylab='value') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/3g1j51258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,y,main='Scatter Plot',xlab='X[t]',ylab='Y[t]') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4wppd1258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mylm$resid,type='l',main='Run Sequence Plot of e[t]',xlab='time or index',ylab='value') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5vjka1258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mylm$resid,main='Histogram of e[t]') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/6e65u1258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > if (par1 > 0) + { + densityplot(~mylm$resid,col='black',main=paste('Density Plot of e[t] bw = ',par1),bw=par1) + } else { + densityplot(~mylm$resid,col='black',main='Density Plot of e[t]') + } > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/7s0kc1258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mylm$resid,main='QQ plot of e[t]') > qqline(mylm$resid) > grid() > dev.off() null device 1 > if (par2 > 0) + { + postscript(file="/var/www/html/rcomp/tmp/8g7z41258123930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + acf(mylm$resid,lag.max=par2,main='Residual Autocorrelation Function') + grid() + dev.off() + } null device 1 > summary(x) Min. 1st Qu. Median Mean 3rd Qu. Max. 2.2 18.0 20.3 18.9 22.3 28.0 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Model: Y[t] = c + b X[t] + e[t]',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'c',1,TRUE) > a<-table.element(a,mylm$coeff[[1]]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'b',1,TRUE) > a<-table.element(a,mylm$coeff[[2]]) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/9ov0j1258123930.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Descriptive Statistics about e[t]',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'# observations',header=TRUE) > a<-table.element(a,length(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'minimum',header=TRUE) > a<-table.element(a,min(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Q1',header=TRUE) > a<-table.element(a,quantile(mylm$resid,0.25)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'median',header=TRUE) > a<-table.element(a,median(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'mean',header=TRUE) > a<-table.element(a,mean(mylm$resid)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Q3',header=TRUE) > a<-table.element(a,quantile(mylm$resid,0.75)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'maximum',header=TRUE) > a<-table.element(a,max(mylm$resid)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/10clj71258123930.tab") > > system("convert tmp/1nms11258123930.ps tmp/1nms11258123930.png") > system("convert tmp/2pjmb1258123930.ps tmp/2pjmb1258123930.png") > system("convert tmp/3g1j51258123930.ps tmp/3g1j51258123930.png") > system("convert tmp/4wppd1258123930.ps tmp/4wppd1258123930.png") > system("convert tmp/5vjka1258123930.ps tmp/5vjka1258123930.png") > system("convert tmp/6e65u1258123930.ps tmp/6e65u1258123930.png") > system("convert tmp/7s0kc1258123930.ps tmp/7s0kc1258123930.png") > system("convert tmp/8g7z41258123930.ps tmp/8g7z41258123930.png") > > > proc.time() user system elapsed 1.636 1.205 2.213