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(635.85,628.86,548.28,479.98,452.42,418.57,398.5,365.05,330.7,296.65,303.84,548.28,602.8,602.9,534.2,466.4,432.95,385.42,371.84,330.5,310.53,290.36,296.85,514.03,554.67,547.48,445.43,371.04,323.61,330,289.36,248.62,228.25,180.22,166.64,377.13,417.77,377.23,316.92,256.51,249.92,250.32,223.26,183.32,169.44,109.33,130.4,327.41,354.07,333.8,278.78,250.02,263.1,276.08,275.88,267.79,261.1,205.88,232.24,421.66,463.4) > x <- c(4,3.8,4.7,4.3,3.9,4,4.3,4.8,4.4,4.3,4.7,4.7,4.9,5,4.2,4.3,4.8,4.8,4.8,4.2,4.6,4.8,4.5,4.4,4.3,3.9,3.7,4,4.1,3.7,3.8,3.8,3.8,3.3,3.3,3.3,3.2,3.4,4.2,4.9,5.1,5.5,5.6,6.4,6.1,7.1,7.8,7.9,7.4,7.5,6.8,5.2,4.7,4.1,3.9,2.6,2.7,1.8,1,0.3,1.3) > 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 276.817047 2 266.611095 3 200.502881 4 125.770976 5 91.779071 6 59.537047 7 44.290976 8 18.880857 9 -21.901048 10 -57.559024 11 -43.937119 12 200.502881 13 258.238833 14 259.946809 15 178.383000 16 112.190976 17 86.780857 18 39.250857 19 25.670857 20 -25.317000 21 -38.855096 22 -55.809143 23 -54.143072 24 161.428952 25 200.460976 26 186.839071 27 81.573118 28 12.007047 29 -33.814977 30 -33.856882 31 -72.888905 32 -113.628905 33 -133.998905 34 -190.068787 35 -203.648787 36 6.841213 37 45.873237 38 8.549190 39 -38.897000 40 -88.051167 41 -91.425214 42 -84.593309 43 -110.045333 44 -137.121523 45 -155.825452 46 -199.855690 47 -167.529856 48 31.088120 49 49.708239 50 31.046215 51 -35.229618 52 -89.717238 53 -84.677119 54 -81.344977 55 -84.760929 56 -113.754620 57 -118.836644 58 -188.528430 59 -175.032240 60 3.131926 61 60.951689 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1sk7t1257076104.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/2wki11257076104.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/3p3761257076104.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/4noph1257076104.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/54mt61257076104.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/64e7p1257076104.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/7fa6b1257076104.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/8og801257076104.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.300 3.800 4.300 4.405 4.800 7.900 > > #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/97hso1257076104.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/10wipu1257076104.tab") > > system("convert tmp/1sk7t1257076104.ps tmp/1sk7t1257076104.png") > system("convert tmp/2wki11257076104.ps tmp/2wki11257076104.png") > system("convert tmp/3p3761257076104.ps tmp/3p3761257076104.png") > system("convert tmp/4noph1257076104.ps tmp/4noph1257076104.png") > system("convert tmp/54mt61257076104.ps tmp/54mt61257076104.png") > system("convert tmp/64e7p1257076104.ps tmp/64e7p1257076104.png") > system("convert tmp/7fa6b1257076104.ps tmp/7fa6b1257076104.png") > system("convert tmp/8og801257076104.ps tmp/8og801257076104.png") > > > proc.time() user system elapsed 1.790 1.520 3.176