R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(267413,267366,264777,258863,254844,254868,277267,285351,286602,283042,276687,277915,277128,277103,275037,270150,267140,264993,287259,291186,292300,288186,281477,282656,280190,280408,276836,275216,274352,271311,289802,290726,292300,278506,269826,265861,269034,264176,255198,253353,246057,235372,258556,260993,254663,250643,243422,247105,248541,245039,237080,237085,225554,226839,247934,248333,246969,245098,246263,255765,264319,268347,273046,273963,267430,271993,292710,295881,293299) > x <- c(26.90,27.80,28.70,30.50,31.80,31.40,34.80,32.20,33.00,32.40,30.50,28.60,30.00,28.20,27.60,24.90,23.80,24.30,23.60,24.20,28.10,30.10,31.10,32.00,32.40,34.00,35.10,37.10,37.30,38.10,39.50,38.30,37.30,38.70,37.50,38.70,37.90,36.60,35.50,37.60,38.60,40.30,39.00,36.80,36.50,34.10,34.20,31.90,33.70,33.50,33.80,29.90,32.30,30.50,28.50,29.00,23.80,17.90,9.90,3.00,4.20,0.40,0.00,2.40,4.20,8.20,9.00,13.60,14.00) > par2 = '12' > 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 453.7610 2 567.1500 3 -1861.4610 4 -7454.6831 5 -11242.0101 6 -11289.2941 7 11715.6198 8 19336.2739 9 20729.8419 10 17062.9159 11 10369.3169 12 11258.7180 13 10721.2119 14 10375.4340 15 8202.5080 16 2834.3411 17 -371.6899 18 -2429.5849 19 19711.6681 20 23745.5941 21 25554.6130 22 21797.0329 23 15266.2429 24 16605.6319 25 14210.9159 26 14714.0518 27 11338.0828 28 10074.5028 29 9246.1448 30 6347.7127 31 25088.2067 32 25798.3547 33 27194.1448 34 13649.6387 35 4755.7868 36 1004.6387 37 4035.0707 38 -1054.6022 39 -10228.6332 40 -11699.3922 41 -18817.1823 42 -29199.2253 43 -6246.8983 44 -4201.9602 45 -10585.4232 46 -15033.1272 47 -22236.3062 48 -18963.1891 49 -17206.4111 50 -20744.0531 51 -28649.5902 52 -29339.6091 53 -40442.9051 54 -39478.6831 55 -18740.1030 56 -18251.9980 57 -20542.6899 58 -23465.1288 59 -23725.8086 60 -15453.4574 61 -6685.6054 62 -3334.8033 63 1292.9127 64 2637.6166 65 -3574.6054 66 1701.2345 67 22560.8024 68 26551.5683 69 24040.8523 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/1zf9s1257360431.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/freestat/rcomp/tmp/2ecm11257360431.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/freestat/rcomp/tmp/3rnfs1257360431.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/freestat/rcomp/tmp/4dqcl1257360431.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/freestat/rcomp/tmp/5nem51257360431.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/freestat/rcomp/tmp/6lfl81257360431.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/freestat/rcomp/tmp/7qf281257360431.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/freestat/rcomp/tmp/8h92k1257360431.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. 0.00 24.90 31.40 28.13 35.50 40.30 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/9lb0i1257360431.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/freestat/rcomp/tmp/10z2dc1257360431.tab") > > system("convert tmp/1zf9s1257360431.ps tmp/1zf9s1257360431.png") > system("convert tmp/2ecm11257360431.ps tmp/2ecm11257360431.png") > system("convert tmp/3rnfs1257360431.ps tmp/3rnfs1257360431.png") > system("convert tmp/4dqcl1257360431.ps tmp/4dqcl1257360431.png") > system("convert tmp/5nem51257360431.ps tmp/5nem51257360431.png") > system("convert tmp/6lfl81257360431.ps tmp/6lfl81257360431.png") > system("convert tmp/7qf281257360431.ps tmp/7qf281257360431.png") > system("convert tmp/8h92k1257360431.ps tmp/8h92k1257360431.png") > > > proc.time() user system elapsed 2.570 1.923 2.959