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(195.00,231.00,238.00,290.00,265.00,252.00,213.00,218.00,213.00,222.00,209.00,211.00,180.00,190.00,183.50,202.00,194.00,186.00,185.50,192.50,184.50,194.00,219.00,263.00,265.00,292.00,288.00,339.00,376.00,338.00,326.00,316.00,343.00,313.00,324.00,326.00,334.00,342.00,353.00,350.50,368.00,371.00,366.00,363.00,330.00,352.00,370.00,347.00,371.00,410.50,579.00,426.00,406.00,435.00,465.00,367.00,300.00,201.00,199.50,174.00) > x <- c(5.9650,6.2050,6.7300,7.9400,6.1000,6.1700,5.8750,6.6400,6.7300,6.8400,7.2400,7.7150,6.3900,6.7000,7.2600,7.1050,6.8500,7.3800,7.0200,7.2500,6.8550,7.3700,7.5350,8.3150,9.0400,9.7700,9.8000,11.5850,13.9200,12.0500,11.2800,11.3550,12.7500,11.5800,12.3600,13.8500,13.0100,13.5800,14.2900,13.3350,13.4500,13.5300,12.4700,12.7700,12.1000,13.7750,14.3600,13.8600,14.9300,17.1900,20.1600,16.7400,16.6400,16.8600,17.5600,17.5900,13.5800,12.2800,10.0500,9.9100) > 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 5.164460 2 36.089133 3 31.986857 4 58.398752 5 72.309589 6 57.829285 7 25.067707 8 13.890104 9 6.986857 10 13.660665 11 -7.798212 12 -15.843129 13 -18.823098 14 -15.378728 15 -33.721156 16 -11.943341 17 -14.550807 18 -33.758819 19 -26.645830 20 -24.509684 21 -24.156543 22 -25.547347 23 -4.036634 24 23.468554 25 10.136839 26 21.699388 27 17.064972 28 30.317231 29 17.938533 30 19.483786 31 23.767125 32 12.181085 33 9.680750 34 4.422967 35 -1.071844 36 -30.581163 37 -4.817520 38 -8.871421 39 -12.885928 40 4.809642 41 19.877715 42 21.185939 43 38.601964 44 29.257806 45 10.426426 46 -2.995123 47 2.633768 48 -9.792635 49 -8.420132 50 -16.712790 51 88.980044 52 8.303447 53 -9.581834 54 14.765784 55 29.962748 56 -68.671668 57 -50.871421 58 -122.380069 59 -76.721827 60 -99.261220 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1nu4c1257949623.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/2rv5z1257949623.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/3igg21257949623.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/462oz1257949623.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/5tbgi1257949623.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/6st0a1257949623.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/7ydym1257949623.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/8vbfa1257949623.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.875 7.206 11.320 10.830 13.580 20.160 > > #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/9m44y1257949623.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/10qiu61257949623.tab") > > system("convert tmp/1nu4c1257949623.ps tmp/1nu4c1257949623.png") > system("convert tmp/2rv5z1257949623.ps tmp/2rv5z1257949623.png") > system("convert tmp/3igg21257949623.ps tmp/3igg21257949623.png") > system("convert tmp/462oz1257949623.ps tmp/462oz1257949623.png") > system("convert tmp/5tbgi1257949623.ps tmp/5tbgi1257949623.png") > system("convert tmp/6st0a1257949623.ps tmp/6st0a1257949623.png") > system("convert tmp/7ydym1257949623.ps tmp/7ydym1257949623.png") > system("convert tmp/8vbfa1257949623.ps tmp/8vbfa1257949623.png") > > > proc.time() user system elapsed 2.060 1.770 3.456