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(23.2,23.2,20.9,20.9,20.9,19.8,19.8,19.8,20.6,20.6,20.6,21.1,21.1,21.1,22.4,22.4,22.4,20.5,20.5,20.5,18.4,18.4,18.4,17.6,17.6,17.6,18.5,18.5,18.5,17.3,17.3,17.3,16.2,16.2,16.2,18.5,18.5,18.5,16.3,16.3,16.3,16.8,16.8,16.8,14.8,14.8,14.8,21.4,21.4,21.4,16.1,16.1,16.1,19.6,19.6,19.6,18.9,18.9,18.9) > x <- c(27.1,27.1,24.1,24.1,24.1,21.3,21.3,21.3,19.1,19.1,19.1,26.2,26.2,26.2,21.7,21.7,21.7,19.4,19.4,19.4,19.5,19.5,19.5,28.7,28.7,28.7,21.8,21.8,21.8,20,20,20,22.6,22.6,22.6,22.4,22.4,22.4,18.6,18.6,18.6,16.2,16.2,16.2,13.8,13.8,13.8,24.1,24.1,24.1,19.9,19.9,19.9,22.3,22.3,22.3,20.9,20.9,20.9) > 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 2.3826789 2 2.3826789 3 1.1042456 4 1.1042456 5 1.1042456 6 0.9577079 7 0.9577079 8 0.9577079 9 2.5068569 10 2.5068569 11 2.5068569 12 0.5891489 13 0.5891489 14 0.5891489 15 3.4214990 16 3.4214990 17 3.4214990 18 2.3047002 19 2.3047002 20 2.3047002 21 0.1706480 22 0.1706480 23 0.1706480 24 -3.7621567 25 -3.7621567 26 -3.7621567 27 -0.5125532 28 -0.5125532 29 -0.5125532 30 -1.0996132 31 -1.0996132 32 -1.0996132 33 -3.0849710 34 -3.0849710 35 -3.0849710 36 -0.7168665 37 -0.7168665 38 -0.7168665 39 -1.6228820 40 -1.6228820 41 -1.6228820 42 -0.3056286 43 -0.3056286 44 -0.3056286 45 -1.4883752 46 -1.4883752 47 -1.4883752 48 1.6042456 49 1.6042456 50 1.6042456 51 -2.2655609 52 -2.2655609 53 -2.2655609 54 0.4171857 55 0.4171857 56 0.4171857 57 0.1939168 58 0.1939168 59 0.1939168 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1jk8x1256894875.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/2k4x01256894875.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/3wf5h1256894875.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/4uvzf1256894875.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/5k30q1256894875.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/6yq5f1256894875.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/7nm7y1256894875.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/8lsrb1256894875.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. 13.80 19.45 21.30 21.39 22.60 28.70 > > #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/9skls1256894875.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/101sl11256894875.tab") > > system("convert tmp/1jk8x1256894875.ps tmp/1jk8x1256894875.png") > system("convert tmp/2k4x01256894875.ps tmp/2k4x01256894875.png") > system("convert tmp/3wf5h1256894875.ps tmp/3wf5h1256894875.png") > system("convert tmp/4uvzf1256894875.ps tmp/4uvzf1256894875.png") > system("convert tmp/5k30q1256894875.ps tmp/5k30q1256894875.png") > system("convert tmp/6yq5f1256894875.ps tmp/6yq5f1256894875.png") > system("convert tmp/7nm7y1256894875.ps tmp/7nm7y1256894875.png") > system("convert tmp/8lsrb1256894875.ps tmp/8lsrb1256894875.png") > > > proc.time() user system elapsed 1.770 1.600 3.317