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,119.21,133.02,101.97,95.38,108.76,128.92,89.80,92.32,102.66,118.28,161.86,200.00,169.35,191.68,168.67,144.93,179.58,179.41,222.26,208.41,216.89,195.09,237.56,236.37,268.16,268.74,290.96,298.69,258.13,258.14,266.61,291.88,323.91,365.84,388.71,406.11,425.98,394.88,408.91,470.45,518.71,492.74,443.26,462.04,515.37,533.87,467.71,456.05,366.68,318.53,314.49,374.05,387.70,264.77,257.50,275.91,152.25,-43.25,-123.31) > x <- c(100.00,100.24,100.77,101.98,100.14,100.21,99.91,100.68,100.77,100.88,101.28,101.75,100.43,100.74,101.30,101.14,100.89,101.42,101.06,101.29,100.89,101.41,101.57,102.35,103.08,103.81,103.84,105.62,107.96,106.09,105.32,105.39,106.79,105.62,106.40,107.89,107.05,107.62,108.33,107.37,107.49,107.57,106.51,106.81,106.14,107.81,108.40,107.90,108.97,111.23,114.20,110.78,110.68,110.90,111.60,111.63,107.62,106.32,104.09,103.95) > 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 -36.735139 2 -23.708043 3 -23.551956 4 -85.774096 5 -44.961833 6 -33.385180 7 -5.496550 8 -64.453367 9 -64.251956 10 -56.745787 11 -51.430627 12 -19.958813 13 52.187158 14 13.550907 15 21.454131 16 2.566067 17 -14.733408 18 6.262679 19 15.367035 20 52.291752 21 48.746592 22 43.830300 23 17.908365 24 40.283927 25 20.287594 26 33.271261 27 33.078398 28 9.441861 29 -43.111453 30 -35.496326 31 -15.649509 32 -8.982856 33 -19.779796 34 42.391861 35 64.227423 36 48.711894 37 87.752058 38 92.937661 39 43.546570 40 82.308186 41 140.756734 42 186.955766 43 188.293592 44 131.084962 45 167.125569 46 177.432862 47 180.733223 48 127.454273 49 88.228827 50 -59.363519 51 -184.026955 52 -99.960574 53 -37.824364 54 -29.842026 55 -170.805496 56 -178.848359 57 -57.132339 58 -147.301609 59 -285.352127 60 -361.805433 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1qkns1257942501.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/2hm5n1257942501.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/31ob11257942502.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/4qavs1257942502.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/50fff1257942502.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/6nt201257942502.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/7i2e01257942502.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/85kwt1257942502.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. 99.91 101.20 105.40 104.90 107.60 114.20 > > #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/9lk451257942502.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/10ev611257942502.tab") > > system("convert tmp/1qkns1257942501.ps tmp/1qkns1257942501.png") > system("convert tmp/2hm5n1257942501.ps tmp/2hm5n1257942501.png") > system("convert tmp/31ob11257942502.ps tmp/31ob11257942502.png") > system("convert tmp/4qavs1257942502.ps tmp/4qavs1257942502.png") > system("convert tmp/50fff1257942502.ps tmp/50fff1257942502.png") > system("convert tmp/6nt201257942502.ps tmp/6nt201257942502.png") > system("convert tmp/7i2e01257942502.ps tmp/7i2e01257942502.png") > system("convert tmp/85kwt1257942502.ps tmp/85kwt1257942502.png") > > > proc.time() user system elapsed 1.613 1.186 2.459