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(60,59,50,25,17,27,60,61,60,56,44,43,48,49,47,39,29,34,48,49,48,44,39,40,41,40,38,33,32,31,37,37,36,35,30,29,31,30,29,29,28,23,24,18,10,14,13,13,12,8,4,2,1,1,9,13,10,6,3,4,6,6,5,3,1,1,1,1) > x <- c(68,61,44,22,13,15,43,55,57,47,40,41,47,46,45,39,38,29,36,35,35,38,37,39,41,43,42,41,38,32,23,14,15,20,21,23,24,22,19,19,17,11,13,12,10,8,7,8,9,8,7,5,2,3,6,6,4,2,1,1,1,4,4,3,1,1,1,1) > 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 -10.4097408 2 -4.7004835 3 2.5934271 4 -1.3203356 5 -0.6941477 6 7.3889217 7 13.5518924 8 3.0503085 9 0.1333778 10 5.7180311 11 0.4272884 12 -1.5311769 13 -2.2819689 14 -0.3235036 15 -1.3650382 16 -3.6142462 17 -12.6557809 18 0.9704071 19 8.2611497 20 10.2196151 21 9.2196151 22 2.3442191 23 -1.6973156 24 -2.6142462 25 -3.5311769 26 -6.4481076 27 -7.4896422 28 -11.5311769 29 -9.6557809 30 -4.9049889 31 9.7211990 32 18.3473870 33 16.3889217 34 10.5965950 35 4.6381297 36 1.7211990 37 2.7627337 38 3.6796644 39 5.5550604 40 5.5550604 41 6.4719910 42 7.2227830 43 6.3058523 44 1.2643177 45 -4.8187517 46 1.0981790 47 1.0566443 48 0.0981790 49 -1.8602863 50 -4.9018210 51 -7.9433557 52 -8.0264250 53 -6.1510290 54 -7.1094944 55 -1.9848903 56 2.0151097 57 0.9320403 58 -1.1510290 59 -3.1925637 60 -2.1925637 61 -0.1925637 62 -3.0679597 63 -4.0679597 64 -5.1094944 65 -5.1925637 66 -5.1925637 67 -5.1925637 68 -5.1925637 > library(lattice) > postscript(file="/var/www/html/freestat/rcomp/tmp/1kfva1256756164.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/2am1r1256756164.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/3jxox1256756164.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/4agtl1256756164.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/5rbic1256756164.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/6a2go1256756164.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/7y40f1256756164.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/8gn821256756164.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. 1.00 6.75 19.50 22.99 39.00 68.00 > > #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/9ow4i1256756164.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/10vki81256756164.tab") > > system("convert tmp/1kfva1256756164.ps tmp/1kfva1256756164.png") > system("convert tmp/2am1r1256756164.ps tmp/2am1r1256756164.png") > system("convert tmp/3jxox1256756164.ps tmp/3jxox1256756164.png") > system("convert tmp/4agtl1256756164.ps tmp/4agtl1256756164.png") > system("convert tmp/5rbic1256756164.ps tmp/5rbic1256756164.png") > system("convert tmp/6a2go1256756164.ps tmp/6a2go1256756164.png") > system("convert tmp/7y40f1256756164.ps tmp/7y40f1256756164.png") > system("convert tmp/8gn821256756164.ps tmp/8gn821256756164.png") > > > proc.time() user system elapsed 2.840 2.150 7.309