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(403.6,341,391.2,396.6,434.1,418.3,377.2,424.8,509.1,453.7,435.6,406.8,428.3,418.4,576.7,486.8,423,491.3,488.8,522.6,418.5,471.3,424.6,495.8,489.5,460.7,514.3,503.2,561.6,623.6,503.1,674.6,491,526.3,501.6,529.1,541.9,671.2,673.4,610.3,625,562.8,568.5,691.4,538.4,532.1,595,641.1,641.9,658.8,758.5,788.8,946.1,650.6,656.7,776.1,612,544.1,455.7,423.9,492.5) > x <- c(200.1,172,136.1,182.6,208.7,142.3,188.8,143.9,149.7,196.9,231.5,219.2,220.7,244.2,182.5,229.8,238.1,206.5,249.3,181.8,218,246.4,214.3,242.3,220.7,204.5,180.7,233,236.5,239.4,208.7,209,247.2,284.3,245.8,249.1,251.4,251.2,207.2,228.3,254.3,217.9,244.4,233.2,212.6,239.5,335.5,248.8,264.6,275.4,180.7,256.1,247.4,227.8,248.1,153.7,225.5,274.4,400.3,301.8,345.2) > 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 -121.541595 2 -173.711068 3 -110.185235 4 -122.045715 5 -94.233856 6 -85.386632 7 -143.747112 8 -79.480541 9 2.666539 10 -70.253777 11 -101.197059 12 -125.431384 13 -104.488173 14 -123.111212 15 58.091404 16 -49.366031 17 -116.246934 18 -36.217231 19 -54.604297 20 4.251239 21 -113.285952 22 -71.027837 23 -105.812537 24 -45.005945 25 -43.288173 26 -66.074845 27 -3.640448 28 -34.153849 29 22.946975 30 83.870515 31 -25.233856 32 146.154786 33 -51.624791 34 -30.096056 35 -40.505121 36 -14.230058 37 -2.283802 38 127.090436 39 145.622934 40 74.690759 41 79.739738 42 31.051167 43 26.914550 44 153.971913 45 8.618491 46 -7.666604 47 19.598855 48 97.881300 49 92.816448 50 105.707563 51 240.559552 52 242.871590 53 403.400970 54 115.176356 55 113.741135 56 268.181766 57 77.430100 58 -8.621244 59 -143.754459 60 -138.991936 61 -86.501718 > library(lattice) > postscript(file="/var/www/rcomp/tmp/16v7c1256672107.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/2nrzg1256672107.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/3dvpr1256672107.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/421bd1256672107.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/5j1z81256672107.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/64d121256672107.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/7ss281256672107.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/835l41256672107.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. 136.1 206.5 229.8 228.4 248.1 400.3 > > #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/97lky1256672107.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/10rdfi1256672107.tab") > > system("convert tmp/16v7c1256672107.ps tmp/16v7c1256672107.png") > system("convert tmp/2nrzg1256672107.ps tmp/2nrzg1256672107.png") > system("convert tmp/3dvpr1256672107.ps tmp/3dvpr1256672107.png") > system("convert tmp/421bd1256672107.ps tmp/421bd1256672107.png") > system("convert tmp/5j1z81256672107.ps tmp/5j1z81256672107.png") > system("convert tmp/64d121256672107.ps tmp/64d121256672107.png") > system("convert tmp/7ss281256672107.ps tmp/7ss281256672107.png") > system("convert tmp/835l41256672107.ps tmp/835l41256672107.png") > > > proc.time() user system elapsed 1.760 1.520 3.293