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(1111.92,1131.13,1144.94,1113.89,1107.30,1120.68,1140.84,1101.72,1104.24,1114.58,1130.20,1173.78,1211.92,1181.27,1203.60,1180.59,1156.85,1191.50,1191.33,1234.18,1220.33,1228.81,1207.01,1249.48,1248.29,1280.08,1280.66,1302.88,1310.61,1270.05,1270.06,1278.53,1303.80,1335.83,1377.76,1400.63,1418.03,1437.90,1406.80,1420.83,1482.37,1530.63,1504.66,1455.18,1473.96,1527.29,1545.79,1479.63,1467.97,1378.60,1330.45,1326.41,1385.97,1399.62,1276.69,1269.42,1287.83,1164.17,968.67,888.61) > x <- c(5.9650,6.2050,6.7300,7.9400,6.1000,6.1700,5.8750,6.6400,6.7300,6.8400,7.2400,7.7150,6.3900,6.7000,7.2600,7.1050,6.8500,7.3800,7.0200,7.2500,6.8550,7.3700,7.5350,8.3150,9.0400,9.7700,9.8000,11.5850,13.9200,12.0500,11.2800,11.3550,12.7500,11.5800,12.3600,13.8500,13.0100,13.5800,14.2900,13.3350,13.4500,13.5300,12.4700,12.7700,12.1000,13.7750,14.3600,13.8600,14.9300,17.1900,20.1600,16.7400,16.6400,16.8600,17.5600,17.5900,13.5800,12.2800,10.0500,9.9100) > 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 -36.811963 2 -23.786162 3 -23.504097 4 -85.732766 5 -44.910575 6 -33.334300 7 -5.572889 8 -64.405022 9 -64.204097 10 -56.698521 11 -51.385519 12 -20.045079 13 52.236851 14 13.598928 15 21.499131 16 2.483093 17 -14.686196 18 6.307031 19 15.413330 20 52.336806 21 48.664966 22 43.874706 23 17.823070 24 40.194424 25 20.322990 26 33.302719 27 33.109694 28 9.334716 29 -43.102385 30 -35.477170 31 -15.626198 32 -9.088761 33 -19.764416 34 42.413553 35 64.244907 36 48.721340 37 87.766035 38 92.948563 39 43.553642 40 82.191600 41 140.768338 42 186.966938 43 188.310483 44 131.100234 45 167.144456 46 177.313902 47 180.739917 48 127.463665 49 88.232445 50 -59.372093 51 -184.051553 52 -99.966720 53 -37.829971 54 -29.848820 55 -170.816066 56 -178.859091 57 -57.121437 58 -147.283693 59 -285.322180 60 -361.774731 > library(lattice) > postscript(file="/var/www/rcomp/tmp/1z6kr1257941174.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/2zoxg1257941174.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/3vrzo1257941174.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/4yi9b1257941174.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/5n5ef1257941174.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/6plrq1257941174.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/7nwxu1257941174.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/8u7xr1257941174.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. 5.875 7.206 11.320 10.830 13.580 20.160 > > #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/91p1b1257941174.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/10lrgv1257941174.tab") > > system("convert tmp/1z6kr1257941174.ps tmp/1z6kr1257941174.png") > system("convert tmp/2zoxg1257941174.ps tmp/2zoxg1257941174.png") > system("convert tmp/3vrzo1257941174.ps tmp/3vrzo1257941174.png") > system("convert tmp/4yi9b1257941174.ps tmp/4yi9b1257941174.png") > system("convert tmp/5n5ef1257941174.ps tmp/5n5ef1257941174.png") > system("convert tmp/6plrq1257941174.ps tmp/6plrq1257941174.png") > system("convert tmp/7nwxu1257941174.ps tmp/7nwxu1257941174.png") > system("convert tmp/8u7xr1257941174.ps tmp/8u7xr1257941174.png") > > > proc.time() user system elapsed 2.020 1.750 3.447