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(1844,1790,1707,1617,1530,1453,1386,1329,1255,1201,1179,1167,1160,1161,1203,1290,1404,1550,1670,1746,1817,1836,1872,1956,2010,1933,1917,1900,1829,1805,1730,1650,1618,1582,1576,1512,1540,1519,1473,1402,1299,1267,1200,1145,1103,1076,1095,1080,1082,1060,1027,1003,987,959,913,912,889,882,901,913,921,914,950,894,930,890,898,880,840,845,819,838,833,837,850,927,932,978,978,974,977,950,935,913,942,990,1075,1181,1336,1492) > x <- c(100.3,101.9,102.1,103.2,103.7,106.2,107.7,109.9,111.7,114.9,116.0,118.3,120.4,126.0,128.1,130.1,130.8,133.6,134.2,135.5,136.2,139.1,139.0,139.6,138.7,140.9,141.3,141.8,142.0,144.5,144.6,145.5,146.8,149.5,149.9,150.1,150.9,152.8,153.1,154.0,154.9,156.9,158.4,159.7,160.2,163.2,163.7,164.4,163.7,165.5,165.6,166.8,167.5,170.6,170.9,172.0,171.8,173.9,174.0,173.8,173.9,176.0,176.6,178.2,179.2,181.3,181.8,182.9,183.8,186.3,187.4,189.2,189.7,191.9,192.6,193.7,194.2,197.6,199.3,201.4,203.0,206.3,207.1,209.8,211.1,215.3,217.4,215.5,210.9,212.6) > 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 159.0826934 2 116.7032191 3 35.1557849 4 -46.8551037 5 -130.2236894 6 -189.0666178 7 -245.1723749 8 -286.1941520 9 -347.1210605 10 -377.8800089 11 -391.8908975 12 -387.1863917 13 -378.9344516 14 -337.2626114 15 -280.0106713 16 -178.4850141 17 -59.4010340 18 106.9348861 19 231.2925833 20 316.7342604 21 392.8182405 22 432.8804434 23 468.1541606 24 556.5118577 25 603.9753120 26 542.9535349 27 529.8586664 28 516.4900807 29 446.9426464 30 441.0997179 31 366.8260008 32 293.3625465 33 270.8042237 34 254.4138610 35 251.3189924 36 188.7715582 37 222.5818210 38 215.3811954 39 171.5600440 40 107.0965897 41 10.6331355 42 -6.8412073 43 -62.9469644 44 -108.5052872 45 -146.8738729 46 -152.0853870 47 -129.4539727 48 -139.3699927 49 -142.4539727 50 -151.3808812 51 -183.6545984 52 -198.9392041 53 -209.8552240 54 -215.3404553 55 -259.1616067 56 -252.1724953 57 -276.6250610 58 -268.3731209 59 -248.6468381 60 -238.0994038 61 -229.3731209 62 -221.1211808 63 -180.7634837 64 -225.1429579 65 -181.8801293 66 -206.6281892 67 -194.9967749 68 -205.0076634 69 -238.4711177 70 -215.3140462 71 -233.3249347 72 -201.2518432 73 -202.6204289 74 -182.6422059 75 -164.5582259 76 -79.5691144 77 -70.9377001 78 -0.2440829 79 12.1027258 80 23.3546659 81 37.9751916 82 34.9425261 83 25.7527889 84 23.3624262 85 61.8041034 86 140.3079835 87 240.5599236 88 332.7605493 89 454.3515377 90 622.6983463 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1blve1257360529.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/2swr81257360529.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/3rbqq1257360529.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/47xol1257360529.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/5s6gq1257360529.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/6izs71257360529.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/75b9u1257360529.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/8h6fa1257360529.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. 100.3 139.0 161.7 160.0 182.6 217.4 > > #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/976bf1257360529.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/10sfv71257360529.tab") > > system("convert tmp/1blve1257360529.ps tmp/1blve1257360529.png") > system("convert tmp/2swr81257360529.ps tmp/2swr81257360529.png") > system("convert tmp/3rbqq1257360529.ps tmp/3rbqq1257360529.png") > system("convert tmp/47xol1257360529.ps tmp/47xol1257360529.png") > system("convert tmp/5s6gq1257360529.ps tmp/5s6gq1257360529.png") > system("convert tmp/6izs71257360529.ps tmp/6izs71257360529.png") > system("convert tmp/75b9u1257360529.ps tmp/75b9u1257360529.png") > system("convert tmp/8h6fa1257360529.ps tmp/8h6fa1257360529.png") > > > proc.time() user system elapsed 1.595 1.151 2.706