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(94.1,95.8,99.3,101.1,104,99,105.4,107.1,110.7,117.1,118.7,126.5,127.5,134.6,131.8,135.9,142.7,141.7,153.4,145,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179,190.6,190,181.6,174.8,180.5,196.8,193.8,197,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244,234.7,250.2,265.7,287.6,283.3,295.4,312.3,333.8) > x <- c(80.9,113.8,71.2,55.8,61,60.8,74.3,66.5,71,61.6,66.4,74.7,72.4,76.4,86.4,73.9,133.1,83.3,85.8,76.8,92.7,68.8,69.4,97,84.6,84.2,201.8,83.1,69.4,78.8,77.1,90.7,107.5,81.4,83.3,105.7,85.8,87.2,87.5,77.5,78.5,89.7,94.3,104.4,115.9,90,91.1,119.8,101.9,99.2,115.7,94.9,99.8,109.6,109,119.6,119.2,94.6,102.5,105.4) > 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 -76.7300560 2 -112.8880361 3 -60.3682807 4 -40.8475241 5 -43.9311562 6 -48.7010165 7 -57.8354460 8 -47.1599979 9 -48.7381411 10 -31.5215753 11 -35.4449280 12 -37.1957254 13 -33.5491189 14 -31.0519129 15 -45.3588977 16 -26.8751667 17 -88.1965168 18 -31.8917324 19 -23.0684786 20 -21.1121922 21 -46.7082981 22 -8.6066044 23 -5.3970235 24 -19.9563016 25 -6.4876404 26 -13.5273610 27 -135.8495025 28 5.6384073 29 33.0029765 30 21.5864108 31 15.1425982 32 -7.3069011 33 -20.9386356 34 25.3945947 35 20.2082676 36 -2.3673784 37 39.8315214 38 43.3205435 39 39.4753340 40 62.7823188 41 59.3316203 42 23.2437973 43 10.3505843 44 0.9285297 45 -3.6045029 46 9.3985878 47 19.0328195 48 -5.0922270 49 28.5052759 50 31.9121618 51 20.3256368 52 57.0601652 53 42.1217427 54 46.3448976 55 62.5353166 56 72.2379127 57 68.3981921 58 108.8053748 59 116.6148568 60 134.7778312 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1lqoi1257966611.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/2icj31257966611.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/3dgd51257966611.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/4nfzp1257966611.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/56sxs1257966611.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/6fvki1257966611.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/7q3vj1257966611.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/84qis1257966611.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. 55.80 75.98 86.10 90.24 102.10 201.80 > > #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/9lvdx1257966611.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/107xyx1257966611.tab") > > system("convert tmp/1lqoi1257966611.ps tmp/1lqoi1257966611.png") > system("convert tmp/2icj31257966611.ps tmp/2icj31257966611.png") > system("convert tmp/3dgd51257966611.ps tmp/3dgd51257966611.png") > system("convert tmp/4nfzp1257966611.ps tmp/4nfzp1257966611.png") > system("convert tmp/56sxs1257966611.ps tmp/56sxs1257966611.png") > system("convert tmp/6fvki1257966611.ps tmp/6fvki1257966611.png") > system("convert tmp/7q3vj1257966611.ps tmp/7q3vj1257966611.png") > system("convert tmp/84qis1257966611.ps tmp/84qis1257966611.png") > > > proc.time() user system elapsed 1.627 1.179 2.249