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(-14.6,-12.378,-2.954,4.084,-3.12,-6.972,3.328,14.02,21.462,12.672,5.214,22.244,3.2,-7.112,2.212,-1.282,3.362,8.978,4.39,12.806,16.714,9.004,21.322,25.216,2.854,-9.518,6.27,5.474,10.502,12.88,15.008,18.134,24.768,24.43,25.342,36.53,11.124,-2.302,21.684,16.254,16.75,19.926,16.388,30.8,35.514,31.9,36.712,44.18,20.738,13.068,20.596,19.098,11.34,4.914,-0.106,8.43,2.054,1.408,-5.328,9.634) > x <- c(15.47,95.74,123.06,123.39,120.28,115.33,110.4,114.49,132.03,123.16,118.82,128.32,112.24,104.53,132.57,122.52,131.8,124.55,120.96,122.6,145.52,118.57,134.25,136.7,121.37,111.63,134.42,137.65,137.86,119.77,130.69,128.28,147.45,128.42,136.9,143.95,135.64,122.48,136.83,153.04,142.71,123.46,144.37,146.15,147.61,158.51,147.4,165.05,154.64,126.2,157.36,154.15,123.21,113.07,110.45,113.57,122.44,114.93,111.85,126.04) > 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 23.8939965 2 -9.7789284 3 -12.5718132 4 -5.6813817 5 -11.4946602 6 -13.1331324 7 -0.6285481 8 8.2344966 9 7.8330061 10 3.0094691 11 -2.5077813 12 10.2740340 13 -1.5793544 14 -8.4436172 15 -11.6584697 16 -10.6583374 17 -10.1641431 18 -1.3061074 19 -4.2887408 20 3.3938884 21 -2.9474162 22 1.3940130 23 6.7002724 24 9.4986879 25 -6.0080835 26 -14.0245763 27 -8.4277478 28 -10.6681306 29 -5.7340378 30 4.7334002 31 1.9782237 32 6.1819211 33 4.2435315 34 12.4153163 35 9.5352524 36 17.5706522 37 -4.1193041 38 -11.6604504 39 5.9085549 40 -6.7701898 41 -1.6548479 42 10.1293159 43 -2.7591623 44 10.8568621 45 14.9179832 46 6.4297502 47 16.2098904 48 15.7852104 49 -3.0016735 50 2.0460500 51 -4.3599959 52 -4.4225566 53 1.6551102 54 -0.2365116 55 -4.0849070 56 3.0558997 57 -7.2865633 58 -4.5742615 59 -9.9329553 60 -1.3164017 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/17uk41257350073.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/2b9ph1257350073.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/3ygm01257350073.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/4ulgn1257350073.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/5e49g1257350073.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/6m4cd1257350073.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/7tzrq1257350073.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/8ujgq1257350074.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. 15.47 119.50 126.10 127.60 137.70 165.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/91kcd1257350074.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/10ksyl1257350074.tab") > > system("convert tmp/17uk41257350073.ps tmp/17uk41257350073.png") > system("convert tmp/2b9ph1257350073.ps tmp/2b9ph1257350073.png") > system("convert tmp/3ygm01257350073.ps tmp/3ygm01257350073.png") > system("convert tmp/4ulgn1257350073.ps tmp/4ulgn1257350073.png") > system("convert tmp/5e49g1257350073.ps tmp/5e49g1257350073.png") > system("convert tmp/6m4cd1257350073.ps tmp/6m4cd1257350073.png") > system("convert tmp/7tzrq1257350073.ps tmp/7tzrq1257350073.png") > system("convert tmp/8ujgq1257350074.ps tmp/8ujgq1257350074.png") > > > proc.time() user system elapsed 1.633 1.194 2.548