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(100,101.73,102.97,100.18,99.58,100.79,102.60,99.08,99.31,100.24,101.64,105.56,108.99,106.24,108.25,106.18,104.04,107.16,107.14,111.00,109.75,110.51,108.55,112.37,112.26,115.12,115.18,117.17,117.87,114.22,114.22,114.98,117.26,120.14,123.91,125.96,127.53,129.32,126.52,127.78,133.32,137.66,135.32,130.87,132.56,137.36,139.02,133.07,132.02,123.98,119.65,119.29,124.65,125.87,114.82,114.16,115.82,104.70,87.12,79.92) > x <- c(100.00,104.02,112.82,133.11,102.26,103.44,98.49,111.32,112.82,114.67,121.37,129.34,107.12,112.32,121.71,119.11,114.84,123.72,117.69,121.54,114.92,123.55,126.32,139.40,151.55,163.79,164.29,194.22,233.36,202.01,189.10,190.36,213.75,194.13,207.21,232.19,218.11,227.66,239.56,223.55,225.48,226.82,209.05,214.08,202.85,230.93,240.74,232.36,250.29,288.18,337.97,280.64,278.96,282.65,294.38,294.89,227.66,205.87,168.48,166.14) > 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 -3.3111603 2 -2.1368300 3 -2.1132212 4 -7.7078323 5 -4.0435517 6 -2.9966587 7 -0.5024386 8 -5.7958818 9 -5.7732212 10 -5.0989398 11 -4.6250558 12 -1.8067193 13 4.6946686 14 1.2258920 15 1.9379472 16 0.2273355 17 -1.3224383 18 0.5701124 19 1.3836169 20 4.7114457 21 4.3765036 22 3.9436109 23 1.6007241 24 3.6127244 25 1.8232751 26 2.9913855 27 2.9822724 28 0.8351599 29 -3.8750165 30 -3.1916228 31 -1.4071215 32 -0.8212866 33 -1.7743992 34 3.8176003 35 5.7796006 36 4.3767082 37 7.8929342 38 8.3628733 39 3.9179806 40 7.3909833 41 12.6642065 42 16.8189833 43 16.9352643 44 11.7899861 45 15.0322672 46 15.9508733 47 16.2548736 48 11.4632098 49 7.9348126 50 -5.3425810 51 -16.5548673 52 -8.9903549 53 -3.3981347 54 -2.6881897 55 -15.3595839 56 -16.0900793 57 -5.1371267 58 -13.2451762 59 -25.6568957 60 -32.5334462 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1iimy1257943296.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/28f2b1257943296.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/31m451257943296.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/4382b1257943296.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/59i951257943296.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/6e3141257943296.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/7wbrm1257943297.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/8ak6o1257943297.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. 98.49 120.80 189.70 181.50 227.70 338.00 > > #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/91a091257943297.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/102u0u1257943297.tab") > > system("convert tmp/1iimy1257943296.ps tmp/1iimy1257943296.png") > system("convert tmp/28f2b1257943296.ps tmp/28f2b1257943296.png") > system("convert tmp/31m451257943296.ps tmp/31m451257943296.png") > system("convert tmp/4382b1257943296.ps tmp/4382b1257943296.png") > system("convert tmp/59i951257943296.ps tmp/59i951257943296.png") > system("convert tmp/6e3141257943296.ps tmp/6e3141257943296.png") > system("convert tmp/7wbrm1257943297.ps tmp/7wbrm1257943297.png") > system("convert tmp/8ak6o1257943297.ps tmp/8ak6o1257943297.png") > > > proc.time() user system elapsed 2.09 1.88 3.95