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(146.54,120.13,131.67,131.97,145.92,177.02,149.56,171.58,173.95,190.39,183.46,165.44,186.32,223.29,198.99,191.05,178.42,187.85,183.51,252.94,213.51,185.53,215.48,214.39,229.21,183.55,206.71,186.23,217.46,214.69,202.06,225.57,220.70,246.32,273.51,220.66,295.88,215.35,230.83,220.00,232.06,237.68,294.39,295.35,267.68,274.12,246.84,249.34,303.25,236.14,233.38,260.96,281.18,281.54,288.95,332.68,345.96,414.96,285.35,288.03) > x <- c(153.24,184.48,191.81,168.19,163.81,190.57,163.81,129.62,173.90,198.76,135.52,179.81,137.05,142.57,187.52,220.48,208.76,210.19,232.57,173.81,218.86,226.76,196.67,237.43,173.14,207.62,234.67,204.10,230.76,210.19,194.76,172.10,221.90,225.24,228.00,198.76,199.05,235.43,270.76,234.10,237.24,239.43,239.24,197.33,217.43,242.19,207.52,232.76,222.10,202.48,228.10,319.52,236.95,252.00,262.29,172.10,243.90,235.62,216.95,236.29) > 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 -37.678390 2 -87.697687 3 -81.697256 4 -63.546693 5 -46.286555 6 -35.410140 7 -42.646555 8 5.212174 9 -25.881965 10 -28.229645 11 12.633312 12 -38.858384 13 14.337031 14 47.135349 15 -11.135135 16 -43.984304 17 -47.757038 18 -39.407746 19 -60.661192 20 53.176052 21 -20.300006 22 -54.250347 23 -1.560150 24 -33.454086 25 29.952397 26 -41.765496 27 -39.048245 28 -36.425293 29 -25.343304 30 -12.567746 31 -13.536688 32 27.098366 33 -15.407454 34 7.688377 35 32.792536 36 2.040355 37 77.041191 38 -30.982607 39 -42.202878 40 -25.327474 41 -15.640495 42 -11.675564 43 45.178026 44 77.811062 45 34.950701 46 22.678595 47 21.600078 48 5.025217 49 66.991399 50 14.709005 51 -7.413038 52 -48.922729 53 33.698669 54 22.684792 55 22.318234 56 134.208366 57 93.226281 58 168.483803 59 52.983456 60 41.047457 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1cd421258141025.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/2znbe1258141025.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/3klet1258141025.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/4lshq1258141025.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/5y17n1258141025.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/6el7b1258141025.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/7ydyo1258141025.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/8tyii1258141025.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. 129.6 186.8 210.2 208.5 234.2 319.5 > > #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/9hp221258141025.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/10feaa1258141026.tab") > system("convert tmp/1cd421258141025.ps tmp/1cd421258141025.png") > system("convert tmp/2znbe1258141025.ps tmp/2znbe1258141025.png") > system("convert tmp/3klet1258141025.ps tmp/3klet1258141025.png") > system("convert tmp/4lshq1258141025.ps tmp/4lshq1258141025.png") > system("convert tmp/5y17n1258141025.ps tmp/5y17n1258141025.png") > system("convert tmp/6el7b1258141025.ps tmp/6el7b1258141025.png") > system("convert tmp/7ydyo1258141025.ps tmp/7ydyo1258141025.png") > system("convert tmp/8tyii1258141025.ps tmp/8tyii1258141025.png") > > > proc.time() user system elapsed 1.626 1.181 1.937