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.3,1.2,1.1,1.4,1.2,1.5,1.1,1.3,1.5,1.1,1.4,1.3,1.5,1.6,1.7,1.1,1.6,1.3,1.7,1.6,1.7,1.9,1.8,1.9,1.6,1.5,1.6,1.6,1.7,2,2,1.9,1.7,1.8,1.9,1.7,2,2.1,2.4,2.5,2.5,2.6,2.2,2.5,2.8,2.8,2.9,3,3.1,2.9,2.7,2.2,2.5,2.3,2.6,2.3,2.2,1.8,1.8) > x <- c(2.3,1.9,1.7,2.5,2.1,2.4,1.5,1.9,2.1,2.2,2,2,2.2,2.3,2.3,2,2.2,1.9,2.3,2.2,2.3,2.1,2.4,2.3,1.9,1.6,1.8,1.8,2,2.3,2.2,2.2,2,2,1.9,1.5,1.6,1.5,2,1.5,1.5,1.9,1.1,1.5,2.1,2.3,2.6,2.9,3.2,3.2,3.1,3,3.3,2.7,3.6,3.1,2.7,2.6,2.2) > 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.654770404 2 -0.572095962 3 -0.580758741 4 -0.646107625 5 -0.663433183 6 -0.500439015 7 -0.489421521 8 -0.472095962 9 -0.363433183 10 -0.809101794 11 -0.417764573 12 -0.517764573 13 -0.409101794 14 -0.354770404 15 -0.254770404 16 -0.717764573 17 -0.309101794 18 -0.472095962 19 -0.254770404 20 -0.309101794 21 -0.254770404 22 0.036566817 23 -0.200439015 24 -0.054770404 25 -0.172095962 26 -0.135090131 27 -0.126427352 28 -0.126427352 29 -0.117764573 30 0.045229596 31 0.090898206 32 -0.009101794 33 -0.117764573 34 -0.017764573 35 0.127904038 36 0.110578479 37 0.364909869 38 0.510578479 39 0.582235427 40 0.910578479 41 0.910578479 42 0.827904038 43 0.793252921 44 0.910578479 45 0.936566817 46 0.845229596 47 0.808223764 48 0.771217933 49 0.734212102 50 0.534212102 51 0.379880712 52 -0.074450677 53 0.088543491 54 0.162555154 55 0.051537660 56 -0.020119288 57 0.062555154 58 -0.291776236 59 -0.109101794 > library(lattice) > postscript(file="/var/www/rcomp/tmp/13nze1257256718.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/23u701257256718.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/3boxw1257256718.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/4a0yv1257256718.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/5hx1a1257256718.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/6guux1257256718.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/75x421257256718.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/87s251257256718.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.100 1.900 2.200 2.195 2.350 3.600 > > #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/9drza1257256718.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/10o6ws1257256718.tab") > > system("convert tmp/13nze1257256718.ps tmp/13nze1257256718.png") > system("convert tmp/23u701257256718.ps tmp/23u701257256718.png") > system("convert tmp/3boxw1257256718.ps tmp/3boxw1257256718.png") > system("convert tmp/4a0yv1257256718.ps tmp/4a0yv1257256718.png") > system("convert tmp/5hx1a1257256718.ps tmp/5hx1a1257256718.png") > system("convert tmp/6guux1257256718.ps tmp/6guux1257256718.png") > system("convert tmp/75x421257256718.ps tmp/75x421257256718.png") > system("convert tmp/87s251257256718.ps tmp/87s251257256718.png") > > > proc.time() user system elapsed 2.160 1.820 3.063