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(2564,3869,4145,4091,4117,3281,2186,3476,4009,3924,3101,2211,2497,3520,4191,8255,3000,2955,1986,3229,3448,3371,3160,2429,2574,2725,3451,3481,3592,3472,2312,3322,4348,3603,2700,2640,2916,3180,4151,4023,3431,3874,2617,3580,5267,3832,3441,3228,3397,3971,4625,4486,4132,4685,3172,4280,4207,4158,3933,3151,3616,4222,4436,4806,4849,5023,3521,4649,5388,5148,4847,3996,4483,4684,5454,4770,5309,5074,3505,4953,5155,5308,5171,4003,4379) > x <- c(3595,3914,4159,3676,3794,3446,3504,3958,3353,3480,3098,2944,3389,3497,4404,3849,3734,3060,3507,3287,3215,3764,2734,2837,2766,3851,3289,3848,3348,3682,4058,3655,3811,3341,3032,3475,3353,3186,3902,4164,3499,4145,3796,3711,3949,3740,3243,4407,4814,3908,5250,3937,4004,5560,3922,3759,4138,4634,3996,4308,4143,4429,5219,4929,5755,5592,4163,4962,5208,4755,4491,5732,5731,5040,6102,4904,5369,5578,4619,4731,5011,5299,4146,4625,4736) > 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 -918.525217 2 138.571070 3 224.174802 4 545.527445 5 479.826385 6 -85.733201 7 -1225.806603 8 -288.622546 9 714.539669 10 530.844460 11 4.707213 12 -765.615132 13 -825.436926 14 113.633290 15 79.778533 16 4575.084366 17 -590.545957 18 -111.761937 19 -1428.137986 20 -14.169908 21 260.783281 22 -242.859786 23 346.581670 24 -464.462476 25 -264.286414 26 -956.469889 27 206.275837 28 -198.138507 29 301.425307 30 -78.135321 31 -1530.335308 32 -207.152875 33 697.615216 34 317.865200 35 -345.002363 36 -749.269902 37 -378.460331 38 15.319982 39 429.896602 40 98.289163 41 23.079035 42 -35.945412 43 -1021.727870 44 7.327978 45 1509.371603 46 236.791277 47 232.023708 48 -885.552850 49 -1032.843794 50 245.233836 51 -143.671439 52 737.697135 53 331.629584 54 -324.581004 55 -564.645951 56 670.025852 57 302.494482 58 -131.960821 59 138.846605 60 -885.617215 61 -292.391156 62 91.350342 63 -308.580483 64 286.786529 65 -312.120891 66 -11.449088 67 -402.933709 68 104.141317 69 651.967921 70 764.006736 71 668.168429 72 -1147.246955 73 -659.469828 74 78.525362 75 23.215823 76 270.214720 77 447.850373 78 50.430699 79 -773.303907 80 587.657799 81 572.062064 82 501.249307 83 1260.277461 84 -279.966673 85 9.772161 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1g0ta1257960209.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/2a85l1257960209.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/3yi5g1257960209.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/4p3wz1257960209.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/5y38j1257960209.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/6o7871257960209.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/74b411257960209.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/8b0th1257960209.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. 2734 3499 3922 4105 4634 6102 > > #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/9w4pb1257960209.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/10jxuk1257960209.tab") > > system("convert tmp/1g0ta1257960209.ps tmp/1g0ta1257960209.png") > system("convert tmp/2a85l1257960209.ps tmp/2a85l1257960209.png") > system("convert tmp/3yi5g1257960209.ps tmp/3yi5g1257960209.png") > system("convert tmp/4p3wz1257960209.ps tmp/4p3wz1257960209.png") > system("convert tmp/5y38j1257960209.ps tmp/5y38j1257960209.png") > system("convert tmp/6o7871257960209.ps tmp/6o7871257960209.png") > system("convert tmp/74b411257960209.ps tmp/74b411257960209.png") > system("convert tmp/8b0th1257960209.ps tmp/8b0th1257960209.png") > > > proc.time() user system elapsed 1.644 1.212 2.510