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(2.406945108,2.388762789,2.302585093,2.219203484,2.219203484,2.251291799,2.261763098,2.251291799,2.208274414,2.186051277,2.197224577,2.312535424,2.332143895,2.32238772,2.261763098,2.219203484,2.2300144,2.240709689,2.240709689,2.219203484,2.197224577,2.197224577,2.197224577,2.282382386,2.302585093,2.282382386,2.2300144,2.197224577,2.197224577,2.208274414,2.208274414,2.208274414,2.219203484,2.174751721,2.116255515,2.128231706,2.091864062,2.041220329,2.066862759,2.066862759,2.079441542,2.066862759,2.028148247,1.960094784,1.916922612,1.871802177,1.931521412,2.104134154,2.163323026,2.116255515,2.066862759,2.014903021,2.054123734,2.116255515,2.128231706,2.104134154,2.041220329,1.974081026,1.987874348,2.091864062) > x <- c(8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8) > 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.1546514223 2 0.1255340254 3 0.0830966411 4 0.0215851879 5 0.0106501100 6 0.0208682692 7 0.0313395682 8 0.0208682692 9 0.0106561179 10 -0.0115670191 11 0.0433465926 12 0.1149171279 13 0.1345255989 14 0.1138343460 15 0.0422746461 16 -0.0002849679 17 -0.0113442078 18 -0.0225190746 19 -0.0334541525 20 -0.0549603575 21 -0.0769392645 22 -0.0441340308 23 0.0214764368 24 0.1503745575 25 0.2033824982 26 0.1722447133 27 0.0980065715 28 0.0542816705 29 0.0433465926 30 0.0434613517 31 0.0543964296 32 0.0762665855 33 0.0762605775 34 0.0536789704 35 0.0389230761 36 0.0180940333 37 -0.0073385328 38 -0.0361121099 39 0.0004653980 40 0.0114004759 41 -0.0088259749 42 -0.0542099916 43 -0.0929245036 44 -0.1172376549 45 -0.1276045932 46 -0.1399197944 47 -0.1130057932 48 -0.0606789083 49 -0.0124251142 50 -0.0157523135 51 0.0223355538 52 0.0031810496 53 -0.0013385491 54 -0.0376224694 55 -0.0912567459 56 -0.1372244538 57 -0.1782681229 58 -0.2126021922 59 -0.2097439481 60 -0.1604296237 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1p1hn1256645541.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/2e5je1256645541.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/3d56s1256645541.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/46oi71256645541.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/51mdi1256645541.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/60bcd1256645541.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/7ab611256645541.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/8kl9k1256645541.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. 5.800 6.700 7.200 7.172 7.700 8.200 > > #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/9rbbb1256645541.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/105ktd1256645541.tab") > > system("convert tmp/1p1hn1256645541.ps tmp/1p1hn1256645541.png") > system("convert tmp/2e5je1256645541.ps tmp/2e5je1256645541.png") > system("convert tmp/3d56s1256645541.ps tmp/3d56s1256645541.png") > system("convert tmp/46oi71256645541.ps tmp/46oi71256645541.png") > system("convert tmp/51mdi1256645541.ps tmp/51mdi1256645541.png") > system("convert tmp/60bcd1256645541.ps tmp/60bcd1256645541.png") > system("convert tmp/7ab611256645541.ps tmp/7ab611256645541.png") > system("convert tmp/8kl9k1256645541.ps tmp/8kl9k1256645541.png") > > > proc.time() user system elapsed 1.561 1.125 2.159