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(-9.314,-5.0234,9.814,8.1308,-10.2608,-15.3104,4.6961,-2.2175,6.0038,-1.2903,2.5262,1.1646,-7.4196,5.355,14.0077,4.5124,-3.8231,-16.2402,8.6444,0.0841,-3.0662,10.6491,-2.219,-1.2421,-5.2066,5.9774,9.549,8.2253,-6.2735,-21.3735,8.4939,3.0555,-4.8665,10.9275,-3.7873,-5.1465,-1.1365,5.8179,3.1025,10.4451,-6.8916,-21.2798,11.7841,-4.1934,-0.0117,1.7321,-6.8123,-7.9135,-0.168,2.0539,8.7166,12.7296,-4.5136,-13.8994,10.342,-3.6225,1.558,11.2231,-4.3136,-5.8018) > x <- c(-11.152,-1.5796,13.16,11.1072,-5.6192,-3.8776,13.7234,7.109,10.9492,7.6378,2.6788,2.4724,-10.7344,0.574,15.1298,4.6936,-11.3734,-18.5268,1.4216,-4.6246,-4.2308,8.5854,-2.922,0.5006,-9.2324,0.2036,5.65,4.1602,-15.015,-20.315,2.9446,-6.449,-7.137,3.139,-9.8002,-4.357,-6.117,0.6406,0.589,2.3694,-15.0224,-19.9452,6.3754,-5.8596,-3.3378,-1.0326,-4.4502,-4.275,-3.768,11.3846,18.4804,18.5824,-4.7104,-2.5836,5.172,4.139,9.136,15.4814,1.9896,2.7668) > 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 -1.222997e+00 2 -3.882909e+00 3 2.520793e-01 4 5.941566e-02 5 -6.187159e+00 6 -1.250133e+01 7 -5.274905e+00 8 -7.385795e+00 9 -1.952861e+00 10 -6.842556e+00 11 5.746700e-01 12 -6.370631e-01 13 3.681835e-01 14 4.931764e+00 15 3.015509e+00 16 1.097925e+00 17 4.428661e+00 18 -2.794361e+00 19 7.605722e+00 20 3.435563e+00 21 -6.751245e-04 22 4.408793e+00 23 -1.037937e-01 24 -1.612041e+00 25 1.490583e+00 26 5.823111e+00 27 5.440084e+00 28 5.198127e+00 29 4.622424e+00 30 -6.629251e+00 31 6.349373e+00 32 7.731658e+00 33 3.092143e-01 34 8.641819e+00 35 3.322162e+00 36 -1.989341e+00 37 3.298593e+00 38 5.346305e+00 39 2.668372e+00 40 8.718225e+00 41 4.009697e+00 42 -6.804062e+00 43 7.148472e+00 44 5.479522e-02 45 2.405418e+00 46 2.475414e+00 47 -3.587469e+00 48 -4.815882e+00 49 2.561486e+00 50 -6.218904e+00 51 -4.708459e+00 52 -7.695209e-01 53 -1.099838e+00 54 -1.202991e+01 55 6.580160e+00 56 -6.634280e+00 57 -5.082098e+00 58 -2.438736e-02 59 -5.764702e+00 60 -7.817227e+00 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1anhs1257168974.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/2w6u41257168974.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/3ifn81257168974.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/4kc9c1257168974.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/524rg1257168974.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/6zy6a1257168974.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/7f3vh1257168974.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/8rqgp1257168974.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. -20.32000 -4.93800 0.53730 -0.08502 5.29100 18.58000 > > #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/9nzav1257168974.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/10oh601257168974.tab") > system("convert tmp/1anhs1257168974.ps tmp/1anhs1257168974.png") > system("convert tmp/2w6u41257168974.ps tmp/2w6u41257168974.png") > system("convert tmp/3ifn81257168974.ps tmp/3ifn81257168974.png") > system("convert tmp/4kc9c1257168974.ps tmp/4kc9c1257168974.png") > system("convert tmp/524rg1257168974.ps tmp/524rg1257168974.png") > system("convert tmp/6zy6a1257168974.ps tmp/6zy6a1257168974.png") > system("convert tmp/7f3vh1257168974.ps tmp/7f3vh1257168974.png") > system("convert tmp/8rqgp1257168974.ps tmp/8rqgp1257168974.png") > > > proc.time() user system elapsed 2.020 1.820 3.775