R version 2.8.0 (2008-10-20) 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(29.837,29.571,30.167,30.524,30.996,31.033,31.198,30.937,31.649,33.115,34.106,33.926,33.382,32.851,32.948,36.112,36.113,35.21,35.193,34.383,35.349,37.058,38.076,36.63,36.045,35.638,35.114,35.465,35.254,35.299,35.916,36.683,37.288,38.536,38.977,36.407,34.955,34.951,32.68,34.791,34.178,35.213,34.871,35.299,35.443,37.108,36.419,34.471,33.868,34.385,33.643,34.627,32.919,35.5,36.11,37.086,37.711,40.427,39.884,38.512,38.767) > x <- c(9.3,8.7,8.2,8.3,8.5,8.6,8.5,8.2,8.1,7.9,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8,8.2,8.1,8.1,8,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.4,6.1,6.5,7.7,7.9,7.5,6.9,6.6,6.9,7.7,8,8,7.7,7.3,7.4,8.1,8.3,8.2) > 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 -3.509688829 2 -4.431724902 3 -4.382421630 4 -3.916082284 5 -3.225403593 6 -3.079064248 7 -3.023403593 8 -3.612421630 9 -3.009760975 10 -1.762439666 11 -0.006064248 12 -0.076724902 13 -0.620724902 14 -1.370403593 15 -1.382742939 16 1.890596407 17 2.110275098 18 1.207275098 19 1.080935752 20 0.161596407 21 0.908917716 22 2.289899679 23 3.526578370 24 1.971239025 25 1.386239025 26 0.869899679 27 0.236560334 28 0.587560334 29 0.485899679 30 0.530899679 31 1.038560334 32 1.914899679 33 2.191881643 34 2.893184915 35 3.662202952 36 0.873524261 37 -0.906493776 38 -0.910493776 39 -3.181493776 40 -0.851815085 41 -1.355475739 42 -0.539154430 43 -1.209172467 44 -1.218529849 45 -1.402547885 46 0.699809497 47 1.322881643 48 -0.406439666 49 -1.446797048 50 -1.585833121 51 -2.655851158 52 -1.343833121 53 -2.177118357 54 0.731899679 55 1.341899679 56 1.989881643 57 2.177524261 58 5.002863606 59 5.225239025 60 4.071917716 61 4.217578370 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/1irhm1257272283.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/freestat/rcomp/tmp/2lpy41257272283.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/freestat/rcomp/tmp/3eh7y1257272283.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/freestat/rcomp/tmp/45iy21257272283.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/freestat/rcomp/tmp/5aknj1257272283.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/freestat/rcomp/tmp/6kwn01257272283.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/freestat/rcomp/tmp/7mjtm1257272283.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/freestat/rcomp/tmp/8l8iz1257272283.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. 6.100 7.300 8.000 7.851 8.300 9.300 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/92o6j1257272283.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/freestat/rcomp/tmp/10t1ks1257272283.tab") > > system("convert tmp/1irhm1257272283.ps tmp/1irhm1257272283.png") > system("convert tmp/2lpy41257272283.ps tmp/2lpy41257272283.png") > system("convert tmp/3eh7y1257272283.ps tmp/3eh7y1257272283.png") > system("convert tmp/45iy21257272283.ps tmp/45iy21257272283.png") > system("convert tmp/5aknj1257272283.ps tmp/5aknj1257272283.png") > system("convert tmp/6kwn01257272283.ps tmp/6kwn01257272283.png") > system("convert tmp/7mjtm1257272283.ps tmp/7mjtm1257272283.png") > system("convert tmp/8l8iz1257272283.ps tmp/8l8iz1257272283.png") > > > proc.time() user system elapsed 2.714 1.997 3.128