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(-28.232,-13.6128,-14.4528,-12.7712,-15.2384,-16.7344,-18.3704,-16.0232,-11.6492,-14.7028,-10.8104,-7.5492,-5.5476,-2.2228,-1.4812,-3.5976,-8.312,-7.4576,-2.8216,-2.5256,-2.4896,-6.3904,-12.4092,-5.4076,-6.1492,-7.8852,-11.7896,-18.908,-5.7212,2.8656,1.6096,2.4216,-2.976,-3.442,-4.746,-5.6232,-4.1092,-3.9728,-1.9512,-7.706,-14.754,-21.7552,-18.6744,-21.0932,-31.2252,-33.948,-41.6084,-36.5632,-33.9704,-26.056,-30.1576,-40.3312,-50.2164,-47.2612,-57.94,-65.2624,-64.9752,-68.884,-69.8192,-60.0244,-52.6772) > x <- c(-9.122,-0.1328,2.1672,1.6288,4.1716,7.1856,2.0096,-0.7332,0.6508,0.7672,-1.4704,-0.7492,0.2124,2.8372,4.0488,3.2124,4.318,4.0624,5.8284,6.4044,6.6204,4.5496,-0.1492,2.6424,1.5908,2.4748,1.1604,-4.578,2.7388,6.1556,5.5796,6.9016,5.604,6.768,3.314,2.7268,3.5708,3.5372,5.4188,2.344,-0.964,-0.3252,1.6556,0.6368,-6.6752,-8.808,-11.5384,-10.5732,-12.8804,-7.756,-7.2176,-13.2612,-15.1764,-14.1912,-20.34,-20.2924,-17.6652,-15.494,-18.6892,-18.4544,-13.7072) > 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 8.1948734 2 1.6244423 3 -4.6371916 4 -1.6864578 5 -10.1476277 6 -18.7483254 7 -8.1832918 8 0.6293245 9 1.7409152 10 -1.5870666 11 7.5798760 12 9.1410402 13 8.8759258 14 6.0134628 15 3.8990404 16 3.7542293 17 -3.5663265 18 -2.1094180 19 -1.6362899 20 -2.6980557 21 -3.1712178 22 -2.1906615 23 2.8667009 24 3.2878517 25 5.0251170 26 1.2053238 27 0.3992697 28 6.8076106 29 2.7470145 30 3.2796237 31 3.3813894 32 1.0771285 33 -1.2617270 34 -4.4715453 35 2.3663346 36 2.8733013 37 2.3977973 38 2.6134003 39 0.1996323 40 1.6928497 41 2.4425736 42 -6.0644262 43 -7.6528317 44 -7.6700836 45 -0.5660022 46 1.7387026 47 0.5144892 48 3.2844887 49 11.3158947 50 7.1508943 51 1.7801606 52 5.8527287 53 0.4820997 54 1.1149546 55 4.9303036 56 -2.5043007 57 -8.4100209 58 -17.4368434 59 -10.8402152 60 -1.5988933 61 -5.4419457 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1ewil1257350680.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/2xyfi1257350680.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/3po7n1257350680.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/468no1257350680.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/59oue1257350680.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/6lu6w1257350680.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/7re4q1257350680.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/8soj81257350680.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. -20.340 -7.756 1.160 -2.057 3.571 7.186 > > #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/9deci1257350680.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/10vn0c1257350680.tab") > > system("convert tmp/1ewil1257350680.ps tmp/1ewil1257350680.png") > system("convert tmp/2xyfi1257350680.ps tmp/2xyfi1257350680.png") > system("convert tmp/3po7n1257350680.ps tmp/3po7n1257350680.png") > system("convert tmp/468no1257350680.ps tmp/468no1257350680.png") > system("convert tmp/59oue1257350680.ps tmp/59oue1257350680.png") > system("convert tmp/6lu6w1257350680.ps tmp/6lu6w1257350680.png") > system("convert tmp/7re4q1257350680.ps tmp/7re4q1257350680.png") > system("convert tmp/8soj81257350680.ps tmp/8soj81257350680.png") > > > proc.time() user system elapsed 1.574 1.159 1.973