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. > x <- array(list(98.8,6.3,100.5,6.1,110.4,6.1,96.4,6.3,101.9,6.3,106.2,6,81,6.2,94.7,6.4,101,6.8,109.4,7.5,102.3,7.5,90.7,7.6,96.2,7.6,96.1,7.4,106,7.3,103.1,7.1,102,6.9,104.7,6.8,86,7.5,92.1,7.6,106.9,7.8,112.6,8,101.7,8.1,92,8.2,97.4,8.3,97,8.2,105.4,8,102.7,7.9,98.1,7.6,104.5,7.6,87.4,8.3,89.9,8.4,109.8,8.4,111.7,8.4,98.6,8.4,96.9,8.6,95.1,8.9,97,8.8,112.7,8.3,102.9,7.5,97.4,7.2,111.4,7.4,87.4,8.8,96.8,9.3,114.1,9.3,110.3,8.7,103.9,8.2,101.6,8.3,94.6,8.5,95.9,8.6,104.7,8.5,102.8,8.2,98.1,8.1,113.9,7.9,80.9,8.6,95.7,8.7,113.2,8.7,105.9,8.5,108.8,8.4,102.3,8.5,99,8.7,100.7,8.7,115.5,8.6,100.7,8.5,109.9,8.3,114.6,8,85.4,8.2,100.5,8.1,114.8,8.1,116.5,8,112.9,7.9,102,7.9,106,8,105.3,8,118.8,7.9,106.1,8,109.3,7.7,117.2,7.2,92.5,7.5,104.2,7.3,112.5,7,122.4,7,113.3,7,100,7.2,110.7,7.3,112.8,7.1,109.8,6.8,117.3,6.4,109.1,6.1,115.9,6.5,96,7.7,99.8,7.9,116.8,7.5,115.7,6.9,99.4,6.6,94.3,6.9,91,7.7),dim=c(2,97),dimnames=list(c('Y','X'),1:97)) > y <- array(NA,dim=c(2,97),dimnames=list(c('Y','X'),1:97)) > 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 = 'Include Monthly 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) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > 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 Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 98.8 6.3 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1 0 0 0 0 0 0 0 0 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 100.8087 -0.4220 1.2899 3.1717 12.8478 6.3509 M5 M6 M7 M8 M9 M10 5.4863 13.2691 -10.4211 -0.7361 13.6836 15.5770 M11 7.5795 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -10.6228 -3.9117 -0.9063 3.8455 12.8411 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 100.8087 6.1135 16.490 < 2e-16 *** X -0.4220 0.7352 -0.574 0.567509 M1 1.2899 2.6231 0.492 0.624172 M2 3.1717 2.6992 1.175 0.243303 M3 12.8478 2.7036 4.752 8.23e-06 *** M4 6.3509 2.7161 2.338 0.021750 * M5 5.4863 2.7379 2.004 0.048314 * M6 13.2691 2.7512 4.823 6.24e-06 *** M7 -10.4211 2.6993 -3.861 0.000221 *** M8 -0.7361 2.6995 -0.273 0.785760 M9 13.6836 2.6993 5.069 2.34e-06 *** M10 15.5770 2.6992 5.771 1.28e-07 *** M11 7.5795 2.7010 2.806 0.006229 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.398 on 84 degrees of freedom Multiple R-squared: 0.6776, Adjusted R-squared: 0.6315 F-statistic: 14.71 on 12 and 84 DF, p-value: 5.248e-16 > if (n > n25) { + kp3 <- k + 3 + nmkm3 <- n - k - 3 + gqarr <- array(NA, dim=c(nmkm3-kp3+1,3)) + numgqtests <- 0 + numsignificant1 <- 0 + numsignificant5 <- 0 + numsignificant10 <- 0 + for (mypoint in kp3:nmkm3) { + j <- 0 + numgqtests <- numgqtests + 1 + for (myalt in c('greater', 'two.sided', 'less')) { + j <- j + 1 + gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value + } + if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1 + } + gqarr + } [,1] [,2] [,3] [1,] 0.2937304445 0.5874608890 0.7062696 [2,] 0.1582499673 0.3164999347 0.8417500 [3,] 0.0839358007 0.1678716014 0.9160642 [4,] 0.1017454780 0.2034909560 0.8982545 [5,] 0.0615388342 0.1230776684 0.9384612 [6,] 0.0769674979 0.1539349958 0.9230325 [7,] 0.0510950549 0.1021901098 0.9489049 [8,] 0.0279842889 0.0559685778 0.9720157 [9,] 0.0162221938 0.0324443877 0.9837778 [10,] 0.0080679250 0.0161358499 0.9919321 [11,] 0.0043917814 0.0087835628 0.9956082 [12,] 0.0029951566 0.0059903133 0.9970048 [13,] 0.0021138849 0.0042277697 0.9978861 [14,] 0.0018627438 0.0037254877 0.9981373 [15,] 0.0012210327 0.0024420655 0.9987790 [16,] 0.0011136414 0.0022272829 0.9988864 [17,] 0.0011125542 0.0022251084 0.9988874 [18,] 0.0018857905 0.0037715811 0.9981142 [19,] 0.0009651816 0.0019303633 0.9990348 [20,] 0.0008657965 0.0017315930 0.9991342 [21,] 0.0010944641 0.0021889282 0.9989055 [22,] 0.0007030533 0.0014061065 0.9992969 [23,] 0.0004044311 0.0008088622 0.9995956 [24,] 0.0005287020 0.0010574041 0.9994713 [25,] 0.0003446191 0.0006892381 0.9996554 [26,] 0.0004569547 0.0009139095 0.9995430 [27,] 0.0007762261 0.0015524523 0.9992238 [28,] 0.0004649760 0.0009299521 0.9995350 [29,] 0.0003504551 0.0007009103 0.9996495 [30,] 0.0007108435 0.0014216870 0.9992892 [31,] 0.0004087469 0.0008174939 0.9995913 [32,] 0.0002732768 0.0005465537 0.9997267 [33,] 0.0007429243 0.0014858486 0.9992571 [34,] 0.0005966886 0.0011933773 0.9994033 [35,] 0.0006175428 0.0012350856 0.9993825 [36,] 0.0008683826 0.0017367651 0.9991316 [37,] 0.0005423919 0.0010847837 0.9994576 [38,] 0.0007145580 0.0014291160 0.9992854 [39,] 0.0009133667 0.0018267334 0.9990866 [40,] 0.0015925732 0.0031851465 0.9984074 [41,] 0.0011109970 0.0022219940 0.9988890 [42,] 0.0009293385 0.0018586770 0.9990707 [43,] 0.0023401579 0.0046803157 0.9976598 [44,] 0.0028050930 0.0056101861 0.9971949 [45,] 0.0038620227 0.0077240453 0.9961380 [46,] 0.0024748957 0.0049497913 0.9975251 [47,] 0.0023799447 0.0047598894 0.9976201 [48,] 0.0026059013 0.0052118026 0.9973941 [49,] 0.0039282513 0.0078565025 0.9960717 [50,] 0.0058895912 0.0117791825 0.9941104 [51,] 0.0047047349 0.0094094698 0.9952953 [52,] 0.0056885513 0.0113771027 0.9943114 [53,] 0.0051116862 0.0102233724 0.9948883 [54,] 0.0040120566 0.0080241132 0.9959879 [55,] 0.0036485068 0.0072970137 0.9963515 [56,] 0.0068648101 0.0137296201 0.9931352 [57,] 0.0065049417 0.0130098835 0.9934951 [58,] 0.0087653945 0.0175307890 0.9912346 [59,] 0.0090742055 0.0181484110 0.9909258 [60,] 0.0189444008 0.0378888016 0.9810556 [61,] 0.0219144817 0.0438289635 0.9780855 [62,] 0.0151777286 0.0303554571 0.9848223 [63,] 0.0101026945 0.0202053891 0.9898973 [64,] 0.0069229096 0.0138458191 0.9930771 [65,] 0.0054555467 0.0109110935 0.9945445 [66,] 0.0023641170 0.0047282340 0.9976359 > postscript(file="/var/www/html/rcomp/tmp/1jmyl1258648930.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/222y81258648930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, type='b', 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/37q9q1258648930.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/4ttok1258648930.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/5ecyj1258648930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > qqline(mysum$resid) > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 97 Frequency = 1 1 2 3 4 5 6 -0.6401115 -0.9062513 -0.6824036 -8.1011090 -1.7364369 -5.3458342 7 8 9 10 11 12 -6.7712778 -2.6718540 -10.6227845 -3.8207450 -2.9232715 -6.9015960 13 14 15 16 17 18 -2.6915290 -4.7576688 -4.5760198 -1.0635198 -1.3832450 -6.5082450 19 20 21 22 23 24 -1.2226953 -4.7654701 -4.3007980 -0.4097517 -3.2700795 -5.3484040 25 26 27 28 29 30 -1.1961384 -3.5200795 -4.8806292 -1.1259306 -4.9878544 -6.3706557 31 32 33 34 35 36 0.5148939 -6.6278809 -1.1476061 -1.1409571 -6.2434836 -0.2796094 37 38 39 40 41 42 -3.2429465 -3.2668876 2.5459668 -1.0947252 -5.8566490 0.4449470 43 44 45 46 47 48 0.7258872 0.6519070 3.5321818 -2.4143611 -1.0278809 4.2937946 49 50 51 52 53 54 -3.9117411 -4.4512849 -5.3696359 -0.8993346 -4.7768611 3.1559402 55 56 57 58 59 60 -5.8585101 -0.7012849 2.3789899 -6.8987584 3.9565164 5.0781919 61 62 63 64 65 66 0.5726562 0.3909137 5.4725627 -2.8727386 7.1075362 3.8981389 67 68 69 70 71 72 -1.5273047 3.8455231 3.7257980 3.4902483 7.8455231 4.5250000 73 74 75 76 77 78 7.2772656 4.6955231 8.4771721 2.3162681 6.2543443 6.1605497 79 80 81 82 83 84 5.2773047 7.2079339 0.9616128 8.9682618 7.8657353 2.2296094 85 86 87 88 89 90 11.6818750 11.8157353 -0.9870131 12.8410896 5.3791658 4.5651591 91 92 93 94 95 96 8.8617020 3.0611258 5.4726061 2.2260631 -6.2030593 -3.5969865 97 -7.8493303 > postscript(file="/var/www/html/rcomp/tmp/6988r1258648930.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 = 97 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.6401115 NA 1 -0.9062513 -0.6401115 2 -0.6824036 -0.9062513 3 -8.1011090 -0.6824036 4 -1.7364369 -8.1011090 5 -5.3458342 -1.7364369 6 -6.7712778 -5.3458342 7 -2.6718540 -6.7712778 8 -10.6227845 -2.6718540 9 -3.8207450 -10.6227845 10 -2.9232715 -3.8207450 11 -6.9015960 -2.9232715 12 -2.6915290 -6.9015960 13 -4.7576688 -2.6915290 14 -4.5760198 -4.7576688 15 -1.0635198 -4.5760198 16 -1.3832450 -1.0635198 17 -6.5082450 -1.3832450 18 -1.2226953 -6.5082450 19 -4.7654701 -1.2226953 20 -4.3007980 -4.7654701 21 -0.4097517 -4.3007980 22 -3.2700795 -0.4097517 23 -5.3484040 -3.2700795 24 -1.1961384 -5.3484040 25 -3.5200795 -1.1961384 26 -4.8806292 -3.5200795 27 -1.1259306 -4.8806292 28 -4.9878544 -1.1259306 29 -6.3706557 -4.9878544 30 0.5148939 -6.3706557 31 -6.6278809 0.5148939 32 -1.1476061 -6.6278809 33 -1.1409571 -1.1476061 34 -6.2434836 -1.1409571 35 -0.2796094 -6.2434836 36 -3.2429465 -0.2796094 37 -3.2668876 -3.2429465 38 2.5459668 -3.2668876 39 -1.0947252 2.5459668 40 -5.8566490 -1.0947252 41 0.4449470 -5.8566490 42 0.7258872 0.4449470 43 0.6519070 0.7258872 44 3.5321818 0.6519070 45 -2.4143611 3.5321818 46 -1.0278809 -2.4143611 47 4.2937946 -1.0278809 48 -3.9117411 4.2937946 49 -4.4512849 -3.9117411 50 -5.3696359 -4.4512849 51 -0.8993346 -5.3696359 52 -4.7768611 -0.8993346 53 3.1559402 -4.7768611 54 -5.8585101 3.1559402 55 -0.7012849 -5.8585101 56 2.3789899 -0.7012849 57 -6.8987584 2.3789899 58 3.9565164 -6.8987584 59 5.0781919 3.9565164 60 0.5726562 5.0781919 61 0.3909137 0.5726562 62 5.4725627 0.3909137 63 -2.8727386 5.4725627 64 7.1075362 -2.8727386 65 3.8981389 7.1075362 66 -1.5273047 3.8981389 67 3.8455231 -1.5273047 68 3.7257980 3.8455231 69 3.4902483 3.7257980 70 7.8455231 3.4902483 71 4.5250000 7.8455231 72 7.2772656 4.5250000 73 4.6955231 7.2772656 74 8.4771721 4.6955231 75 2.3162681 8.4771721 76 6.2543443 2.3162681 77 6.1605497 6.2543443 78 5.2773047 6.1605497 79 7.2079339 5.2773047 80 0.9616128 7.2079339 81 8.9682618 0.9616128 82 7.8657353 8.9682618 83 2.2296094 7.8657353 84 11.6818750 2.2296094 85 11.8157353 11.6818750 86 -0.9870131 11.8157353 87 12.8410896 -0.9870131 88 5.3791658 12.8410896 89 4.5651591 5.3791658 90 8.8617020 4.5651591 91 3.0611258 8.8617020 92 5.4726061 3.0611258 93 2.2260631 5.4726061 94 -6.2030593 2.2260631 95 -3.5969865 -6.2030593 96 -7.8493303 -3.5969865 97 NA -7.8493303 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.9062513 -0.6401115 [2,] -0.6824036 -0.9062513 [3,] -8.1011090 -0.6824036 [4,] -1.7364369 -8.1011090 [5,] -5.3458342 -1.7364369 [6,] -6.7712778 -5.3458342 [7,] -2.6718540 -6.7712778 [8,] -10.6227845 -2.6718540 [9,] -3.8207450 -10.6227845 [10,] -2.9232715 -3.8207450 [11,] -6.9015960 -2.9232715 [12,] -2.6915290 -6.9015960 [13,] -4.7576688 -2.6915290 [14,] -4.5760198 -4.7576688 [15,] -1.0635198 -4.5760198 [16,] -1.3832450 -1.0635198 [17,] -6.5082450 -1.3832450 [18,] -1.2226953 -6.5082450 [19,] -4.7654701 -1.2226953 [20,] -4.3007980 -4.7654701 [21,] -0.4097517 -4.3007980 [22,] -3.2700795 -0.4097517 [23,] -5.3484040 -3.2700795 [24,] -1.1961384 -5.3484040 [25,] -3.5200795 -1.1961384 [26,] -4.8806292 -3.5200795 [27,] -1.1259306 -4.8806292 [28,] -4.9878544 -1.1259306 [29,] -6.3706557 -4.9878544 [30,] 0.5148939 -6.3706557 [31,] -6.6278809 0.5148939 [32,] -1.1476061 -6.6278809 [33,] -1.1409571 -1.1476061 [34,] -6.2434836 -1.1409571 [35,] -0.2796094 -6.2434836 [36,] -3.2429465 -0.2796094 [37,] -3.2668876 -3.2429465 [38,] 2.5459668 -3.2668876 [39,] -1.0947252 2.5459668 [40,] -5.8566490 -1.0947252 [41,] 0.4449470 -5.8566490 [42,] 0.7258872 0.4449470 [43,] 0.6519070 0.7258872 [44,] 3.5321818 0.6519070 [45,] -2.4143611 3.5321818 [46,] -1.0278809 -2.4143611 [47,] 4.2937946 -1.0278809 [48,] -3.9117411 4.2937946 [49,] -4.4512849 -3.9117411 [50,] -5.3696359 -4.4512849 [51,] -0.8993346 -5.3696359 [52,] -4.7768611 -0.8993346 [53,] 3.1559402 -4.7768611 [54,] -5.8585101 3.1559402 [55,] -0.7012849 -5.8585101 [56,] 2.3789899 -0.7012849 [57,] -6.8987584 2.3789899 [58,] 3.9565164 -6.8987584 [59,] 5.0781919 3.9565164 [60,] 0.5726562 5.0781919 [61,] 0.3909137 0.5726562 [62,] 5.4725627 0.3909137 [63,] -2.8727386 5.4725627 [64,] 7.1075362 -2.8727386 [65,] 3.8981389 7.1075362 [66,] -1.5273047 3.8981389 [67,] 3.8455231 -1.5273047 [68,] 3.7257980 3.8455231 [69,] 3.4902483 3.7257980 [70,] 7.8455231 3.4902483 [71,] 4.5250000 7.8455231 [72,] 7.2772656 4.5250000 [73,] 4.6955231 7.2772656 [74,] 8.4771721 4.6955231 [75,] 2.3162681 8.4771721 [76,] 6.2543443 2.3162681 [77,] 6.1605497 6.2543443 [78,] 5.2773047 6.1605497 [79,] 7.2079339 5.2773047 [80,] 0.9616128 7.2079339 [81,] 8.9682618 0.9616128 [82,] 7.8657353 8.9682618 [83,] 2.2296094 7.8657353 [84,] 11.6818750 2.2296094 [85,] 11.8157353 11.6818750 [86,] -0.9870131 11.8157353 [87,] 12.8410896 -0.9870131 [88,] 5.3791658 12.8410896 [89,] 4.5651591 5.3791658 [90,] 8.8617020 4.5651591 [91,] 3.0611258 8.8617020 [92,] 5.4726061 3.0611258 [93,] 2.2260631 5.4726061 [94,] -6.2030593 2.2260631 [95,] -3.5969865 -6.2030593 [96,] -7.8493303 -3.5969865 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.9062513 -0.6401115 2 -0.6824036 -0.9062513 3 -8.1011090 -0.6824036 4 -1.7364369 -8.1011090 5 -5.3458342 -1.7364369 6 -6.7712778 -5.3458342 7 -2.6718540 -6.7712778 8 -10.6227845 -2.6718540 9 -3.8207450 -10.6227845 10 -2.9232715 -3.8207450 11 -6.9015960 -2.9232715 12 -2.6915290 -6.9015960 13 -4.7576688 -2.6915290 14 -4.5760198 -4.7576688 15 -1.0635198 -4.5760198 16 -1.3832450 -1.0635198 17 -6.5082450 -1.3832450 18 -1.2226953 -6.5082450 19 -4.7654701 -1.2226953 20 -4.3007980 -4.7654701 21 -0.4097517 -4.3007980 22 -3.2700795 -0.4097517 23 -5.3484040 -3.2700795 24 -1.1961384 -5.3484040 25 -3.5200795 -1.1961384 26 -4.8806292 -3.5200795 27 -1.1259306 -4.8806292 28 -4.9878544 -1.1259306 29 -6.3706557 -4.9878544 30 0.5148939 -6.3706557 31 -6.6278809 0.5148939 32 -1.1476061 -6.6278809 33 -1.1409571 -1.1476061 34 -6.2434836 -1.1409571 35 -0.2796094 -6.2434836 36 -3.2429465 -0.2796094 37 -3.2668876 -3.2429465 38 2.5459668 -3.2668876 39 -1.0947252 2.5459668 40 -5.8566490 -1.0947252 41 0.4449470 -5.8566490 42 0.7258872 0.4449470 43 0.6519070 0.7258872 44 3.5321818 0.6519070 45 -2.4143611 3.5321818 46 -1.0278809 -2.4143611 47 4.2937946 -1.0278809 48 -3.9117411 4.2937946 49 -4.4512849 -3.9117411 50 -5.3696359 -4.4512849 51 -0.8993346 -5.3696359 52 -4.7768611 -0.8993346 53 3.1559402 -4.7768611 54 -5.8585101 3.1559402 55 -0.7012849 -5.8585101 56 2.3789899 -0.7012849 57 -6.8987584 2.3789899 58 3.9565164 -6.8987584 59 5.0781919 3.9565164 60 0.5726562 5.0781919 61 0.3909137 0.5726562 62 5.4725627 0.3909137 63 -2.8727386 5.4725627 64 7.1075362 -2.8727386 65 3.8981389 7.1075362 66 -1.5273047 3.8981389 67 3.8455231 -1.5273047 68 3.7257980 3.8455231 69 3.4902483 3.7257980 70 7.8455231 3.4902483 71 4.5250000 7.8455231 72 7.2772656 4.5250000 73 4.6955231 7.2772656 74 8.4771721 4.6955231 75 2.3162681 8.4771721 76 6.2543443 2.3162681 77 6.1605497 6.2543443 78 5.2773047 6.1605497 79 7.2079339 5.2773047 80 0.9616128 7.2079339 81 8.9682618 0.9616128 82 7.8657353 8.9682618 83 2.2296094 7.8657353 84 11.6818750 2.2296094 85 11.8157353 11.6818750 86 -0.9870131 11.8157353 87 12.8410896 -0.9870131 88 5.3791658 12.8410896 89 4.5651591 5.3791658 90 8.8617020 4.5651591 91 3.0611258 8.8617020 92 5.4726061 3.0611258 93 2.2260631 5.4726061 94 -6.2030593 2.2260631 95 -3.5969865 -6.2030593 96 -7.8493303 -3.5969865 > 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/7phvj1258648930.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/8tcjt1258648930.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/9g2o81258648930.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 > if (n > n25) { + postscript(file="/var/www/html/rcomp/tmp/10b7sv1258648930.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + 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] = ', sep='') > for (i in 1:k){ + if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '') + myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ') + if (rownames(mysum$coefficients)[i] != '(Intercept)') { + myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='') + if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='') + } + } > 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/11sx6i1258648930.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, round(mysum$coefficients[i,2],6)) + a<-table.element(a, round(mysum$coefficients[i,3],4)) + a<-table.element(a, round(mysum$coefficients[i,4],6)) + a<-table.element(a, round(mysum$coefficients[i,4]/2,6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/1212y21258648930.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/13pkub1258648930.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Time or Index', 1, TRUE) > a<-table.element(a, 'Actuals', 1, TRUE) > a<-table.element(a, 'Interpolation
Forecast', 1, TRUE) > a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE) > a<-table.row.end(a) > for (i in 1:n) { + a<-table.row.start(a) + a<-table.element(a,i, 1, TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,x[i]-mysum$resid[i]) + a<-table.element(a,mysum$resid[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/145z081258648930.tab") > if (n > n25) { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'p-values',header=TRUE) + a<-table.element(a,'Alternative Hypothesis',3,header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'breakpoint index',header=TRUE) + a<-table.element(a,'greater',header=TRUE) + a<-table.element(a,'2-sided',header=TRUE) + a<-table.element(a,'less',header=TRUE) + a<-table.row.end(a) + for (mypoint in kp3:nmkm3) { + a<-table.row.start(a) + a<-table.element(a,mypoint,header=TRUE) + a<-table.element(a,gqarr[mypoint-kp3+1,1]) + a<-table.element(a,gqarr[mypoint-kp3+1,2]) + a<-table.element(a,gqarr[mypoint-kp3+1,3]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/157p331258648930.tab") + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Description',header=TRUE) + a<-table.element(a,'# significant tests',header=TRUE) + a<-table.element(a,'% significant tests',header=TRUE) + a<-table.element(a,'OK/NOK',header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'1% type I error level',header=TRUE) + a<-table.element(a,numsignificant1) + a<-table.element(a,numsignificant1/numgqtests) + if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'5% type I error level',header=TRUE) + a<-table.element(a,numsignificant5) + a<-table.element(a,numsignificant5/numgqtests) + if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'10% type I error level',header=TRUE) + a<-table.element(a,numsignificant10) + a<-table.element(a,numsignificant10/numgqtests) + if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/169llz1258648930.tab") + } > > system("convert tmp/1jmyl1258648930.ps tmp/1jmyl1258648930.png") > system("convert tmp/222y81258648930.ps tmp/222y81258648930.png") > system("convert tmp/37q9q1258648930.ps tmp/37q9q1258648930.png") > system("convert tmp/4ttok1258648930.ps tmp/4ttok1258648930.png") > system("convert tmp/5ecyj1258648930.ps tmp/5ecyj1258648930.png") > system("convert tmp/6988r1258648930.ps tmp/6988r1258648930.png") > system("convert tmp/7phvj1258648930.ps tmp/7phvj1258648930.png") > system("convert tmp/8tcjt1258648930.ps tmp/8tcjt1258648930.png") > system("convert tmp/9g2o81258648930.ps tmp/9g2o81258648930.png") > system("convert tmp/10b7sv1258648930.ps tmp/10b7sv1258648930.png") > > > proc.time() user system elapsed 2.960 1.612 3.339