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(101.5,1,100.7,1,110.6,1,96.8,1,100.0,1,104.8,1,86.8,1,92.0,1,100.2,1,106.6,1,102.1,1,93.7,1,97.6,1,96.9,1,105.6,1,102.8,1,101.7,1,104.2,1,92.7,1,91.9,1,106.5,1,112.3,1,102.8,1,96.5,1,101.0,0,98.9,0,105.1,0,103.0,0,99.0,0,104.3,0,94.6,0,90.4,0,108.9,0,111.4,0,100.8,0,102.5,0,98.2,0,98.7,0,113.3,0,104.6,0,99.3,0,111.8,0,97.3,0,97.7,0,115.6,0,111.9,0,107.0,0,107.1,0,100.6,0,99.2,0,108.4,0,103.0,0,99.8,0,115.0,0,90.8,0,95.9,0,114.4,0,108.2,0,112.6,0,109.1,0,105.0,0,105.0,0,118.5,0,103.7,0,112.5,0,116.6,0,96.6,0,101.9,0,116.5,0,119.3,0,115.4,0,108.5,0,111.5,0,108.8,0,121.8,0,109.6,0,112.2,0,119.6,0,104.1,0,105.3,0,115.0,0,124.1,0,116.8,0,107.5,0,115.6,0,116.2,0,116.3,0,119.0,0,111.9,0,118.6,0,106.9,0,103.2,0),dim=c(2,92),dimnames=list(c('Y','X'),1:92)) > y <- array(NA,dim=c(2,92),dimnames=list(c('Y','X'),1:92)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = '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 t 1 101.5 1 1 0 0 0 0 0 0 0 0 0 0 1 2 100.7 1 0 1 0 0 0 0 0 0 0 0 0 2 3 110.6 1 0 0 1 0 0 0 0 0 0 0 0 3 4 96.8 1 0 0 0 1 0 0 0 0 0 0 0 4 5 100.0 1 0 0 0 0 1 0 0 0 0 0 0 5 6 104.8 1 0 0 0 0 0 1 0 0 0 0 0 6 7 86.8 1 0 0 0 0 0 0 1 0 0 0 0 7 8 92.0 1 0 0 0 0 0 0 0 1 0 0 0 8 9 100.2 1 0 0 0 0 0 0 0 0 1 0 0 9 10 106.6 1 0 0 0 0 0 0 0 0 0 1 0 10 11 102.1 1 0 0 0 0 0 0 0 0 0 0 1 11 12 93.7 1 0 0 0 0 0 0 0 0 0 0 0 12 13 97.6 1 1 0 0 0 0 0 0 0 0 0 0 13 14 96.9 1 0 1 0 0 0 0 0 0 0 0 0 14 15 105.6 1 0 0 1 0 0 0 0 0 0 0 0 15 16 102.8 1 0 0 0 1 0 0 0 0 0 0 0 16 17 101.7 1 0 0 0 0 1 0 0 0 0 0 0 17 18 104.2 1 0 0 0 0 0 1 0 0 0 0 0 18 19 92.7 1 0 0 0 0 0 0 1 0 0 0 0 19 20 91.9 1 0 0 0 0 0 0 0 1 0 0 0 20 21 106.5 1 0 0 0 0 0 0 0 0 1 0 0 21 22 112.3 1 0 0 0 0 0 0 0 0 0 1 0 22 23 102.8 1 0 0 0 0 0 0 0 0 0 0 1 23 24 96.5 1 0 0 0 0 0 0 0 0 0 0 0 24 25 101.0 0 1 0 0 0 0 0 0 0 0 0 0 25 26 98.9 0 0 1 0 0 0 0 0 0 0 0 0 26 27 105.1 0 0 0 1 0 0 0 0 0 0 0 0 27 28 103.0 0 0 0 0 1 0 0 0 0 0 0 0 28 29 99.0 0 0 0 0 0 1 0 0 0 0 0 0 29 30 104.3 0 0 0 0 0 0 1 0 0 0 0 0 30 31 94.6 0 0 0 0 0 0 0 1 0 0 0 0 31 32 90.4 0 0 0 0 0 0 0 0 1 0 0 0 32 33 108.9 0 0 0 0 0 0 0 0 0 1 0 0 33 34 111.4 0 0 0 0 0 0 0 0 0 0 1 0 34 35 100.8 0 0 0 0 0 0 0 0 0 0 0 1 35 36 102.5 0 0 0 0 0 0 0 0 0 0 0 0 36 37 98.2 0 1 0 0 0 0 0 0 0 0 0 0 37 38 98.7 0 0 1 0 0 0 0 0 0 0 0 0 38 39 113.3 0 0 0 1 0 0 0 0 0 0 0 0 39 40 104.6 0 0 0 0 1 0 0 0 0 0 0 0 40 41 99.3 0 0 0 0 0 1 0 0 0 0 0 0 41 42 111.8 0 0 0 0 0 0 1 0 0 0 0 0 42 43 97.3 0 0 0 0 0 0 0 1 0 0 0 0 43 44 97.7 0 0 0 0 0 0 0 0 1 0 0 0 44 45 115.6 0 0 0 0 0 0 0 0 0 1 0 0 45 46 111.9 0 0 0 0 0 0 0 0 0 0 1 0 46 47 107.0 0 0 0 0 0 0 0 0 0 0 0 1 47 48 107.1 0 0 0 0 0 0 0 0 0 0 0 0 48 49 100.6 0 1 0 0 0 0 0 0 0 0 0 0 49 50 99.2 0 0 1 0 0 0 0 0 0 0 0 0 50 51 108.4 0 0 0 1 0 0 0 0 0 0 0 0 51 52 103.0 0 0 0 0 1 0 0 0 0 0 0 0 52 53 99.8 0 0 0 0 0 1 0 0 0 0 0 0 53 54 115.0 0 0 0 0 0 0 1 0 0 0 0 0 54 55 90.8 0 0 0 0 0 0 0 1 0 0 0 0 55 56 95.9 0 0 0 0 0 0 0 0 1 0 0 0 56 57 114.4 0 0 0 0 0 0 0 0 0 1 0 0 57 58 108.2 0 0 0 0 0 0 0 0 0 0 1 0 58 59 112.6 0 0 0 0 0 0 0 0 0 0 0 1 59 60 109.1 0 0 0 0 0 0 0 0 0 0 0 0 60 61 105.0 0 1 0 0 0 0 0 0 0 0 0 0 61 62 105.0 0 0 1 0 0 0 0 0 0 0 0 0 62 63 118.5 0 0 0 1 0 0 0 0 0 0 0 0 63 64 103.7 0 0 0 0 1 0 0 0 0 0 0 0 64 65 112.5 0 0 0 0 0 1 0 0 0 0 0 0 65 66 116.6 0 0 0 0 0 0 1 0 0 0 0 0 66 67 96.6 0 0 0 0 0 0 0 1 0 0 0 0 67 68 101.9 0 0 0 0 0 0 0 0 1 0 0 0 68 69 116.5 0 0 0 0 0 0 0 0 0 1 0 0 69 70 119.3 0 0 0 0 0 0 0 0 0 0 1 0 70 71 115.4 0 0 0 0 0 0 0 0 0 0 0 1 71 72 108.5 0 0 0 0 0 0 0 0 0 0 0 0 72 73 111.5 0 1 0 0 0 0 0 0 0 0 0 0 73 74 108.8 0 0 1 0 0 0 0 0 0 0 0 0 74 75 121.8 0 0 0 1 0 0 0 0 0 0 0 0 75 76 109.6 0 0 0 0 1 0 0 0 0 0 0 0 76 77 112.2 0 0 0 0 0 1 0 0 0 0 0 0 77 78 119.6 0 0 0 0 0 0 1 0 0 0 0 0 78 79 104.1 0 0 0 0 0 0 0 1 0 0 0 0 79 80 105.3 0 0 0 0 0 0 0 0 1 0 0 0 80 81 115.0 0 0 0 0 0 0 0 0 0 1 0 0 81 82 124.1 0 0 0 0 0 0 0 0 0 0 1 0 82 83 116.8 0 0 0 0 0 0 0 0 0 0 0 1 83 84 107.5 0 0 0 0 0 0 0 0 0 0 0 0 84 85 115.6 0 1 0 0 0 0 0 0 0 0 0 0 85 86 116.2 0 0 1 0 0 0 0 0 0 0 0 0 86 87 116.3 0 0 0 1 0 0 0 0 0 0 0 0 87 88 119.0 0 0 0 0 1 0 0 0 0 0 0 0 88 89 111.9 0 0 0 0 0 1 0 0 0 0 0 0 89 90 118.6 0 0 0 0 0 0 1 0 0 0 0 0 90 91 106.9 0 0 0 0 0 0 0 1 0 0 0 0 91 92 103.2 0 0 0 0 0 0 0 0 1 0 0 0 92 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 91.7817 2.9190 1.5618 0.5089 9.6809 2.3155 M5 M6 M7 M8 M9 M10 1.3251 8.4096 -7.4558 -6.6213 8.1410 10.2988 M11 t 4.8851 0.2279 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7.1014 -2.2494 0.5024 2.3354 5.5345 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 91.78168 1.72940 53.071 < 2e-16 *** X 2.91902 1.18850 2.456 0.016271 * M1 1.56184 1.67781 0.931 0.354786 M2 0.50890 1.67639 0.304 0.762266 M3 9.68095 1.67519 5.779 1.47e-07 *** M4 2.31550 1.67423 1.383 0.170605 M5 1.32505 1.67351 0.792 0.430888 M6 8.40961 1.67301 5.027 3.10e-06 *** M7 -7.45584 1.67274 -4.457 2.74e-05 *** M8 -6.62129 1.67271 -3.958 0.000165 *** M9 8.14098 1.72833 4.710 1.06e-05 *** M10 10.29875 1.72777 5.961 6.88e-08 *** M11 4.88509 1.72743 2.828 0.005951 ** t 0.22795 0.01969 11.574 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.232 on 78 degrees of freedom Multiple R-squared: 0.8635, Adjusted R-squared: 0.8408 F-statistic: 37.96 on 13 and 78 DF, p-value: < 2.2e-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.75643934 0.4871213 0.2435607 [2,] 0.61623125 0.7675375 0.3837687 [3,] 0.68903205 0.6219359 0.3109679 [4,] 0.56700573 0.8659885 0.4329943 [5,] 0.60797381 0.7840524 0.3920262 [6,] 0.61545738 0.7690852 0.3845426 [7,] 0.51481766 0.9703647 0.4851823 [8,] 0.42189187 0.8437837 0.5781081 [9,] 0.33841842 0.6768368 0.6615816 [10,] 0.26214506 0.5242901 0.7378549 [11,] 0.23262821 0.4652564 0.7673718 [12,] 0.21748151 0.4349630 0.7825185 [13,] 0.17144210 0.3428842 0.8285579 [14,] 0.12864053 0.2572811 0.8713595 [15,] 0.15277593 0.3055519 0.8472241 [16,] 0.12014704 0.2402941 0.8798530 [17,] 0.13534768 0.2706954 0.8646523 [18,] 0.10334947 0.2066989 0.8966505 [19,] 0.09602741 0.1920548 0.9039726 [20,] 0.14046623 0.2809325 0.8595338 [21,] 0.13711391 0.2742278 0.8628861 [22,] 0.10611665 0.2122333 0.8938834 [23,] 0.12416190 0.2483238 0.8758381 [24,] 0.10254200 0.2050840 0.8974580 [25,] 0.08879956 0.1775991 0.9112004 [26,] 0.10325685 0.2065137 0.8967431 [27,] 0.11474377 0.2294875 0.8852562 [28,] 0.11728456 0.2345691 0.8827154 [29,] 0.23961873 0.4792375 0.7603813 [30,] 0.19638766 0.3927753 0.8036123 [31,] 0.15689421 0.3137884 0.8431058 [32,] 0.22791876 0.4558375 0.7720812 [33,] 0.21814842 0.4362968 0.7818516 [34,] 0.21880506 0.4376101 0.7811949 [35,] 0.22010381 0.4402076 0.7798962 [36,] 0.18057653 0.3611531 0.8194235 [37,] 0.21344633 0.4268927 0.7865537 [38,] 0.22753826 0.4550765 0.7724617 [39,] 0.28862809 0.5772562 0.7113719 [40,] 0.23637992 0.4727598 0.7636201 [41,] 0.21466990 0.4293398 0.7853301 [42,] 0.42398687 0.8479737 0.5760131 [43,] 0.41659408 0.8331882 0.5834059 [44,] 0.47207061 0.9441412 0.5279294 [45,] 0.46535246 0.9307049 0.5346475 [46,] 0.44326141 0.8865228 0.5567386 [47,] 0.43092785 0.8618557 0.5690722 [48,] 0.57955478 0.8408904 0.4204452 [49,] 0.61568671 0.7686266 0.3843133 [50,] 0.53951459 0.9209708 0.4604854 [51,] 0.62091417 0.7581717 0.3790858 [52,] 0.53126630 0.9374674 0.4687337 [53,] 0.47097086 0.9419417 0.5290291 [54,] 0.41496043 0.8299209 0.5850396 [55,] 0.32555330 0.6511066 0.6744467 [56,] 0.24949229 0.4989846 0.7505077 [57,] 0.18135892 0.3627178 0.8186411 [58,] 0.20591552 0.4118310 0.7940845 [59,] 0.26706568 0.5341314 0.7329343 > postscript(file="/var/www/html/freestat/rcomp/tmp/1zns01229040984.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/freestat/rcomp/tmp/23ujf1229040984.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/freestat/rcomp/tmp/3q6mh1229040984.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/freestat/rcomp/tmp/469bf1229040984.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/freestat/rcomp/tmp/5ygtg1229040984.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 = 92 Frequency = 1 1 2 3 4 5 6 5.009510870 5.034510870 5.534510870 -1.127989130 2.834510870 0.322010870 7 8 9 10 11 12 -2.040489130 2.097010870 -4.693206522 -0.678920807 0.006793478 -3.736063665 13 14 15 16 17 18 -1.625854037 -1.500854037 -2.200854037 2.136645963 1.799145963 -3.013354037 19 20 21 22 23 24 1.124145963 -0.738354037 -1.128571429 2.285714286 -2.028571429 -3.671428571 25 26 27 28 29 30 1.957802795 0.682802795 -2.517197205 2.520302795 -0.717197205 -2.729697205 31 32 33 34 35 36 3.207802795 -2.054697205 1.455085404 1.569371118 -3.844914596 2.512228261 37 38 39 40 41 42 -3.577562112 -2.252562112 2.947437888 1.384937888 -3.152562112 2.034937888 43 44 45 46 47 48 3.172437888 2.509937888 5.419720497 -0.665993789 -0.380279503 4.376863354 49 50 51 52 53 54 -3.912927019 -4.487927019 -4.687927019 -2.950427019 -5.387927019 2.499572981 55 56 57 58 59 60 -6.062927019 -2.025427019 1.484355590 -7.101358696 2.484355590 3.641498447 61 62 63 64 65 66 -2.248291925 -1.423291925 2.676708075 -4.985791925 4.576708075 1.364208075 67 68 69 70 71 72 -2.998291925 1.239208075 0.848990683 1.263276398 2.548990683 0.306133540 73 74 75 76 77 78 1.516343168 -0.358656832 3.241343168 -1.821156832 1.541343168 1.628843168 79 80 81 82 83 84 1.766343168 1.903843168 -3.386374224 3.327911491 1.213625776 -3.429231366 85 86 87 88 89 90 2.880978261 4.305978261 -4.994021739 4.843478261 -1.494021739 -2.106521739 91 92 1.830978261 -2.931521739 > postscript(file="/var/www/html/freestat/rcomp/tmp/6raym1229040984.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 = 92 Frequency = 1 lag(myerror, k = 1) myerror 0 5.009510870 NA 1 5.034510870 5.009510870 2 5.534510870 5.034510870 3 -1.127989130 5.534510870 4 2.834510870 -1.127989130 5 0.322010870 2.834510870 6 -2.040489130 0.322010870 7 2.097010870 -2.040489130 8 -4.693206522 2.097010870 9 -0.678920807 -4.693206522 10 0.006793478 -0.678920807 11 -3.736063665 0.006793478 12 -1.625854037 -3.736063665 13 -1.500854037 -1.625854037 14 -2.200854037 -1.500854037 15 2.136645963 -2.200854037 16 1.799145963 2.136645963 17 -3.013354037 1.799145963 18 1.124145963 -3.013354037 19 -0.738354037 1.124145963 20 -1.128571429 -0.738354037 21 2.285714286 -1.128571429 22 -2.028571429 2.285714286 23 -3.671428571 -2.028571429 24 1.957802795 -3.671428571 25 0.682802795 1.957802795 26 -2.517197205 0.682802795 27 2.520302795 -2.517197205 28 -0.717197205 2.520302795 29 -2.729697205 -0.717197205 30 3.207802795 -2.729697205 31 -2.054697205 3.207802795 32 1.455085404 -2.054697205 33 1.569371118 1.455085404 34 -3.844914596 1.569371118 35 2.512228261 -3.844914596 36 -3.577562112 2.512228261 37 -2.252562112 -3.577562112 38 2.947437888 -2.252562112 39 1.384937888 2.947437888 40 -3.152562112 1.384937888 41 2.034937888 -3.152562112 42 3.172437888 2.034937888 43 2.509937888 3.172437888 44 5.419720497 2.509937888 45 -0.665993789 5.419720497 46 -0.380279503 -0.665993789 47 4.376863354 -0.380279503 48 -3.912927019 4.376863354 49 -4.487927019 -3.912927019 50 -4.687927019 -4.487927019 51 -2.950427019 -4.687927019 52 -5.387927019 -2.950427019 53 2.499572981 -5.387927019 54 -6.062927019 2.499572981 55 -2.025427019 -6.062927019 56 1.484355590 -2.025427019 57 -7.101358696 1.484355590 58 2.484355590 -7.101358696 59 3.641498447 2.484355590 60 -2.248291925 3.641498447 61 -1.423291925 -2.248291925 62 2.676708075 -1.423291925 63 -4.985791925 2.676708075 64 4.576708075 -4.985791925 65 1.364208075 4.576708075 66 -2.998291925 1.364208075 67 1.239208075 -2.998291925 68 0.848990683 1.239208075 69 1.263276398 0.848990683 70 2.548990683 1.263276398 71 0.306133540 2.548990683 72 1.516343168 0.306133540 73 -0.358656832 1.516343168 74 3.241343168 -0.358656832 75 -1.821156832 3.241343168 76 1.541343168 -1.821156832 77 1.628843168 1.541343168 78 1.766343168 1.628843168 79 1.903843168 1.766343168 80 -3.386374224 1.903843168 81 3.327911491 -3.386374224 82 1.213625776 3.327911491 83 -3.429231366 1.213625776 84 2.880978261 -3.429231366 85 4.305978261 2.880978261 86 -4.994021739 4.305978261 87 4.843478261 -4.994021739 88 -1.494021739 4.843478261 89 -2.106521739 -1.494021739 90 1.830978261 -2.106521739 91 -2.931521739 1.830978261 92 NA -2.931521739 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 5.034510870 5.009510870 [2,] 5.534510870 5.034510870 [3,] -1.127989130 5.534510870 [4,] 2.834510870 -1.127989130 [5,] 0.322010870 2.834510870 [6,] -2.040489130 0.322010870 [7,] 2.097010870 -2.040489130 [8,] -4.693206522 2.097010870 [9,] -0.678920807 -4.693206522 [10,] 0.006793478 -0.678920807 [11,] -3.736063665 0.006793478 [12,] -1.625854037 -3.736063665 [13,] -1.500854037 -1.625854037 [14,] -2.200854037 -1.500854037 [15,] 2.136645963 -2.200854037 [16,] 1.799145963 2.136645963 [17,] -3.013354037 1.799145963 [18,] 1.124145963 -3.013354037 [19,] -0.738354037 1.124145963 [20,] -1.128571429 -0.738354037 [21,] 2.285714286 -1.128571429 [22,] -2.028571429 2.285714286 [23,] -3.671428571 -2.028571429 [24,] 1.957802795 -3.671428571 [25,] 0.682802795 1.957802795 [26,] -2.517197205 0.682802795 [27,] 2.520302795 -2.517197205 [28,] -0.717197205 2.520302795 [29,] -2.729697205 -0.717197205 [30,] 3.207802795 -2.729697205 [31,] -2.054697205 3.207802795 [32,] 1.455085404 -2.054697205 [33,] 1.569371118 1.455085404 [34,] -3.844914596 1.569371118 [35,] 2.512228261 -3.844914596 [36,] -3.577562112 2.512228261 [37,] -2.252562112 -3.577562112 [38,] 2.947437888 -2.252562112 [39,] 1.384937888 2.947437888 [40,] -3.152562112 1.384937888 [41,] 2.034937888 -3.152562112 [42,] 3.172437888 2.034937888 [43,] 2.509937888 3.172437888 [44,] 5.419720497 2.509937888 [45,] -0.665993789 5.419720497 [46,] -0.380279503 -0.665993789 [47,] 4.376863354 -0.380279503 [48,] -3.912927019 4.376863354 [49,] -4.487927019 -3.912927019 [50,] -4.687927019 -4.487927019 [51,] -2.950427019 -4.687927019 [52,] -5.387927019 -2.950427019 [53,] 2.499572981 -5.387927019 [54,] -6.062927019 2.499572981 [55,] -2.025427019 -6.062927019 [56,] 1.484355590 -2.025427019 [57,] -7.101358696 1.484355590 [58,] 2.484355590 -7.101358696 [59,] 3.641498447 2.484355590 [60,] -2.248291925 3.641498447 [61,] -1.423291925 -2.248291925 [62,] 2.676708075 -1.423291925 [63,] -4.985791925 2.676708075 [64,] 4.576708075 -4.985791925 [65,] 1.364208075 4.576708075 [66,] -2.998291925 1.364208075 [67,] 1.239208075 -2.998291925 [68,] 0.848990683 1.239208075 [69,] 1.263276398 0.848990683 [70,] 2.548990683 1.263276398 [71,] 0.306133540 2.548990683 [72,] 1.516343168 0.306133540 [73,] -0.358656832 1.516343168 [74,] 3.241343168 -0.358656832 [75,] -1.821156832 3.241343168 [76,] 1.541343168 -1.821156832 [77,] 1.628843168 1.541343168 [78,] 1.766343168 1.628843168 [79,] 1.903843168 1.766343168 [80,] -3.386374224 1.903843168 [81,] 3.327911491 -3.386374224 [82,] 1.213625776 3.327911491 [83,] -3.429231366 1.213625776 [84,] 2.880978261 -3.429231366 [85,] 4.305978261 2.880978261 [86,] -4.994021739 4.305978261 [87,] 4.843478261 -4.994021739 [88,] -1.494021739 4.843478261 [89,] -2.106521739 -1.494021739 [90,] 1.830978261 -2.106521739 [91,] -2.931521739 1.830978261 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 5.034510870 5.009510870 2 5.534510870 5.034510870 3 -1.127989130 5.534510870 4 2.834510870 -1.127989130 5 0.322010870 2.834510870 6 -2.040489130 0.322010870 7 2.097010870 -2.040489130 8 -4.693206522 2.097010870 9 -0.678920807 -4.693206522 10 0.006793478 -0.678920807 11 -3.736063665 0.006793478 12 -1.625854037 -3.736063665 13 -1.500854037 -1.625854037 14 -2.200854037 -1.500854037 15 2.136645963 -2.200854037 16 1.799145963 2.136645963 17 -3.013354037 1.799145963 18 1.124145963 -3.013354037 19 -0.738354037 1.124145963 20 -1.128571429 -0.738354037 21 2.285714286 -1.128571429 22 -2.028571429 2.285714286 23 -3.671428571 -2.028571429 24 1.957802795 -3.671428571 25 0.682802795 1.957802795 26 -2.517197205 0.682802795 27 2.520302795 -2.517197205 28 -0.717197205 2.520302795 29 -2.729697205 -0.717197205 30 3.207802795 -2.729697205 31 -2.054697205 3.207802795 32 1.455085404 -2.054697205 33 1.569371118 1.455085404 34 -3.844914596 1.569371118 35 2.512228261 -3.844914596 36 -3.577562112 2.512228261 37 -2.252562112 -3.577562112 38 2.947437888 -2.252562112 39 1.384937888 2.947437888 40 -3.152562112 1.384937888 41 2.034937888 -3.152562112 42 3.172437888 2.034937888 43 2.509937888 3.172437888 44 5.419720497 2.509937888 45 -0.665993789 5.419720497 46 -0.380279503 -0.665993789 47 4.376863354 -0.380279503 48 -3.912927019 4.376863354 49 -4.487927019 -3.912927019 50 -4.687927019 -4.487927019 51 -2.950427019 -4.687927019 52 -5.387927019 -2.950427019 53 2.499572981 -5.387927019 54 -6.062927019 2.499572981 55 -2.025427019 -6.062927019 56 1.484355590 -2.025427019 57 -7.101358696 1.484355590 58 2.484355590 -7.101358696 59 3.641498447 2.484355590 60 -2.248291925 3.641498447 61 -1.423291925 -2.248291925 62 2.676708075 -1.423291925 63 -4.985791925 2.676708075 64 4.576708075 -4.985791925 65 1.364208075 4.576708075 66 -2.998291925 1.364208075 67 1.239208075 -2.998291925 68 0.848990683 1.239208075 69 1.263276398 0.848990683 70 2.548990683 1.263276398 71 0.306133540 2.548990683 72 1.516343168 0.306133540 73 -0.358656832 1.516343168 74 3.241343168 -0.358656832 75 -1.821156832 3.241343168 76 1.541343168 -1.821156832 77 1.628843168 1.541343168 78 1.766343168 1.628843168 79 1.903843168 1.766343168 80 -3.386374224 1.903843168 81 3.327911491 -3.386374224 82 1.213625776 3.327911491 83 -3.429231366 1.213625776 84 2.880978261 -3.429231366 85 4.305978261 2.880978261 86 -4.994021739 4.305978261 87 4.843478261 -4.994021739 88 -1.494021739 4.843478261 89 -2.106521739 -1.494021739 90 1.830978261 -2.106521739 91 -2.931521739 1.830978261 > 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/freestat/rcomp/tmp/7oggz1229040984.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/freestat/rcomp/tmp/8k6hm1229040984.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/freestat/rcomp/tmp/9xgpe1229040984.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/freestat/rcomp/tmp/10ylbf1229040984.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11v9kc1229040984.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/freestat/rcomp/tmp/122lz71229040984.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/freestat/rcomp/tmp/13ipgf1229040984.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/freestat/rcomp/tmp/14t8yd1229040984.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/freestat/rcomp/tmp/159fbw1229040984.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/freestat/rcomp/tmp/16lvcm1229040984.tab") + } > > system("convert tmp/1zns01229040984.ps tmp/1zns01229040984.png") > system("convert tmp/23ujf1229040984.ps tmp/23ujf1229040984.png") > system("convert tmp/3q6mh1229040984.ps tmp/3q6mh1229040984.png") > system("convert tmp/469bf1229040984.ps tmp/469bf1229040984.png") > system("convert tmp/5ygtg1229040984.ps tmp/5ygtg1229040984.png") > system("convert tmp/6raym1229040984.ps tmp/6raym1229040984.png") > system("convert tmp/7oggz1229040984.ps tmp/7oggz1229040984.png") > system("convert tmp/8k6hm1229040984.ps tmp/8k6hm1229040984.png") > system("convert tmp/9xgpe1229040984.ps tmp/9xgpe1229040984.png") > system("convert tmp/10ylbf1229040984.ps tmp/10ylbf1229040984.png") > > > proc.time() user system elapsed 4.404 2.663 5.035