R version 2.8.1 (2008-12-22) 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(8.1,8,7.5,7.4,7.7,7.9,7.7,7.1,6.2,5.8,6.1,6.9,7.3,7.2,6.1,5.8,6.1,6.4,6.8,6.8,6.5,6.2,6.3,6.4,6.6,6.7,6.4,6.8,7,6.9,7.1,7.2,7.1,7,6.9,6.7,6.6,6.9,7.3,7.9,8.2,8.2,8.2,8.1,7.9,7.7,7.7,7.6,7.5,7.5,7.1,7.5,7.5,7.8,7.8,7.8,7.6,7.5,7.7,8.1,8,7.6,6.6,6.5,6.8,7.5,8,8.2,8.1,7.9,7.9,7.6,7.5,7.6,7.3,7.5,7.6,7.5,7.6,7.8,7.9,7.8,7.5,6.6,6.3,6.3,6,6.3,6.4,6.3,6.3,6.4,6.7,6.7,6.8,6.2,5.8,5.6,5.4,5.7,5.8,5.5,5.4,5.4,5.4,5.5,5.6,5.7,5.8,5.4,4.9,5.2,5.5,5.9,6.3,6.5,6.4,6.4,6.6,6.8,7.2) > x <- c(8.3,8.1,7.4,7.3,7.7,8,8,7.7,6.9,6.6,6.9,7.5,7.9,7.7,6.5,6.1,6.4,6.8,7.1,7.3,7.2,7,7,7,7.3,7.5,7.2,7.7,8,7.9,8,8,7.9,7.9,8,8.1,8.1,8.2,8,8.3,8.5,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,7.9,8.1,8.2,8.5,8.6,8.5,8.3,8.2,8.7,9.3,9.3,8.8,7.4,7.2,7.5,8.3,8.8,8.9,8.6,8.4,8.4,8.4,8.4,8.3,7.6,7.6,7.9,8,8.2,8.3,8.2,8.1,8,7.8,7.6,7.5,6.8,6.9,7.1,7.3,7.4,7.6,7.6,7.5,7.5,6.8,6.4,6.2,6,6.3,6.3,6.1,6.1,6.3,6.6,6.8,7,7.1,7.3,6.8,6.3,6.4,6.7,6.8,7.2,7.5,7.7,7.8,8.1,8.4,8.7) > 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.5945912875 2 0.6887358878 3 0.8682419888 4 0.8653142890 5 0.7770250884 6 0.6858081879 7 0.4858081879 8 0.1770250884 9 0.0536034896 10 -0.0551796100 11 -0.0463965104 12 0.1711696887 13 0.1828804881 14 0.2770250884 15 0.3418926902 16 0.4301818908 17 0.4389649903 18 0.3506757897 19 0.4594588893 20 0.2653142890 21 0.0623865891 22 -0.0434688106 23 0.0565311894 24 0.1565311894 25 0.0653142890 26 -0.0288303113 27 -0.0376134109 28 -0.1229749116 29 -0.2141918121 30 -0.2171195119 31 -0.1141918121 32 -0.0141918121 33 -0.0171195119 34 -0.1171195119 35 -0.3141918121 36 -0.6112641122 37 -0.7112641122 38 -0.5083364124 39 0.0858081879 40 0.3945912875 41 0.5004466872 42 0.4033743870 43 0.3063020869 44 0.2063020869 45 0.2004466872 46 0.0975189873 47 0.0004466872 48 -0.2936979131 49 -0.3936979131 50 -0.2966256130 51 -0.0171195119 52 0.1887358878 53 0.0916635876 54 0.1004466872 55 0.0033743870 56 0.1004466872 57 0.0945912875 58 0.0916635876 59 -0.1936979131 60 -0.3761317140 61 -0.4761317140 62 -0.3907702133 63 -0.0317580112 64 0.0623865891 65 0.0711696887 66 -0.0054087125 67 0.0092297867 68 0.1121574866 69 0.3033743870 70 0.2975189873 71 0.2975189873 72 -0.0024810127 73 -0.1024810127 74 0.0945912875 75 0.4740973885 76 0.6740973885 77 0.4828804881 78 0.2858081879 79 0.1916635876 80 0.2945912875 81 0.4916635876 82 0.4887358878 83 0.2858081879 84 -0.4200472118 85 -0.5259026115 86 -0.4288303113 87 -0.0493242103 88 0.1536034896 89 0.0594588893 90 -0.2346857110 91 -0.3317580112 92 -0.4259026115 93 -0.1259026115 94 -0.0288303113 95 0.0711696887 96 0.1506757897 97 0.1389649903 98 0.1331095906 99 0.1272541909 100 0.1360372905 101 0.2360372905 102 0.1301818908 103 0.0301818908 104 -0.1639627095 105 -0.4551796100 106 -0.5493242103 107 -0.6434688106 108 -0.6405411107 109 -0.7346857110 110 -0.6493242103 111 -0.6639627095 112 -0.4610350097 113 -0.4522519101 114 -0.1493242103 115 -0.1376134109 116 -0.2288303113 117 -0.5229749116 118 -0.6200472118 119 -0.7112641122 120 -0.8024810127 121 -0.6936979131 > library(lattice) > postscript(file="/var/www/rcomp/tmp/15c5z1257354462.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/rcomp/tmp/2ikym1257354462.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/rcomp/tmp/30v1u1257354462.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/rcomp/tmp/40v0b1257354462.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/rcomp/tmp/5283y1257354462.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/rcomp/tmp/6r6a81257354462.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/rcomp/tmp/7qch81257354462.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/rcomp/tmp/8u3cn1257354462.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.000 7.100 7.700 7.666 8.300 9.300 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/9olgr1257354463.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/rcomp/tmp/10yo3y1257354463.tab") > > system("convert tmp/15c5z1257354462.ps tmp/15c5z1257354462.png") > system("convert tmp/2ikym1257354462.ps tmp/2ikym1257354462.png") > system("convert tmp/30v1u1257354462.ps tmp/30v1u1257354462.png") > system("convert tmp/40v0b1257354462.ps tmp/40v0b1257354462.png") > system("convert tmp/5283y1257354462.ps tmp/5283y1257354462.png") > system("convert tmp/6r6a81257354462.ps tmp/6r6a81257354462.png") > system("convert tmp/7qch81257354462.ps tmp/7qch81257354462.png") > system("convert tmp/8u3cn1257354462.ps tmp/8u3cn1257354462.png") > > > proc.time() user system elapsed 2.020 1.670 3.631