R version 2.8.1 (2008-12-22) 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(123.10,136.60,112.10,95.10,96.30,105.70,115.80,105.70,105.70,111.10,82.40,60.00,107.30,99.30,113.50,108.90,100.20,103.90,138.70,120.20,100.20,143.20,70.90,85.20,133.00,136.60,117.90,106.30,122.30,125.50,148.40,126.30,99.60,140.40,80.30,92.60,138.50,110.90,119.60,105.00,109.00,129.40,148.60,101.40,134.80,143.70,81.60,90.30,141.50,140.70,140.20,100.20,125.70,119.60,134.70,109.00,116.30,146.90,97.40,89.40,132.10,139.80,129.00,112.50,121.90,121.70,123.10,131.60,119.30,132.50,98.30,85.10,131.70,129.30,90.70,78.60,68.90,79.10) > x <- c(7.8,8,8.1,8.2,8.3,8.2,8,7.9,7.6,7.6,8.3,8.4,8.4,8.4,8.4,8.6,8.9,8.8,8.3,7.5,7.2,7.4,8.8,9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.5,8.2,8.1,7.9,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8,8.2,8.1,8.1,8,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.4,6.1,6.5,7.7,7.9,7.5,6.9,6.6,6.9,7.7,8) > 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.6564780 2 23.1093304 3 -0.9142435 4 -17.4378173 5 -15.7613911 6 -6.8378173 7 2.3093304 8 -8.2670958 9 -9.6963743 10 -4.2963743 11 -29.6613911 12 -51.5849649 13 -4.2849649 14 -12.2849649 15 1.9150351 16 -1.7321126 17 -9.0028341 18 -5.7792602 19 26.6386089 20 4.3271995 21 -17.1020790 22 26.8507733 23 -38.7792602 24 -22.0971293 25 25.7028707 26 26.4443136 27 5.3621827 28 -5.7613911 29 11.1914612 30 14.8678874 31 37.2914612 32 13.7621827 33 -13.4142435 34 26.4329042 35 -30.3321126 36 -17.5556864 37 28.3443136 38 -0.2085388 39 8.0150351 40 -6.1085388 41 -1.1556864 42 19.2443136 43 37.9678874 44 -9.7085388 45 22.7386089 46 30.2093304 47 -30.9378173 48 -22.7142435 49 28.4857565 50 27.2093304 51 26.2329042 52 -13.7670958 53 12.2093304 54 6.1093304 55 20.7329042 56 -4.4906696 57 1.3800518 58 29.5979210 59 -18.4728005 60 -27.4256529 61 13.8450686 62 21.5450686 63 10.7450686 64 -4.8020790 65 5.0743471 66 3.9214948 67 3.8922163 68 10.4865115 69 -3.2427670 70 11.8629377 71 -16.6199482 72 -28.8670958 73 15.8271995 74 10.5686424 75 -29.4606361 76 -40.1313576 77 -46.0199482 78 -34.3906696 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1ytd51256758989.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/rcomp/tmp/2w55s1256758989.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/rcomp/tmp/3o9sp1256758989.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/rcomp/tmp/4y0ae1256758989.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/rcomp/tmp/5t62r1256758989.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/rcomp/tmp/6vsn81256758989.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/rcomp/tmp/7gi2k1256758989.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/rcomp/tmp/8lffc1256758989.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. 6.100 7.525 8.000 7.953 8.400 9.300 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/97irn1256758989.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/rcomp/tmp/103ne71256758989.tab") > > system("convert tmp/1ytd51256758989.ps tmp/1ytd51256758989.png") > system("convert tmp/2w55s1256758989.ps tmp/2w55s1256758989.png") > system("convert tmp/3o9sp1256758989.ps tmp/3o9sp1256758989.png") > system("convert tmp/4y0ae1256758989.ps tmp/4y0ae1256758989.png") > system("convert tmp/5t62r1256758989.ps tmp/5t62r1256758989.png") > system("convert tmp/6vsn81256758989.ps tmp/6vsn81256758989.png") > system("convert tmp/7gi2k1256758989.ps tmp/7gi2k1256758989.png") > system("convert tmp/8lffc1256758989.ps tmp/8lffc1256758989.png") > > > proc.time() user system elapsed 1.740 1.710 3.214