R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(314,318,320,323,325,327,330,331,332,334,334,334,339,345,346,352,355,358,361,363,364,365,366,370,371,371,372,373,373,374,375,375,376,376,377,377,378,379,380,384,389,390,391,392,393,394,394,395,396,397,398,399,400,400,401,401,406,407,423,427) > x <- c(1178,2141,2238,2685,4341,5376,4478,6404,4617,3024,1897,2075,1351,2211,2453,3042,4765,4992,4601,6266,4812,3159,1916,2237,1595,2453,2226,3597,4706,4974,5756,5493,5004,3225,2006,2291,1588,2105,2191,3591,4668,4885,5822,5599,5340,3082,2010,2301,1514,1979,2480,3499,4676,5585,5610,5796,6199,3030,1930,2552) > 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 -50.7470651 2 -48.9378525 3 -47.1585237 4 -45.1754313 5 -46.9427666 6 -47.2973512 7 -42.2544362 8 -45.6360110 9 -40.5706558 10 -34.9466430 11 -32.3827621 12 -32.7877051 13 -26.1406334 14 -22.0970998 15 -21.6476403 16 -16.9875923 17 -17.9073500 18 -15.4237662 19 -11.5342564 20 -13.3220664 21 -9.0142732 22 -4.2537628 23 -0.4259863 24 2.8437512 25 5.3042761 26 3.3523597 27 4.8687758 28 2.7498044 29 0.2268727 30 0.6171831 31 -0.1618363 32 0.4364784 33 2.5489343 34 6.5960898 35 10.3692672 36 9.7209033 37 12.3202009 38 12.1440461 39 12.9483994 40 13.7634541 41 16.3133212 42 16.8196547 43 15.6880163 44 17.1953326 45 18.7845474 46 24.9214092 47 27.3601674 48 27.6981537 49 30.4885480 50 30.4306911 51 30.2909357 52 28.9727505 53 27.2951215 54 25.2271820 55 26.1703080 56 25.7471653 57 29.8303560 58 38.0397072 59 56.5421642 60 59.1271385 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/144le1262011752.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/html/rcomp/tmp/2g9g51262011752.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/html/rcomp/tmp/3oob81262011752.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/html/rcomp/tmp/4h9dk1262011752.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/html/rcomp/tmp/566l41262011752.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/html/rcomp/tmp/6so051262011752.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/html/rcomp/tmp/7q2h51262011752.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/html/rcomp/tmp/8bk4o1262011752.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. 1178 2206 3120 3560 4907 6404 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/html/rcomp/tmp/91ffj1262011752.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/html/rcomp/tmp/109tp31262011752.tab") > try(system("convert tmp/144le1262011752.ps tmp/144le1262011752.png",intern=TRUE)) character(0) > try(system("convert tmp/2g9g51262011752.ps tmp/2g9g51262011752.png",intern=TRUE)) character(0) > try(system("convert tmp/3oob81262011752.ps tmp/3oob81262011752.png",intern=TRUE)) character(0) > try(system("convert tmp/4h9dk1262011752.ps tmp/4h9dk1262011752.png",intern=TRUE)) character(0) > try(system("convert tmp/566l41262011752.ps tmp/566l41262011752.png",intern=TRUE)) character(0) > try(system("convert tmp/6so051262011752.ps tmp/6so051262011752.png",intern=TRUE)) character(0) > try(system("convert tmp/7q2h51262011752.ps tmp/7q2h51262011752.png",intern=TRUE)) character(0) > try(system("convert tmp/8bk4o1262011752.ps tmp/8bk4o1262011752.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.634 1.194 3.477