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(31.481,29.896,33.842,39.120,33.702,25.094,51.442,45.594,52.518,48.564,41.745,49.585,32.747,33.379,35.645,37.034,35.681,20.972,58.552,54.955,65.540,51.570,51.145,46.641,35.704,33.253,35.193,41.668,34.865,21.210,56.126,49.231,59.723,48.103,47.472,50.497,40.059,34.149,36.860,46.356,36.577,23.872,57.276,56.389,57.657,62.300,48.929,51.168,39.636,33.213,38.127,43.291,30.600,21.956,48.033,46.148,50.736,48.114,38.390,44.112) > x <- c(87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91,93.2,103.1,94.1,91.8,102.7) > 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 -4.2419661 2 -9.5314879 3 -12.4033844 4 -5.6278117 5 -8.5235841 6 -16.2251586 7 12.8815278 8 6.5212004 9 9.9771374 10 6.7719237 11 1.8051846 12 3.4184352 13 -0.4143287 14 -5.6149800 15 -10.2456961 16 -5.9797803 17 -8.4756646 18 -20.6230272 19 18.2574964 20 13.9905297 21 18.7428783 22 10.6055297 23 6.5548275 24 0.1985666 25 0.7692300 26 -7.6326507 27 -11.3282530 28 -5.5232197 29 -10.9074667 30 -20.2667978 31 13.0728099 32 6.4536786 33 11.6253547 34 5.0104001 35 3.1182863 36 3.0299116 37 2.3261338 38 -8.1948135 39 -8.7548275 40 -3.1603983 41 -9.3531059 42 -16.8166017 43 12.3705490 44 10.6559431 45 13.1062373 46 14.7935018 47 4.6541059 48 4.2132391 49 0.5237906 50 -7.3967821 51 -9.1824491 52 -3.5849413 53 -9.8521429 54 -16.4862427 55 10.8912809 56 8.1392651 57 8.8256943 58 9.7505769 59 0.9330024 60 2.3593335 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1mh7b1257967299.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/2qha81257967299.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/3izv31257967299.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/4hbbs1257967299.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/5z11a1257967299.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/653lc1257967299.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/73qgz1257967299.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/8zdxi1257967299.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. 80.90 98.78 104.40 104.70 113.00 122.40 > > #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/9d8lv1257967299.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/10z8vt1257967299.tab") > > system("convert tmp/1mh7b1257967299.ps tmp/1mh7b1257967299.png") > system("convert tmp/2qha81257967299.ps tmp/2qha81257967299.png") > system("convert tmp/3izv31257967299.ps tmp/3izv31257967299.png") > system("convert tmp/4hbbs1257967299.ps tmp/4hbbs1257967299.png") > system("convert tmp/5z11a1257967299.ps tmp/5z11a1257967299.png") > system("convert tmp/653lc1257967299.ps tmp/653lc1257967299.png") > system("convert tmp/73qgz1257967299.ps tmp/73qgz1257967299.png") > system("convert tmp/8zdxi1257967299.ps tmp/8zdxi1257967299.png") > > > proc.time() user system elapsed 1.673 1.237 10.205