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.627,200.102,-245.169,-73.627,-109.085,82.186,235.915,238.102,378.102,481.289,-76.169,49.831,152.831,236.831,148.831,399.644,838.457,95.999,155.27,-277.73,17.728,-75.356,-20.711,-36.795,83.205,151.476,-244.982,-67.711,-9.169,-89.169,24.56,-91.44,-169.711,295.205,54.476,-164.066,-214.608,259.392,-97.608,-139.795,62.018,79.018,-6.795,219.663,-71.879,302.392,-127.982,-237.982,161.205,-55.15,-240.421,-158.337,-466.169,-461.085,-306.272,-436.814,-403.356,-31.356) > x <- c(3.35,2.69,2.13,2.15,2.47,2.63,2.67,2.39,2.29,2.61,3.03,3.13,3.03,2.53,2.33,2.41,2.49,2.51,2.37,2.27,2.25,2.21,2.41,2.47,2.37,2.33,2.25,2.41,2.53,2.53,2.47,2.27,2.01,1.67,1.43,1.31,1.29,1.59,1.69,1.67,1.55,1.35,1.17,1.05,0.83,0.99,1.35,1.45,1.37,1.37,1.41,1.55,1.63,1.47,1.15,0.73,0.41,0.41) > 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 -360.603475 2 113.641344 3 -265.010174 4 -95.847441 5 -169.373717 6 2.863145 7 151.833611 8 187.330352 9 339.226688 10 404.345412 11 -203.077200 12 -88.973536 13 25.922800 14 169.404481 15 105.197154 16 346.493085 17 775.789016 18 30.951749 19 106.877619 20 -314.226044 21 -16.388777 22 -104.714243 23 -73.861915 24 -97.083717 25 34.812619 26 107.842154 27 -279.098777 28 -120.861915 29 -76.595519 30 -156.595519 31 -35.728717 32 -127.936044 33 -175.276570 34 330.086973 35 117.909180 36 -86.357217 37 -134.519950 38 303.791042 39 -65.105294 40 -104.913027 41 111.175576 42 151.968249 43 87.568654 44 328.302257 45 62.932197 46 418.169059 47 -55.031751 48 -176.928088 49 231.775981 50 15.420981 51 -174.608553 52 -109.179424 53 -426.528493 54 -402.410355 55 -209.529079 56 -290.106467 57 -218.580191 58 153.419809 > library(lattice) > postscript(file="/var/www/rcomp/tmp/12m2w1257280289.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/2515i1257280289.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/3erbc1257280289.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/4jgc81257280289.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/55rj31257280289.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/6bjz31257280289.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/7nwwu1257280289.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/84km91257280289.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. 0.410 1.415 2.230 1.963 2.470 3.350 > > #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/9hkso1257280289.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/10rgm81257280289.tab") > > system("convert tmp/12m2w1257280289.ps tmp/12m2w1257280289.png") > system("convert tmp/2515i1257280289.ps tmp/2515i1257280289.png") > system("convert tmp/3erbc1257280289.ps tmp/3erbc1257280289.png") > system("convert tmp/4jgc81257280289.ps tmp/4jgc81257280289.png") > system("convert tmp/55rj31257280289.ps tmp/55rj31257280289.png") > system("convert tmp/6bjz31257280289.ps tmp/6bjz31257280289.png") > system("convert tmp/7nwwu1257280289.ps tmp/7nwwu1257280289.png") > system("convert tmp/84km91257280289.ps tmp/84km91257280289.png") > > > proc.time() user system elapsed 1.960 1.670 3.495