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(82.10,83.75,111.00,75.00,80.95,78.55,75.25,91.40,101.85,112.85,136.60,111.50,104.65,117.20,110.90,111.65,99.10,116.35,115.40,123.35,149.85,143.25,183.50,213.75,252.00,248.00,270.75,344.75,308.75,306.70,321.00,304.80,284.35,297.85,332.50,323.50,343.95,354.15,342.00,357.35,350.25,338.50,349.50,355.75,426.25,474.00,468.00,530.50,598.50,672.25,571.50,536.75,572.00,621.25,596.25,506.00,563.75,413.25,461.75) > x <- c(119.21,133.02,101.97,95.38,108.76,128.92,89.80,92.32,102.66,118.28,161.86,200.00,169.35,191.68,168.67,144.93,179.58,179.41,222.26,208.41,216.89,195.09,237.56,236.37,268.16,268.74,290.96,298.69,258.13,258.14,266.61,291.88,323.91,365.84,388.71,406.11,425.98,394.88,408.91,470.45,518.71,492.74,443.26,462.04,515.37,533.87,467.71,456.05,366.68,318.53,314.49,374.05,387.70,264.77,257.50,275.91,152.25,-43.25,-123.31) > 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 -117.637085 2 -124.577841 3 -78.012636 4 -109.913209 5 -112.286476 6 -127.227363 7 -106.192071 8 -91.609682 9 -87.591863 10 -86.308562 11 -89.668277 12 -138.493943 13 -126.277565 14 -127.618339 15 -119.604559 16 -104.086669 17 -138.191318 18 -120.835567 19 -148.441172 20 -131.875533 21 -110.650668 22 -103.689590 23 -89.858810 24 -58.868549 25 -40.394085 26 -44.754884 27 -35.827231 28 33.364185 29 22.595255 30 20.539035 31 29.570120 32 -2.349533 33 -42.724365 34 -55.307668 35 -34.884359 36 -54.708339 37 -46.618826 38 -17.072517 39 -37.950128 40 -60.882181 41 -98.003174 42 -93.598073 43 -51.818158 44 -57.250591 45 -19.925467 46 16.316278 47 51.472285 48 121.225595 49 244.819795 50 348.522360 51 250.285514 52 178.485155 53 205.243930 54 330.964725 55 310.487158 56 208.784890 57 343.459795 58 314.574051 59 412.876799 > library(lattice) > postscript(file="/var/www/html/rcomp/tmp/1zhsn1257942164.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/266p51257942164.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/3jf4q1257942164.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/46c0w1257942164.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/5z9yl1257942164.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/6bbc21257942164.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/7h6zg1257942164.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/8i28t1257942164.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. -123.3 165.3 258.1 264.8 380.9 533.9 > > #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/9512h1257942164.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/10g5fs1257942164.tab") > > system("convert tmp/1zhsn1257942164.ps tmp/1zhsn1257942164.png") > system("convert tmp/266p51257942164.ps tmp/266p51257942164.png") > system("convert tmp/3jf4q1257942164.ps tmp/3jf4q1257942164.png") > system("convert tmp/46c0w1257942164.ps tmp/46c0w1257942164.png") > system("convert tmp/5z9yl1257942164.ps tmp/5z9yl1257942164.png") > system("convert tmp/6bbc21257942164.ps tmp/6bbc21257942164.png") > system("convert tmp/7h6zg1257942164.ps tmp/7h6zg1257942164.png") > system("convert tmp/8i28t1257942164.ps tmp/8i28t1257942164.png") > > > proc.time() user system elapsed 1.582 1.170 3.068