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(36,35,37,40,41,31,34,31,33,42,41,42,41,40,35,35,47,46,45,41,40,38,40,36,27,27,34,28,31,27,28,19,20,14,15,42,22,17,18,10,15,15,17,12,11,7,10,6,8,3,1,9,14,12,20,24,24,44,60,68,71,76,74,74,73,72,68,60,60,60,58) > x <- c(27,29,27,26,24,30,26,28,28,24,23,24,24,27,28,25,19,19,19,20,16,22,21,25,29,28,25,26,24,28,28,28,28,32,31,22,29,31,29,32,32,31,29,28,28,29,22,26,24,27,27,23,21,19,17,19,21,13,8,5,10,6,6,8,11,12,13,19,19,18,20) > 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 11.0173000 2 14.4798647 3 12.0173000 4 12.7860176 5 9.3234529 6 12.7111471 7 6.7860176 8 8.2485824 9 10.2485824 10 10.3234529 11 7.0921705 12 10.3234529 13 9.3234529 14 15.0173000 15 12.2485824 16 5.5547352 17 4.1670410 18 3.1670410 19 2.1670410 20 0.3983234 21 -9.5268061 22 1.8608881 23 1.6296058 24 6.5547352 25 6.4798647 26 4.2485824 27 4.5547352 28 0.7860176 29 -0.6765471 30 4.2485824 31 5.2485824 32 -3.7514176 33 -2.7514176 34 0.1737118 35 -1.0575705 36 5.8608881 37 1.4798647 38 0.9424295 39 -2.5201353 40 -3.8262882 41 1.1737118 42 -1.0575705 43 -3.5201353 44 -10.7514176 45 -11.7514176 46 -13.5201353 47 -26.1391119 48 -21.2139824 49 -23.6765471 50 -21.9827000 51 -23.9827000 52 -24.9078295 53 -24.3703942 54 -30.8329590 55 -27.2955237 56 -18.8329590 57 -14.3703942 58 -12.2206532 59 -7.3770650 60 -6.0709121 61 8.0854997 62 4.1603702 63 2.1603702 64 6.6229350 65 12.3167821 66 13.5480645 67 11.7793468 68 17.1670410 69 17.1670410 70 14.9357587 71 17.3983234 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1njnk1260883510.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/2o7zq1260883510.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/3gtcl1260883510.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/4mpy61260883510.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/5jhu51260883510.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/680uu1260883510.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/7g7kj1260883510.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/84a8o1260883510.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. 5.00 19.00 24.00 22.85 28.00 32.00 > > #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/9m7w51260883510.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/10w0su1260883510.tab") > > try(system("convert tmp/1njnk1260883510.ps tmp/1njnk1260883510.png",intern=TRUE)) character(0) > try(system("convert tmp/2o7zq1260883510.ps tmp/2o7zq1260883510.png",intern=TRUE)) character(0) > try(system("convert tmp/3gtcl1260883510.ps tmp/3gtcl1260883510.png",intern=TRUE)) character(0) > try(system("convert tmp/4mpy61260883510.ps tmp/4mpy61260883510.png",intern=TRUE)) character(0) > try(system("convert tmp/5jhu51260883510.ps tmp/5jhu51260883510.png",intern=TRUE)) character(0) > try(system("convert tmp/680uu1260883510.ps tmp/680uu1260883510.png",intern=TRUE)) character(0) > try(system("convert tmp/7g7kj1260883510.ps tmp/7g7kj1260883510.png",intern=TRUE)) character(0) > try(system("convert tmp/84a8o1260883510.ps tmp/84a8o1260883510.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.547 1.148 2.440