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(1.6,1.7,1.6,1.4,2.1,1.9,1.7,1.8,2,2.5,2.1,2.1,2.3,2.4,2.4,2.3,1.7,2,2.3,2,2,1.3,1.7,1.9,1.7,1.6,1.7,1.8,1.9,1.9,1.9,2,2.1,1.9,1.9,1.3,1.3,1.4,1.2,1.3,1.8,2.2,2.6,2.8,3.1,3.9,3.7,4.6,5.1,5.2,4.9,5.1,4.8,3.9,3.5,3.3,2.8,1.6,1.5,0.7,-0.1,-0.7,-0.2,-0.6,-0.6) > x <- c(1,-0.8,-2.9,-0.7,-0.7,1.5,3,3.2,3.1,3.9,1,1.3,0.8,1.2,2.9,3.9,4.5,4.5,3.3,2,1.5,1,2.1,3,4,5.1,4.5,4.2,3.3,2.7,1.8,1.4,0.5,-0.4,0.8,0.7,1.9,2,1.1,0.9,0.4,0.7,2.1,2.8,3.9,3.5,2,2,1.5,2.5,3.1,2.7,2.8,2.5,3,3.2,2.8,2.4,2,1.8,1.1,-1.5,-3.7,-4.2,-3.5) > 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.29057927 2 0.38660901 3 0.95999533 4 0.05454299 5 0.75454299 6 -0.15090935 7 -0.83189958 8 -0.79603161 9 -0.56396559 10 -0.32049372 11 0.20942073 12 0.11322269 13 0.47355276 14 0.44528870 15 -0.09983356 16 -0.52049372 17 -1.31288981 18 -1.01288981 19 -0.32809762 20 -0.21123942 21 -0.05090935 22 -0.59057927 23 -0.54330544 24 -0.63189958 25 -1.15255973 26 -1.60528590 27 -1.31288981 28 -1.11669176 29 -0.72809762 30 -0.53570153 31 -0.24710739 32 -0.01884333 33 0.36975081 34 0.45834495 35 0.07355276 36 -0.49438122 37 -0.87917341 38 -0.81123942 39 -0.72264528 40 -0.55851325 41 0.10181682 42 0.40561878 43 0.35669456 44 0.33223245 45 0.27950628 46 1.20777035 47 1.48876058 48 2.38876058 49 3.04909065 50 2.82843050 51 2.33603441 52 2.66429847 53 2.33223245 54 1.52843050 55 0.96810042 56 0.70396839 57 0.33223245 58 -0.73950348 59 -0.71123942 60 -1.44710739 61 -2.02264528 62 -1.78892888 63 -0.58347654 64 -0.82314647 65 -1.04760857 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1clyv1258035901.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/2aqkk1258035901.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/3jwd81258035901.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/46s5s1258035901.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/5n2lw1258035901.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/65v1s1258035901.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/7e3t21258035901.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/8z31j1258035901.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. -4.200 1.000 2.000 1.754 3.000 5.100 > > #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/9dzjw1258035901.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/10wacq1258035901.tab") > > system("convert tmp/1clyv1258035901.ps tmp/1clyv1258035901.png") > system("convert tmp/2aqkk1258035901.ps tmp/2aqkk1258035901.png") > system("convert tmp/3jwd81258035901.ps tmp/3jwd81258035901.png") > system("convert tmp/46s5s1258035901.ps tmp/46s5s1258035901.png") > system("convert tmp/5n2lw1258035901.ps tmp/5n2lw1258035901.png") > system("convert tmp/65v1s1258035901.ps tmp/65v1s1258035901.png") > system("convert tmp/7e3t21258035901.ps tmp/7e3t21258035901.png") > system("convert tmp/8z31j1258035901.ps tmp/8z31j1258035901.png") > > > proc.time() user system elapsed 2.090 1.810 3.507