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(100,109,173,91,124,130,82,82,196,116,146,102,153,119,153,137,147,152,84,76,161,129,104,144,171,140,120,130,247,154,38,57,172,163,130,163,110,133,156,157,127,167,89,53,187,202,137,151,128,140,203,160,161,210,154,70,269,176,156,210) > x <- c(100,108,125,109,92,126,63,51,129,115,96,101,106,93,120,96,99,129,62,56,119,92,90,105,102,99,107,90,90,108,62,53,97,96,103,88,100,95,109,92,96,100,62,64,110,119,93,84,101,92,91,110,85,120,74,59,121,124,100,121) > 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 -44.8807780 2 -47.4965662 3 -8.1801162 4 -66.9485397 5 -9.2649898 6 -52.6320897 7 -9.1577574 8 8.2659249 9 9.0119897 10 -50.6603809 11 6.9271161 12 -44.3327515 13 -0.5926192 14 -15.7169633 15 -20.9202486 16 -2.0728839 17 3.5711955 18 -34.9880103 19 -5.7057839 20 -4.9939427 21 -11.4682750 22 -4.2649898 23 -26.3610427 24 -8.1406456 25 23.2152750 26 -3.4288045 27 -35.0445927 28 -0.3610427 29 116.6389573 30 -2.4965662 31 -51.7057839 32 -19.6380221 33 31.4751426 34 23.9271161 35 -19.2366986 36 35.5429044 37 -34.8807780 38 -4.6209103 39 -1.9485397 40 23.7350102 41 -12.0728839 42 22.1192220 43 -0.7057839 44 -39.6097310 45 27.5994867 46 29.5317250 47 2.2830367 48 29.3507985 49 -18.3327515 50 6.7350102 51 71.1869838 52 0.5994867 53 37.8988249 54 36.0797514 55 46.8705338 56 -15.3498633 57 93.6277779 58 -3.7281427 59 11.1192220 60 34.6277779 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/11kwm1258109258.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/21r331258109258.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/3j61r1258109258.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/46lto1258109258.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/5b3ic1258109258.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/6iyen1258109258.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/75qlz1258109258.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/82jgi1258109258.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. 51.00 90.00 99.00 96.65 109.00 129.00 > > #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/993st1258109258.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/10zpxr1258109258.tab") > > system("convert tmp/11kwm1258109258.ps tmp/11kwm1258109258.png") > system("convert tmp/21r331258109258.ps tmp/21r331258109258.png") > system("convert tmp/3j61r1258109258.ps tmp/3j61r1258109258.png") > system("convert tmp/46lto1258109258.ps tmp/46lto1258109258.png") > system("convert tmp/5b3ic1258109258.ps tmp/5b3ic1258109258.png") > system("convert tmp/6iyen1258109258.ps tmp/6iyen1258109258.png") > system("convert tmp/75qlz1258109258.ps tmp/75qlz1258109258.png") > system("convert tmp/82jgi1258109258.ps tmp/82jgi1258109258.png") > > > proc.time() user system elapsed 1.537 1.108 2.259