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(-527,-413,-357,-226,-134,-160,-151,-162,-219,-213,-144,-21,-1,15,77,203,369,493,567,522,419,177,308,474,622,770,833,941,1079,1124,953,1167,1267,1177,1114,756,848,997,664,688,419,291,236,328,275,-55,-493,-468,-546,-1287,-1451,-1567,-1540,-1613,-1743,-1583,-1371,-1397,-1284,-1048) > x <- c(-2608,-1975,-2135,-839,-355,-1942,-2443,-2067,-580,-20,-125,-288,-811,-747,2322,2269,1262,943,-314,345,1930,2799,1340,826,986,172,556,573,415,842,1244,1572,2729,2979,343,-1084,-1117,-3243,-1170,-1605,-524,-928,-620,-1764,-37,-1198,-2670,-3128,-2516,-2927,-1673,-2884,-519,394,1527,1663,4723,4126,3761,4215) > 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 -506.674843 2 -397.604013 3 -340.358093 4 -219.450042 5 -131.218949 6 -144.860983 7 -131.959698 8 -145.887609 9 -214.466875 10 -212.827593 11 -143.009959 12 -18.740678 13 5.331922 14 20.833554 15 58.935258 16 185.347969 17 359.189475 18 485.673528 19 569.461784 20 519.330152 21 403.987761 22 155.220860 23 297.582090 24 467.584606 25 614.338687 26 768.677303 27 828.687096 28 936.554717 29 1075.785063 30 1117.460014 31 943.329641 32 1154.775506 33 1245.765950 34 1153.819200 35 1111.345726 36 764.457772 37 856.714743 38 1022.269901 39 673.127454 40 700.514798 41 423.097054 42 298.243001 43 240.844605 44 341.752931 45 275.304786 46 -45.654510 47 -472.192049 48 -443.625604 49 -526.391247 50 -1264.190791 51 -1437.955686 52 -1544.525632 53 -1535.941881 54 -1616.051410 55 -1754.874079 56 -1595.933111 57 -1407.761324 58 -1429.112487 59 -1313.270232 60 -1080.805529 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1d1wb1257279488.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/20fpq1257279488.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/3ih4r1257279488.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/4ub0v1257279488.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/576dg1257279488.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/6qvkm1257279488.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/7pz3t1257279488.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/8uap41257279488.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. -3243.0 -1300.0 -206.5 0.0 1248.0 4723.0 > > #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/9a1ev1257279488.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/10ak221257279488.tab") > > system("convert tmp/1d1wb1257279488.ps tmp/1d1wb1257279488.png") > system("convert tmp/20fpq1257279488.ps tmp/20fpq1257279488.png") > system("convert tmp/3ih4r1257279488.ps tmp/3ih4r1257279488.png") > system("convert tmp/4ub0v1257279488.ps tmp/4ub0v1257279488.png") > system("convert tmp/576dg1257279488.ps tmp/576dg1257279488.png") > system("convert tmp/6qvkm1257279488.ps tmp/6qvkm1257279488.png") > system("convert tmp/7pz3t1257279488.ps tmp/7pz3t1257279488.png") > system("convert tmp/8uap41257279488.ps tmp/8uap41257279488.png") > > > proc.time() user system elapsed 1.970 1.710 3.435