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(14.44,22.09,18.49,15.21,16,18.49,23.04,19.36,18.49,22.09,22.09,24.01,25,17.64,18.49,23.04,23.04,23.04,17.64,21.16,23.04,20.25,19.36,18.49,15.21,13.69,16,16.81,13.69,14.44,14.44,14.44,10.89,10.89,10.89,10.24,11.56,17.64,24.01,26.01,30.25,31.36,40.96,37.21,50.41,60.84,62.41,54.76,56.25,46.24,27.04,22.09,16.81,15.21,6.76,7.29,3.24,1,0.09,1.69) > x <- c(25921,22201,19321,18225,16900,16129,14884,13689,12544,12769,22201,24649,24649,21609,18769,17424,15625,15129,13689,12996,12321,12544,20736,22500,22201,17956,15129,13456,13689,12321,11025,10404,9025,8649,15376,16900,15376,13225,11236,11025,11025,10201,9025,8649,7056,7569,13456,14400,13689,11881,11025,11449,11881,11881,11664,11449,9801,10609,17161,18769) > 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 0.68513540 2 5.74914828 3 0.14709374 4 -3.89479924 5 -4.02588336 6 -2.07185005 7 1.61267846 8 -2.89803514 9 -4.56399086 10 -0.80758035 11 5.74914828 12 9.37089464 13 10.36089464 14 0.88761485 15 -0.23663338 16 3.37837934 17 2.12779041 18 1.78299213 19 -4.61803514 20 -1.57977952 21 -0.16901105 22 -2.80399086 23 2.00074207 24 2.35700047 25 -1.13085172 26 -5.60179669 27 -5.25700787 28 -5.61000692 29 -8.56803514 30 -8.76901105 31 -9.66993560 32 -10.10162861 33 -14.61025125 34 -14.87163059 35 -10.19530389 36 -9.78588336 37 -9.52530389 38 -4.94058838 39 0.04674270 40 1.90006440 41 6.14006440 42 6.67725435 43 15.45974875 44 11.44836941 45 23.54098299 46 34.32759895 47 39.98999308 48 32.99622207 49 33.99196486 50 22.72511950 51 2.93006440 52 -1.72518868 53 -6.70488050 54 -8.30488050 55 -16.90572975 56 -16.52518868 57 -21.72080878 58 -23.39912125 59 -19.75444717 60 -17.03663338 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1ke751256670664.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/2e9pi1256670664.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/3v2un1256670664.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/49wfn1256670664.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/594fd1256670664.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/601ok1256670664.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/78fws1256670664.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/8gqkn1256670664.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. 7056 11400 13570 14620 17230 25920 > > #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/9f9q21256670664.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/107wnm1256670664.tab") > > system("convert tmp/1ke751256670664.ps tmp/1ke751256670664.png") > system("convert tmp/2e9pi1256670664.ps tmp/2e9pi1256670664.png") > system("convert tmp/3v2un1256670664.ps tmp/3v2un1256670664.png") > system("convert tmp/49wfn1256670664.ps tmp/49wfn1256670664.png") > system("convert tmp/594fd1256670664.ps tmp/594fd1256670664.png") > system("convert tmp/601ok1256670664.ps tmp/601ok1256670664.png") > system("convert tmp/78fws1256670664.ps tmp/78fws1256670664.png") > system("convert tmp/8gqkn1256670664.ps tmp/8gqkn1256670664.png") > > > proc.time() user system elapsed 1.820 1.620 3.231