R version 2.8.0 (2008-10-20) 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. > x <- array(list(1687 + ,-183.9235445 + ,1508 + ,-177.0726091 + ,1507 + ,-228.6351091 + ,1385 + ,-237.4476091 + ,1632 + ,-127.7601091 + ,1511 + ,-193.0101091 + ,1559 + ,-220.6351091 + ,1630 + ,-164.5101091 + ,1579 + ,-268.3226091 + ,1653 + ,-333.6976091 + ,2152 + ,-34.26010911 + ,2148 + ,-154.8851091 + ,1752 + ,-97.74528053 + ,1765 + ,101.1056549 + ,1717 + ,2.543154874 + ,1558 + ,-43.26934513 + ,1575 + ,-163.5818451 + ,1520 + ,-162.8318451 + ,1805 + ,46.54315487 + ,1800 + ,26.66815487 + ,1719 + ,-107.1443451 + ,2008 + ,42.48065487 + ,2242 + ,76.91815487 + ,2478 + ,196.2931549 + ,2030 + ,201.4329835 + ,1655 + ,12.28391886 + ,1693 + ,-0.278581137 + ,1623 + ,42.90891886 + ,1805 + ,87.59641886 + ,1746 + ,84.34641886 + ,1795 + ,57.72141886 + ,1926 + ,173.8464189 + ,1619 + ,-185.9660811 + ,1992 + ,47.65891886 + ,2233 + ,89.09641886 + ,2192 + ,-68.52858114 + ,2080 + ,272.6112475 + ,1768 + ,146.4621829 + ,1835 + ,162.8996829 + ,1569 + ,10.08718285 + ,1976 + ,279.7746829 + ,1853 + ,212.5246829 + ,1965 + ,248.8996829 + ,1689 + ,-41.97531715 + ,1778 + ,-5.787817149 + ,1976 + ,52.83718285 + ,2397 + ,274.2746829 + ,2654 + ,414.6496829 + ,2097 + ,310.7895114 + ,1963 + ,362.6404468 + ,1677 + ,26.07794684 + ,1941 + ,403.2654468 + ,2003 + ,327.9529468 + ,1813 + ,193.7029468 + ,2012 + ,317.0779468 + ,1912 + ,202.2029468 + ,2084 + ,321.3904468 + ,2080 + ,178.0154468 + ,2118 + ,16.45294684 + ,2150 + ,-68.17205316 + ,1608 + ,-157.0322246 + ,1503 + ,-76.18128917 + ,1548 + ,-81.74378917 + ,1382 + ,-134.5562892 + ,1731 + ,77.13121083 + ,1798 + ,199.8812108 + ,1779 + ,105.2562108 + ,1887 + ,198.3812108 + ,2004 + ,262.5687108 + ,2077 + ,196.1937108 + ,2092 + ,11.63121083 + ,2051 + ,-145.9937892 + ,1577 + ,-166.8539606 + ,1356 + ,-202.0030252 + ,1652 + ,43.43447482 + ,1382 + ,-113.3780252 + ,1519 + ,-113.6905252 + ,1421 + ,-155.9405252 + ,1442 + ,-210.5655252 + ,1543 + ,-124.4405252 + ,1656 + ,-64.25302518 + ,1561 + ,-298.6280252 + ,1905 + ,-154.1905252 + ,2199 + ,23.18447482 + ,1473 + ,-249.6756966 + ,1655 + ,118.1752388 + ,1407 + ,-180.3872612 + ,1395 + ,-79.19976119 + ,1530 + ,-81.51226119 + ,1309 + ,-246.7622612 + ,1526 + ,-105.3872612 + ,1327 + ,-319.2622612 + ,1627 + ,-72.07476119 + ,1748 + ,-90.44976119 + ,1958 + ,-80.01226119 + ,2274 + ,119.3627388 + ,1648 + ,-53.49743261 + ,1401 + ,-114.6464972 + ,1411 + ,-155.2089972 + ,1403 + ,-50.02149721 + ,1394 + ,-196.3339972 + ,1520 + ,-14.58399721 + ,1528 + ,-82.20899721 + ,1643 + ,17.91600279 + ,1515 + ,-162.8964972 + ,1685 + ,-132.2714972 + ,2000 + ,-16.83399721 + ,2215 + ,81.54100279 + ,1956 + ,275.6808314 + ,1462 + ,-32.46823322 + ,1563 + ,17.96926678 + ,1459 + ,27.15676678 + ,1446 + ,-123.1557332 + ,1622 + ,108.5942668 + ,1657 + ,67.96926678 + ,1638 + ,34.09426678 + ,1643 + ,-13.71823322 + ,1683 + ,-113.0932332 + ,2050 + ,54.34426678 + ,2262 + ,149.7192668 + ,1813 + ,153.8590954 + ,1445 + ,-28.28996923 + ,1762 + ,238.1475308 + ,1461 + ,50.33503077 + ,1556 + ,8.022530771 + ,1431 + ,-61.22746923 + ,1427 + ,-140.8524692 + ,1554 + ,-28.72746923 + ,1645 + ,9.460030771 + ,1653 + ,-121.9149692 + ,2016 + ,41.52253077 + ,2207 + ,115.8975308 + ,1665 + ,27.03735936 + ,1361 + ,-91.11170524 + ,1506 + ,3.325794759 + ,1360 + ,-29.48670524 + ,1453 + ,-73.79920524 + ,1522 + ,50.95079476 + ,1460 + ,-86.67420524 + ,1552 + ,-9.54920524 + ,1548 + ,-66.36170524 + ,1827 + ,73.26329476 + ,1737 + ,-216.2992052 + ,1941 + ,-128.9242052 + ,1474 + ,-142.7843767 + ,1458 + ,27.06655875 + ,1542 + ,60.50405875 + ,1404 + ,35.69155875 + ,1522 + ,16.37905875 + ,1385 + ,-64.87094125 + ,1641 + ,115.5040587 + ,1510 + ,-30.37094125 + ,1681 + ,87.81655875 + ,1938 + ,205.4415587 + ,1868 + ,-64.12094125 + ,1726 + ,-322.7459413 + ,1456 + ,-139.6061127 + ,1445 + ,35.24482274 + ,1456 + ,-4.317677263 + ,1365 + ,17.86982274 + ,1487 + ,2.557322737 + ,1558 + ,129.3073227 + ,1488 + ,-16.31767726 + ,1684 + ,164.8073227 + ,1594 + ,21.99482274 + ,1850 + ,138.6198227 + ,1998 + ,87.05732274 + ,2079 + ,51.43232274 + ,1494 + ,-80.42784867) + ,dim=c(2 + ,169) + ,dimnames=list(c('slachtoffers' + ,'Dummies') + ,1:169)) > y <- array(NA,dim=c(2,169),dimnames=list(c('slachtoffers','Dummies'),1:169)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '1' > #'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: Write here your technical program description (don't use hard returns!) > library(lattice) > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x slachtoffers Dummies 1 1687 -183.9235445 2 1508 -177.0726091 3 1507 -228.6351091 4 1385 -237.4476091 5 1632 -127.7601091 6 1511 -193.0101091 7 1559 -220.6351091 8 1630 -164.5101091 9 1579 -268.3226091 10 1653 -333.6976091 11 2152 -34.2601091 12 2148 -154.8851091 13 1752 -97.7452805 14 1765 101.1056549 15 1717 2.5431549 16 1558 -43.2693451 17 1575 -163.5818451 18 1520 -162.8318451 19 1805 46.5431549 20 1800 26.6681549 21 1719 -107.1443451 22 2008 42.4806549 23 2242 76.9181549 24 2478 196.2931549 25 2030 201.4329835 26 1655 12.2839189 27 1693 -0.2785811 28 1623 42.9089189 29 1805 87.5964189 30 1746 84.3464189 31 1795 57.7214189 32 1926 173.8464189 33 1619 -185.9660811 34 1992 47.6589189 35 2233 89.0964189 36 2192 -68.5285811 37 2080 272.6112475 38 1768 146.4621829 39 1835 162.8996829 40 1569 10.0871828 41 1976 279.7746829 42 1853 212.5246829 43 1965 248.8996829 44 1689 -41.9753172 45 1778 -5.7878171 46 1976 52.8371828 47 2397 274.2746829 48 2654 414.6496829 49 2097 310.7895114 50 1963 362.6404468 51 1677 26.0779468 52 1941 403.2654468 53 2003 327.9529468 54 1813 193.7029468 55 2012 317.0779468 56 1912 202.2029468 57 2084 321.3904468 58 2080 178.0154468 59 2118 16.4529468 60 2150 -68.1720532 61 1608 -157.0322246 62 1503 -76.1812892 63 1548 -81.7437892 64 1382 -134.5562892 65 1731 77.1312108 66 1798 199.8812108 67 1779 105.2562108 68 1887 198.3812108 69 2004 262.5687108 70 2077 196.1937108 71 2092 11.6312108 72 2051 -145.9937892 73 1577 -166.8539606 74 1356 -202.0030252 75 1652 43.4344748 76 1382 -113.3780252 77 1519 -113.6905252 78 1421 -155.9405252 79 1442 -210.5655252 80 1543 -124.4405252 81 1656 -64.2530252 82 1561 -298.6280252 83 1905 -154.1905252 84 2199 23.1844748 85 1473 -249.6756966 86 1655 118.1752388 87 1407 -180.3872612 88 1395 -79.1997612 89 1530 -81.5122612 90 1309 -246.7622612 91 1526 -105.3872612 92 1327 -319.2622612 93 1627 -72.0747612 94 1748 -90.4497612 95 1958 -80.0122612 96 2274 119.3627388 97 1648 -53.4974326 98 1401 -114.6464972 99 1411 -155.2089972 100 1403 -50.0214972 101 1394 -196.3339972 102 1520 -14.5839972 103 1528 -82.2089972 104 1643 17.9160028 105 1515 -162.8964972 106 1685 -132.2714972 107 2000 -16.8339972 108 2215 81.5410028 109 1956 275.6808314 110 1462 -32.4682332 111 1563 17.9692668 112 1459 27.1567668 113 1446 -123.1557332 114 1622 108.5942668 115 1657 67.9692668 116 1638 34.0942668 117 1643 -13.7182332 118 1683 -113.0932332 119 2050 54.3442668 120 2262 149.7192668 121 1813 153.8590954 122 1445 -28.2899692 123 1762 238.1475308 124 1461 50.3350308 125 1556 8.0225308 126 1431 -61.2274692 127 1427 -140.8524692 128 1554 -28.7274692 129 1645 9.4600308 130 1653 -121.9149692 131 2016 41.5225308 132 2207 115.8975308 133 1665 27.0373594 134 1361 -91.1117052 135 1506 3.3257948 136 1360 -29.4867052 137 1453 -73.7992052 138 1522 50.9507948 139 1460 -86.6742052 140 1552 -9.5492052 141 1548 -66.3617052 142 1827 73.2632948 143 1737 -216.2992052 144 1941 -128.9242052 145 1474 -142.7843767 146 1458 27.0665587 147 1542 60.5040587 148 1404 35.6915587 149 1522 16.3790587 150 1385 -64.8709413 151 1641 115.5040587 152 1510 -30.3709413 153 1681 87.8165587 154 1938 205.4415587 155 1868 -64.1209413 156 1726 -322.7459413 157 1456 -139.6061127 158 1445 35.2448227 159 1456 -4.3176773 160 1365 17.8698227 161 1487 2.5573227 162 1558 129.3073227 163 1488 -16.3176773 164 1684 164.8073227 165 1594 21.9948227 166 1850 138.6198227 167 1998 87.0573227 168 2079 51.4323227 169 1494 -80.4278487 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Dummies 1717.751 1.037 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -371.28 -145.80 -51.68 94.10 590.87 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1717.7515 16.5915 103.532 <2e-16 *** Dummies 1.0370 0.1092 9.499 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 215.7 on 167 degrees of freedom Multiple R-squared: 0.3508, Adjusted R-squared: 0.3469 F-statistic: 90.23 on 1 and 167 DF, p-value: < 2.2e-16 > postscript(file="/var/www/html/rcomp/tmp/194v61227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index') > points(x[,1]-mysum$resid) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/278up1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/3sffr1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/49cru1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5kh6s1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 169 Frequency = 1 1 2 3 4 5 6 159.978592 -26.125879 26.344814 -86.516559 46.736695 -6.598574 7 8 9 10 11 12 70.048755 82.846716 139.501044 281.295400 469.776506 590.865520 13 14 15 16 17 18 135.611097 -57.598788 -3.388750 -114.880850 26.884100 -28.893656 19 20 21 22 23 24 38.982926 54.593448 112.357996 246.195769 444.483827 556.691073 25 26 27 28 29 30 103.361032 -75.489994 -24.462589 -139.248344 -3.589611 -59.219337 31 32 33 34 35 36 17.390984 27.968503 94.096717 224.825871 422.854878 545.313164 37 38 39 40 41 42 79.548648 -101.633842 -51.679651 -159.211962 -31.879887 -85.141142 43 44 45 46 47 48 -10.862285 14.777234 66.250530 203.455973 394.823653 506.253744 49 50 51 52 53 54 56.957507 -130.812295 -67.794502 -194.940719 -54.841102 -105.622863 55 56 57 58 59 60 -34.563647 -15.437425 32.964259 177.645191 383.186694 502.943442 61 62 63 64 65 66 53.092095 -135.750921 -84.982568 -196.215616 -66.737113 -127.029768 67 68 69 70 71 72 -47.902946 -36.474257 13.962833 155.794197 362.186869 484.645156 73 74 75 76 77 78 32.277307 -152.272854 -110.793350 -218.177632 -80.853567 -135.040006 79 80 81 82 83 84 -57.393478 -45.705738 4.879381 152.927983 347.145232 457.206049 85 86 87 88 89 90 14.164058 -185.300073 -123.688560 -240.620743 -103.222664 -152.857196 91 92 93 94 95 96 -82.464113 -59.674162 -16.009421 124.045590 323.221825 432.468481 97 98 99 100 101 102 -14.274247 -197.862217 -145.798605 -262.878818 -120.151677 -182.627767 103 104 105 106 107 108 -104.500143 -93.330506 -33.826611 104.415038 299.705500 412.689900 109 110 111 112 113 114 -47.634533 -222.081682 -173.385741 -286.913247 -144.038076 -208.364534 115 116 117 118 119 120 -131.236110 -115.107485 -60.525570 82.527037 275.893116 388.988538 121 122 123 124 125 126 -64.304495 -243.414573 -202.712224 -308.949277 -170.070903 -223.258143 127 128 129 130 131 132 -144.686431 -133.960882 -82.561601 61.675242 255.189350 369.061927 133 134 135 136 137 138 -80.789420 -262.267970 -215.200353 -327.173549 -188.221160 -248.587829 139 140 141 142 143 144 -167.869690 -155.848883 -100.933902 33.273944 243.552390 356.943872 145 146 147 148 149 150 -95.683028 -287.819700 -238.494634 -350.763889 -212.736684 -265.479835 151 152 153 154 155 156 -196.530039 -176.256589 -127.817898 7.204110 216.742409 342.938440 157 158 159 160 161 162 -116.978912 -309.300620 -257.274016 -371.282617 -233.403442 -293.844126 163 164 165 166 167 168 -212.829928 -204.657887 -146.560273 -11.501257 189.969435 307.912823 169 -140.347208 > postscript(file="/var/www/html/rcomp/tmp/6kjsb1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 169 Frequency = 1 lag(myerror, k = 1) myerror 0 159.978592 NA 1 -26.125879 159.978592 2 26.344814 -26.125879 3 -86.516559 26.344814 4 46.736695 -86.516559 5 -6.598574 46.736695 6 70.048755 -6.598574 7 82.846716 70.048755 8 139.501044 82.846716 9 281.295400 139.501044 10 469.776506 281.295400 11 590.865520 469.776506 12 135.611097 590.865520 13 -57.598788 135.611097 14 -3.388750 -57.598788 15 -114.880850 -3.388750 16 26.884100 -114.880850 17 -28.893656 26.884100 18 38.982926 -28.893656 19 54.593448 38.982926 20 112.357996 54.593448 21 246.195769 112.357996 22 444.483827 246.195769 23 556.691073 444.483827 24 103.361032 556.691073 25 -75.489994 103.361032 26 -24.462589 -75.489994 27 -139.248344 -24.462589 28 -3.589611 -139.248344 29 -59.219337 -3.589611 30 17.390984 -59.219337 31 27.968503 17.390984 32 94.096717 27.968503 33 224.825871 94.096717 34 422.854878 224.825871 35 545.313164 422.854878 36 79.548648 545.313164 37 -101.633842 79.548648 38 -51.679651 -101.633842 39 -159.211962 -51.679651 40 -31.879887 -159.211962 41 -85.141142 -31.879887 42 -10.862285 -85.141142 43 14.777234 -10.862285 44 66.250530 14.777234 45 203.455973 66.250530 46 394.823653 203.455973 47 506.253744 394.823653 48 56.957507 506.253744 49 -130.812295 56.957507 50 -67.794502 -130.812295 51 -194.940719 -67.794502 52 -54.841102 -194.940719 53 -105.622863 -54.841102 54 -34.563647 -105.622863 55 -15.437425 -34.563647 56 32.964259 -15.437425 57 177.645191 32.964259 58 383.186694 177.645191 59 502.943442 383.186694 60 53.092095 502.943442 61 -135.750921 53.092095 62 -84.982568 -135.750921 63 -196.215616 -84.982568 64 -66.737113 -196.215616 65 -127.029768 -66.737113 66 -47.902946 -127.029768 67 -36.474257 -47.902946 68 13.962833 -36.474257 69 155.794197 13.962833 70 362.186869 155.794197 71 484.645156 362.186869 72 32.277307 484.645156 73 -152.272854 32.277307 74 -110.793350 -152.272854 75 -218.177632 -110.793350 76 -80.853567 -218.177632 77 -135.040006 -80.853567 78 -57.393478 -135.040006 79 -45.705738 -57.393478 80 4.879381 -45.705738 81 152.927983 4.879381 82 347.145232 152.927983 83 457.206049 347.145232 84 14.164058 457.206049 85 -185.300073 14.164058 86 -123.688560 -185.300073 87 -240.620743 -123.688560 88 -103.222664 -240.620743 89 -152.857196 -103.222664 90 -82.464113 -152.857196 91 -59.674162 -82.464113 92 -16.009421 -59.674162 93 124.045590 -16.009421 94 323.221825 124.045590 95 432.468481 323.221825 96 -14.274247 432.468481 97 -197.862217 -14.274247 98 -145.798605 -197.862217 99 -262.878818 -145.798605 100 -120.151677 -262.878818 101 -182.627767 -120.151677 102 -104.500143 -182.627767 103 -93.330506 -104.500143 104 -33.826611 -93.330506 105 104.415038 -33.826611 106 299.705500 104.415038 107 412.689900 299.705500 108 -47.634533 412.689900 109 -222.081682 -47.634533 110 -173.385741 -222.081682 111 -286.913247 -173.385741 112 -144.038076 -286.913247 113 -208.364534 -144.038076 114 -131.236110 -208.364534 115 -115.107485 -131.236110 116 -60.525570 -115.107485 117 82.527037 -60.525570 118 275.893116 82.527037 119 388.988538 275.893116 120 -64.304495 388.988538 121 -243.414573 -64.304495 122 -202.712224 -243.414573 123 -308.949277 -202.712224 124 -170.070903 -308.949277 125 -223.258143 -170.070903 126 -144.686431 -223.258143 127 -133.960882 -144.686431 128 -82.561601 -133.960882 129 61.675242 -82.561601 130 255.189350 61.675242 131 369.061927 255.189350 132 -80.789420 369.061927 133 -262.267970 -80.789420 134 -215.200353 -262.267970 135 -327.173549 -215.200353 136 -188.221160 -327.173549 137 -248.587829 -188.221160 138 -167.869690 -248.587829 139 -155.848883 -167.869690 140 -100.933902 -155.848883 141 33.273944 -100.933902 142 243.552390 33.273944 143 356.943872 243.552390 144 -95.683028 356.943872 145 -287.819700 -95.683028 146 -238.494634 -287.819700 147 -350.763889 -238.494634 148 -212.736684 -350.763889 149 -265.479835 -212.736684 150 -196.530039 -265.479835 151 -176.256589 -196.530039 152 -127.817898 -176.256589 153 7.204110 -127.817898 154 216.742409 7.204110 155 342.938440 216.742409 156 -116.978912 342.938440 157 -309.300620 -116.978912 158 -257.274016 -309.300620 159 -371.282617 -257.274016 160 -233.403442 -371.282617 161 -293.844126 -233.403442 162 -212.829928 -293.844126 163 -204.657887 -212.829928 164 -146.560273 -204.657887 165 -11.501257 -146.560273 166 189.969435 -11.501257 167 307.912823 189.969435 168 -140.347208 307.912823 169 NA -140.347208 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -26.125879 159.978592 [2,] 26.344814 -26.125879 [3,] -86.516559 26.344814 [4,] 46.736695 -86.516559 [5,] -6.598574 46.736695 [6,] 70.048755 -6.598574 [7,] 82.846716 70.048755 [8,] 139.501044 82.846716 [9,] 281.295400 139.501044 [10,] 469.776506 281.295400 [11,] 590.865520 469.776506 [12,] 135.611097 590.865520 [13,] -57.598788 135.611097 [14,] -3.388750 -57.598788 [15,] -114.880850 -3.388750 [16,] 26.884100 -114.880850 [17,] -28.893656 26.884100 [18,] 38.982926 -28.893656 [19,] 54.593448 38.982926 [20,] 112.357996 54.593448 [21,] 246.195769 112.357996 [22,] 444.483827 246.195769 [23,] 556.691073 444.483827 [24,] 103.361032 556.691073 [25,] -75.489994 103.361032 [26,] -24.462589 -75.489994 [27,] -139.248344 -24.462589 [28,] -3.589611 -139.248344 [29,] -59.219337 -3.589611 [30,] 17.390984 -59.219337 [31,] 27.968503 17.390984 [32,] 94.096717 27.968503 [33,] 224.825871 94.096717 [34,] 422.854878 224.825871 [35,] 545.313164 422.854878 [36,] 79.548648 545.313164 [37,] -101.633842 79.548648 [38,] -51.679651 -101.633842 [39,] -159.211962 -51.679651 [40,] -31.879887 -159.211962 [41,] -85.141142 -31.879887 [42,] -10.862285 -85.141142 [43,] 14.777234 -10.862285 [44,] 66.250530 14.777234 [45,] 203.455973 66.250530 [46,] 394.823653 203.455973 [47,] 506.253744 394.823653 [48,] 56.957507 506.253744 [49,] -130.812295 56.957507 [50,] -67.794502 -130.812295 [51,] -194.940719 -67.794502 [52,] -54.841102 -194.940719 [53,] -105.622863 -54.841102 [54,] -34.563647 -105.622863 [55,] -15.437425 -34.563647 [56,] 32.964259 -15.437425 [57,] 177.645191 32.964259 [58,] 383.186694 177.645191 [59,] 502.943442 383.186694 [60,] 53.092095 502.943442 [61,] -135.750921 53.092095 [62,] -84.982568 -135.750921 [63,] -196.215616 -84.982568 [64,] -66.737113 -196.215616 [65,] -127.029768 -66.737113 [66,] -47.902946 -127.029768 [67,] -36.474257 -47.902946 [68,] 13.962833 -36.474257 [69,] 155.794197 13.962833 [70,] 362.186869 155.794197 [71,] 484.645156 362.186869 [72,] 32.277307 484.645156 [73,] -152.272854 32.277307 [74,] -110.793350 -152.272854 [75,] -218.177632 -110.793350 [76,] -80.853567 -218.177632 [77,] -135.040006 -80.853567 [78,] -57.393478 -135.040006 [79,] -45.705738 -57.393478 [80,] 4.879381 -45.705738 [81,] 152.927983 4.879381 [82,] 347.145232 152.927983 [83,] 457.206049 347.145232 [84,] 14.164058 457.206049 [85,] -185.300073 14.164058 [86,] -123.688560 -185.300073 [87,] -240.620743 -123.688560 [88,] -103.222664 -240.620743 [89,] -152.857196 -103.222664 [90,] -82.464113 -152.857196 [91,] -59.674162 -82.464113 [92,] -16.009421 -59.674162 [93,] 124.045590 -16.009421 [94,] 323.221825 124.045590 [95,] 432.468481 323.221825 [96,] -14.274247 432.468481 [97,] -197.862217 -14.274247 [98,] -145.798605 -197.862217 [99,] -262.878818 -145.798605 [100,] -120.151677 -262.878818 [101,] -182.627767 -120.151677 [102,] -104.500143 -182.627767 [103,] -93.330506 -104.500143 [104,] -33.826611 -93.330506 [105,] 104.415038 -33.826611 [106,] 299.705500 104.415038 [107,] 412.689900 299.705500 [108,] -47.634533 412.689900 [109,] -222.081682 -47.634533 [110,] -173.385741 -222.081682 [111,] -286.913247 -173.385741 [112,] -144.038076 -286.913247 [113,] -208.364534 -144.038076 [114,] -131.236110 -208.364534 [115,] -115.107485 -131.236110 [116,] -60.525570 -115.107485 [117,] 82.527037 -60.525570 [118,] 275.893116 82.527037 [119,] 388.988538 275.893116 [120,] -64.304495 388.988538 [121,] -243.414573 -64.304495 [122,] -202.712224 -243.414573 [123,] -308.949277 -202.712224 [124,] -170.070903 -308.949277 [125,] -223.258143 -170.070903 [126,] -144.686431 -223.258143 [127,] -133.960882 -144.686431 [128,] -82.561601 -133.960882 [129,] 61.675242 -82.561601 [130,] 255.189350 61.675242 [131,] 369.061927 255.189350 [132,] -80.789420 369.061927 [133,] -262.267970 -80.789420 [134,] -215.200353 -262.267970 [135,] -327.173549 -215.200353 [136,] -188.221160 -327.173549 [137,] -248.587829 -188.221160 [138,] -167.869690 -248.587829 [139,] -155.848883 -167.869690 [140,] -100.933902 -155.848883 [141,] 33.273944 -100.933902 [142,] 243.552390 33.273944 [143,] 356.943872 243.552390 [144,] -95.683028 356.943872 [145,] -287.819700 -95.683028 [146,] -238.494634 -287.819700 [147,] -350.763889 -238.494634 [148,] -212.736684 -350.763889 [149,] -265.479835 -212.736684 [150,] -196.530039 -265.479835 [151,] -176.256589 -196.530039 [152,] -127.817898 -176.256589 [153,] 7.204110 -127.817898 [154,] 216.742409 7.204110 [155,] 342.938440 216.742409 [156,] -116.978912 342.938440 [157,] -309.300620 -116.978912 [158,] -257.274016 -309.300620 [159,] -371.282617 -257.274016 [160,] -233.403442 -371.282617 [161,] -293.844126 -233.403442 [162,] -212.829928 -293.844126 [163,] -204.657887 -212.829928 [164,] -146.560273 -204.657887 [165,] -11.501257 -146.560273 [166,] 189.969435 -11.501257 [167,] 307.912823 189.969435 [168,] -140.347208 307.912823 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -26.125879 159.978592 2 26.344814 -26.125879 3 -86.516559 26.344814 4 46.736695 -86.516559 5 -6.598574 46.736695 6 70.048755 -6.598574 7 82.846716 70.048755 8 139.501044 82.846716 9 281.295400 139.501044 10 469.776506 281.295400 11 590.865520 469.776506 12 135.611097 590.865520 13 -57.598788 135.611097 14 -3.388750 -57.598788 15 -114.880850 -3.388750 16 26.884100 -114.880850 17 -28.893656 26.884100 18 38.982926 -28.893656 19 54.593448 38.982926 20 112.357996 54.593448 21 246.195769 112.357996 22 444.483827 246.195769 23 556.691073 444.483827 24 103.361032 556.691073 25 -75.489994 103.361032 26 -24.462589 -75.489994 27 -139.248344 -24.462589 28 -3.589611 -139.248344 29 -59.219337 -3.589611 30 17.390984 -59.219337 31 27.968503 17.390984 32 94.096717 27.968503 33 224.825871 94.096717 34 422.854878 224.825871 35 545.313164 422.854878 36 79.548648 545.313164 37 -101.633842 79.548648 38 -51.679651 -101.633842 39 -159.211962 -51.679651 40 -31.879887 -159.211962 41 -85.141142 -31.879887 42 -10.862285 -85.141142 43 14.777234 -10.862285 44 66.250530 14.777234 45 203.455973 66.250530 46 394.823653 203.455973 47 506.253744 394.823653 48 56.957507 506.253744 49 -130.812295 56.957507 50 -67.794502 -130.812295 51 -194.940719 -67.794502 52 -54.841102 -194.940719 53 -105.622863 -54.841102 54 -34.563647 -105.622863 55 -15.437425 -34.563647 56 32.964259 -15.437425 57 177.645191 32.964259 58 383.186694 177.645191 59 502.943442 383.186694 60 53.092095 502.943442 61 -135.750921 53.092095 62 -84.982568 -135.750921 63 -196.215616 -84.982568 64 -66.737113 -196.215616 65 -127.029768 -66.737113 66 -47.902946 -127.029768 67 -36.474257 -47.902946 68 13.962833 -36.474257 69 155.794197 13.962833 70 362.186869 155.794197 71 484.645156 362.186869 72 32.277307 484.645156 73 -152.272854 32.277307 74 -110.793350 -152.272854 75 -218.177632 -110.793350 76 -80.853567 -218.177632 77 -135.040006 -80.853567 78 -57.393478 -135.040006 79 -45.705738 -57.393478 80 4.879381 -45.705738 81 152.927983 4.879381 82 347.145232 152.927983 83 457.206049 347.145232 84 14.164058 457.206049 85 -185.300073 14.164058 86 -123.688560 -185.300073 87 -240.620743 -123.688560 88 -103.222664 -240.620743 89 -152.857196 -103.222664 90 -82.464113 -152.857196 91 -59.674162 -82.464113 92 -16.009421 -59.674162 93 124.045590 -16.009421 94 323.221825 124.045590 95 432.468481 323.221825 96 -14.274247 432.468481 97 -197.862217 -14.274247 98 -145.798605 -197.862217 99 -262.878818 -145.798605 100 -120.151677 -262.878818 101 -182.627767 -120.151677 102 -104.500143 -182.627767 103 -93.330506 -104.500143 104 -33.826611 -93.330506 105 104.415038 -33.826611 106 299.705500 104.415038 107 412.689900 299.705500 108 -47.634533 412.689900 109 -222.081682 -47.634533 110 -173.385741 -222.081682 111 -286.913247 -173.385741 112 -144.038076 -286.913247 113 -208.364534 -144.038076 114 -131.236110 -208.364534 115 -115.107485 -131.236110 116 -60.525570 -115.107485 117 82.527037 -60.525570 118 275.893116 82.527037 119 388.988538 275.893116 120 -64.304495 388.988538 121 -243.414573 -64.304495 122 -202.712224 -243.414573 123 -308.949277 -202.712224 124 -170.070903 -308.949277 125 -223.258143 -170.070903 126 -144.686431 -223.258143 127 -133.960882 -144.686431 128 -82.561601 -133.960882 129 61.675242 -82.561601 130 255.189350 61.675242 131 369.061927 255.189350 132 -80.789420 369.061927 133 -262.267970 -80.789420 134 -215.200353 -262.267970 135 -327.173549 -215.200353 136 -188.221160 -327.173549 137 -248.587829 -188.221160 138 -167.869690 -248.587829 139 -155.848883 -167.869690 140 -100.933902 -155.848883 141 33.273944 -100.933902 142 243.552390 33.273944 143 356.943872 243.552390 144 -95.683028 356.943872 145 -287.819700 -95.683028 146 -238.494634 -287.819700 147 -350.763889 -238.494634 148 -212.736684 -350.763889 149 -265.479835 -212.736684 150 -196.530039 -265.479835 151 -176.256589 -196.530039 152 -127.817898 -176.256589 153 7.204110 -127.817898 154 216.742409 7.204110 155 342.938440 216.742409 156 -116.978912 342.938440 157 -309.300620 -116.978912 158 -257.274016 -309.300620 159 -371.282617 -257.274016 160 -233.403442 -371.282617 161 -293.844126 -233.403442 162 -212.829928 -293.844126 163 -204.657887 -212.829928 164 -146.560273 -204.657887 165 -11.501257 -146.560273 166 189.969435 -11.501257 167 307.912823 189.969435 168 -140.347208 307.912823 > plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals') > lines(lowess(z)) > abline(lm(z)) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/7uudj1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/82kcv1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/9jszg1227776136.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) > plot(mylm, las = 1, sub='Residual Diagnostics') > par(opar) > dev.off() null device 1 > > #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, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE) > a<-table.row.end(a) > myeq <- colnames(x)[1] > myeq <- paste(myeq, '[t] = ', '') > for (i in 1:k){ + if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '') + myeq <- paste(myeq, mysum$coefficients[i,1], ' ') + if (rownames(mysum$coefficients)[i] != '(Intercept)') myeq <- paste(myeq, rownames(mysum$coefficients)[i], '') + } > myeq <- paste(myeq, ' + e[t]') > a<-table.row.start(a) > a<-table.element(a, myeq) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/10qbsc1227776136.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Variable',header=TRUE) > a<-table.element(a,'Parameter',header=TRUE) > a<-table.element(a,'S.D.',header=TRUE) > a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE) > a<-table.element(a,'2-tail p-value',header=TRUE) > a<-table.element(a,'1-tail p-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:k){ + a<-table.row.start(a) + a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE) + a<-table.element(a,mysum$coefficients[i,1]) + a<-table.element(a,mysum$coefficients[i,2]) + a<-table.element(a,mysum$coefficients[i,3]) + a<-table.element(a,mysum$coefficients[i,4]) + a<-table.element(a,mysum$coefficients[i,4]/2) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/11oh8b1227776136.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Multiple R',1,TRUE) > a<-table.element(a, sqrt(mysum$r.squared)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'R-squared',1,TRUE) > a<-table.element(a, mysum$r.squared) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Adjusted R-squared',1,TRUE) > a<-table.element(a, mysum$adj.r.squared) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (value)',1,TRUE) > a<-table.element(a, mysum$fstatistic[1]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE) > a<-table.element(a, mysum$fstatistic[2]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE) > a<-table.element(a, mysum$fstatistic[3]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'p-value',1,TRUE) > a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3])) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Residual Standard Deviation',1,TRUE) > a<-table.element(a, mysum$sigma) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Sum Squared Residuals',1,TRUE) > a<-table.element(a, sum(myerror*myerror)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/12s66n1227776136.tab") > > system("convert tmp/194v61227776136.ps tmp/194v61227776136.png") > system("convert tmp/278up1227776136.ps tmp/278up1227776136.png") > system("convert tmp/3sffr1227776136.ps tmp/3sffr1227776136.png") > system("convert tmp/49cru1227776136.ps tmp/49cru1227776136.png") > system("convert tmp/5kh6s1227776136.ps tmp/5kh6s1227776136.png") > system("convert tmp/6kjsb1227776136.ps tmp/6kjsb1227776136.png") > system("convert tmp/7uudj1227776136.ps tmp/7uudj1227776136.png") > system("convert tmp/82kcv1227776136.ps tmp/82kcv1227776136.png") > system("convert tmp/9jszg1227776136.ps tmp/9jszg1227776136.png") > > > proc.time() user system elapsed 2.192 1.682 2.700