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(100,95.70,96.10,102.64,93.99,95.42,94.85,94.05,97.93,100.44,103.09,108.79,102.76,101.12,104.13,102.62,102.80,99.78,103.93,103.70,105.61,111.98,110.39,120.06,127.33,136.52,135.56,141.02,158.80,150.15,149.66,153.09,149.20,144.29,147.53,155.86,153.69,158.61,161.06,158.14,161.83,160.12,157.30,159.94,161.44,178.38,189.85,188.41,203.42,219.76,237.48,213.27,204.92,213.39,225.23,219.22,197.54,211.41,175.26,186.91) > x <- c(100,101.73,102.97,100.18,99.58,100.79,102.60,99.08,99.31,100.24,101.64,105.56,108.99,106.24,108.25,106.18,104.04,107.16,107.14,111.00,109.75,110.51,108.55,112.37,112.26,115.12,115.18,117.17,117.87,114.22,114.22,114.98,117.26,120.14,123.91,125.96,127.53,129.32,126.52,127.78,133.32,137.66,135.32,130.87,132.56,137.36,139.02,133.07,132.02,123.98,119.65,119.29,124.65,125.87,114.82,114.16,115.82,104.70,87.12,79.92) > 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 -20.2820723 2 -27.5110632 3 -29.2104556 4 -17.9468228 5 -25.5809878 6 -26.1995884 7 -29.8340240 8 -24.6744586 9 -21.1838620 10 -20.2484063 11 -19.9686880 12 -20.9054767 13 -32.7426668 14 -29.7267564 15 -30.1198037 16 -28.1251729 17 -24.3220280 18 -32.6243701 19 -28.4405089 20 -35.2057141 21 -31.1793912 22 -26.0961155 23 -24.3677212 24 -21.1652040 25 -13.7089676 26 -9.3611145 27 -10.4226980 28 -8.3318841 29 8.2629751 30 5.7926380 31 5.3026380 32 7.4459137 33 -0.3042593 34 -10.0902674 35 -13.2330973 36 -8.3738669 37 -13.2019686 38 -11.3125430 39 -4.1219796 40 -9.1752331 41 -14.8647764 42 -23.9226496 43 -22.7808931 44 -12.6067834 45 -13.9680520 46 -5.1547321 47 3.5047911 48 12.1384882 49 28.9261995 50 58.8783886 51 83.9293312 52 60.3288322 53 42.9040395 54 49.3085083 55 79.8568030 56 74.9642215 57 50.4737447 58 83.1705535 59 76.7845192 60 100.6245393 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1kwbc1257943124.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/2ggqy1257943124.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/3rv8w1257943124.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/4w6la1257943124.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/5c7d91257943124.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/6lfhr1257943124.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/7kh9e1257943124.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/8okcv1257943124.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. 79.92 105.30 114.20 114.60 125.00 139.00 > > #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/9lg071257943124.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/108p781257943124.tab") > > system("convert tmp/1kwbc1257943124.ps tmp/1kwbc1257943124.png") > system("convert tmp/2ggqy1257943124.ps tmp/2ggqy1257943124.png") > system("convert tmp/3rv8w1257943124.ps tmp/3rv8w1257943124.png") > system("convert tmp/4w6la1257943124.ps tmp/4w6la1257943124.png") > system("convert tmp/5c7d91257943124.ps tmp/5c7d91257943124.png") > system("convert tmp/6lfhr1257943124.ps tmp/6lfhr1257943124.png") > system("convert tmp/7kh9e1257943124.ps tmp/7kh9e1257943124.png") > system("convert tmp/8okcv1257943124.ps tmp/8okcv1257943124.png") > > > proc.time() user system elapsed 1.610 1.185 2.313