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(99.9 + ,11554.5 + ,98.6 + ,13182.1 + ,107.2 + ,14800.1 + ,95.7 + ,12150.7 + ,93.7 + ,14478.2 + ,106.7 + ,13253.9 + ,86.7 + ,12036.8 + ,95.3 + ,12653.2 + ,99.3 + ,14035.4 + ,101.8 + ,14571.4 + ,96 + ,15400.9 + ,91.7 + ,14283.2 + ,95.3 + ,14485.3 + ,96.6 + ,14196.3 + ,107.2 + ,15559.1 + ,108 + ,13767.4 + ,98.4 + ,14634 + ,103.1 + ,14381.1 + ,81.1 + ,12509.9 + ,96.6 + ,12122.3 + ,103.7 + ,13122.3 + ,106.6 + ,13908.7 + ,97.6 + ,13456.5 + ,87.6 + ,12441.6 + ,99.4 + ,12953 + ,98.5 + ,13057.2 + ,105.2 + ,14350.1 + ,104.6 + ,13830.2 + ,97.5 + ,13755.5 + ,108.9 + ,13574.4 + ,86.8 + ,12802.6 + ,88.9 + ,11737.3 + ,110.3 + ,13850.2 + ,114.8 + ,15081.8 + ,94.6 + ,13653.3 + ,92 + ,14019.1 + ,93.8 + ,13962 + ,93.8 + ,13768.7 + ,107.6 + ,14747.1 + ,101 + ,13858.1 + ,95.4 + ,13188 + ,96.5 + ,13693.1 + ,89.2 + ,12970 + ,87.1 + ,11392.8 + ,110.5 + ,13985.2 + ,110.8 + ,14994.7 + ,104.2 + ,13584.7 + ,88.9 + ,14257.8 + ,89.8 + ,13553.4 + ,90 + ,14007.3 + ,93.9 + ,16535.8 + ,91.3 + ,14721.4 + ,87.8 + ,13664.6 + ,99.7 + ,16405.9 + ,73.5 + ,13829.4 + ,79.2 + ,13735.6 + ,96.9 + ,15870.5 + ,95.2 + ,15962.4 + ,95.6 + ,15744.1 + ,89.7 + ,16083.7 + ,92.8 + ,14863.9 + ,88 + ,15533.1 + ,101.1 + ,17473.1 + ,92.7 + ,15925.5 + ,95.8 + ,15573.7 + ,103.8 + ,17495 + ,81.8 + ,14155.8 + ,87.1 + ,14913.9 + ,105.9 + ,17250.4 + ,108.1 + ,15879.8 + ,102.6 + ,17647.8 + ,93.7 + ,17749.9) + ,dim=c(2 + ,72) + ,dimnames=list(c('metallurgie' + ,'Invoer') + ,1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('metallurgie','Invoer'),1:72)) > 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 metallurgie Invoer M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 99.9 11554.5 1 0 0 0 0 0 0 0 0 0 0 1 2 98.6 13182.1 0 1 0 0 0 0 0 0 0 0 0 2 3 107.2 14800.1 0 0 1 0 0 0 0 0 0 0 0 3 4 95.7 12150.7 0 0 0 1 0 0 0 0 0 0 0 4 5 93.7 14478.2 0 0 0 0 1 0 0 0 0 0 0 5 6 106.7 13253.9 0 0 0 0 0 1 0 0 0 0 0 6 7 86.7 12036.8 0 0 0 0 0 0 1 0 0 0 0 7 8 95.3 12653.2 0 0 0 0 0 0 0 1 0 0 0 8 9 99.3 14035.4 0 0 0 0 0 0 0 0 1 0 0 9 10 101.8 14571.4 0 0 0 0 0 0 0 0 0 1 0 10 11 96.0 15400.9 0 0 0 0 0 0 0 0 0 0 1 11 12 91.7 14283.2 0 0 0 0 0 0 0 0 0 0 0 12 13 95.3 14485.3 1 0 0 0 0 0 0 0 0 0 0 13 14 96.6 14196.3 0 1 0 0 0 0 0 0 0 0 0 14 15 107.2 15559.1 0 0 1 0 0 0 0 0 0 0 0 15 16 108.0 13767.4 0 0 0 1 0 0 0 0 0 0 0 16 17 98.4 14634.0 0 0 0 0 1 0 0 0 0 0 0 17 18 103.1 14381.1 0 0 0 0 0 1 0 0 0 0 0 18 19 81.1 12509.9 0 0 0 0 0 0 1 0 0 0 0 19 20 96.6 12122.3 0 0 0 0 0 0 0 1 0 0 0 20 21 103.7 13122.3 0 0 0 0 0 0 0 0 1 0 0 21 22 106.6 13908.7 0 0 0 0 0 0 0 0 0 1 0 22 23 97.6 13456.5 0 0 0 0 0 0 0 0 0 0 1 23 24 87.6 12441.6 0 0 0 0 0 0 0 0 0 0 0 24 25 99.4 12953.0 1 0 0 0 0 0 0 0 0 0 0 25 26 98.5 13057.2 0 1 0 0 0 0 0 0 0 0 0 26 27 105.2 14350.1 0 0 1 0 0 0 0 0 0 0 0 27 28 104.6 13830.2 0 0 0 1 0 0 0 0 0 0 0 28 29 97.5 13755.5 0 0 0 0 1 0 0 0 0 0 0 29 30 108.9 13574.4 0 0 0 0 0 1 0 0 0 0 0 30 31 86.8 12802.6 0 0 0 0 0 0 1 0 0 0 0 31 32 88.9 11737.3 0 0 0 0 0 0 0 1 0 0 0 32 33 110.3 13850.2 0 0 0 0 0 0 0 0 1 0 0 33 34 114.8 15081.8 0 0 0 0 0 0 0 0 0 1 0 34 35 94.6 13653.3 0 0 0 0 0 0 0 0 0 0 1 35 36 92.0 14019.1 0 0 0 0 0 0 0 0 0 0 0 36 37 93.8 13962.0 1 0 0 0 0 0 0 0 0 0 0 37 38 93.8 13768.7 0 1 0 0 0 0 0 0 0 0 0 38 39 107.6 14747.1 0 0 1 0 0 0 0 0 0 0 0 39 40 101.0 13858.1 0 0 0 1 0 0 0 0 0 0 0 40 41 95.4 13188.0 0 0 0 0 1 0 0 0 0 0 0 41 42 96.5 13693.1 0 0 0 0 0 1 0 0 0 0 0 42 43 89.2 12970.0 0 0 0 0 0 0 1 0 0 0 0 43 44 87.1 11392.8 0 0 0 0 0 0 0 1 0 0 0 44 45 110.5 13985.2 0 0 0 0 0 0 0 0 1 0 0 45 46 110.8 14994.7 0 0 0 0 0 0 0 0 0 1 0 46 47 104.2 13584.7 0 0 0 0 0 0 0 0 0 0 1 47 48 88.9 14257.8 0 0 0 0 0 0 0 0 0 0 0 48 49 89.8 13553.4 1 0 0 0 0 0 0 0 0 0 0 49 50 90.0 14007.3 0 1 0 0 0 0 0 0 0 0 0 50 51 93.9 16535.8 0 0 1 0 0 0 0 0 0 0 0 51 52 91.3 14721.4 0 0 0 1 0 0 0 0 0 0 0 52 53 87.8 13664.6 0 0 0 0 1 0 0 0 0 0 0 53 54 99.7 16405.9 0 0 0 0 0 1 0 0 0 0 0 54 55 73.5 13829.4 0 0 0 0 0 0 1 0 0 0 0 55 56 79.2 13735.6 0 0 0 0 0 0 0 1 0 0 0 56 57 96.9 15870.5 0 0 0 0 0 0 0 0 1 0 0 57 58 95.2 15962.4 0 0 0 0 0 0 0 0 0 1 0 58 59 95.6 15744.1 0 0 0 0 0 0 0 0 0 0 1 59 60 89.7 16083.7 0 0 0 0 0 0 0 0 0 0 0 60 61 92.8 14863.9 1 0 0 0 0 0 0 0 0 0 0 61 62 88.0 15533.1 0 1 0 0 0 0 0 0 0 0 0 62 63 101.1 17473.1 0 0 1 0 0 0 0 0 0 0 0 63 64 92.7 15925.5 0 0 0 1 0 0 0 0 0 0 0 64 65 95.8 15573.7 0 0 0 0 1 0 0 0 0 0 0 65 66 103.8 17495.0 0 0 0 0 0 1 0 0 0 0 0 66 67 81.8 14155.8 0 0 0 0 0 0 1 0 0 0 0 67 68 87.1 14913.9 0 0 0 0 0 0 0 1 0 0 0 68 69 105.9 17250.4 0 0 0 0 0 0 0 0 1 0 0 69 70 108.1 15879.8 0 0 0 0 0 0 0 0 0 1 0 70 71 102.6 17647.8 0 0 0 0 0 0 0 0 0 0 1 71 72 93.7 17749.9 0 0 0 0 0 0 0 0 0 0 0 72 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Invoer M1 M2 M3 M4 9.295e+01 8.544e-05 3.725e+00 2.861e+00 1.226e+01 7.659e+00 M5 M6 M7 M8 M9 M10 3.614e+00 1.200e+01 -7.697e+00 -1.736e+00 1.359e+01 1.542e+01 M11 t 7.738e+00 -8.614e-02 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -9.543 -3.609 0.504 3.549 8.065 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.295e+01 9.189e+00 10.116 2.02e-14 *** Invoer 8.544e-05 6.806e-04 0.126 0.90053 M1 3.725e+00 2.882e+00 1.293 0.20128 M2 2.861e+00 2.844e+00 1.006 0.31863 M3 1.226e+01 2.932e+00 4.182 9.90e-05 *** M4 7.659e+00 2.839e+00 2.698 0.00913 ** M5 3.614e+00 2.829e+00 1.277 0.20653 M6 1.200e+01 2.825e+00 4.248 7.91e-05 *** M7 -7.697e+00 3.009e+00 -2.558 0.01316 * M8 -1.736e+00 3.094e+00 -0.561 0.57688 M9 1.359e+01 2.816e+00 4.824 1.06e-05 *** M10 1.542e+01 2.825e+00 5.459 1.04e-06 *** M11 7.738e+00 2.817e+00 2.747 0.00800 ** t -8.614e-02 3.975e-02 -2.167 0.03435 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.876 on 58 degrees of freedom Multiple R-squared: 0.7139, Adjusted R-squared: 0.6498 F-statistic: 11.13 on 13 and 58 DF, p-value: 2.003e-11 > 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.62775700 0.74448600 0.372242998 [2,] 0.54904182 0.90191636 0.450958182 [3,] 0.54827890 0.90344220 0.451721100 [4,] 0.42479892 0.84959783 0.575201084 [5,] 0.33148593 0.66297187 0.668514067 [6,] 0.25123040 0.50246081 0.748769595 [7,] 0.19510015 0.39020029 0.804899853 [8,] 0.20832511 0.41665021 0.791674894 [9,] 0.14162824 0.28325648 0.858371758 [10,] 0.09420613 0.18841226 0.905793872 [11,] 0.06784265 0.13568530 0.932157352 [12,] 0.04737326 0.09474652 0.952626739 [13,] 0.02770436 0.05540872 0.972295639 [14,] 0.02156643 0.04313286 0.978433572 [15,] 0.01252182 0.02504364 0.987478181 [16,] 0.02311645 0.04623291 0.976883547 [17,] 0.03262903 0.06525805 0.967370974 [18,] 0.05747443 0.11494886 0.942525572 [19,] 0.05672953 0.11345905 0.943270475 [20,] 0.03592400 0.07184799 0.964076005 [21,] 0.03888993 0.07777985 0.961110074 [22,] 0.03472090 0.06944181 0.965279096 [23,] 0.03376093 0.06752186 0.966239071 [24,] 0.03486585 0.06973170 0.965134148 [25,] 0.02380183 0.04760365 0.976198174 [26,] 0.04640417 0.09280835 0.953595827 [27,] 0.12415280 0.24830559 0.875847204 [28,] 0.11222482 0.22444963 0.887775183 [29,] 0.19702133 0.39404267 0.802978667 [30,] 0.88076307 0.23847386 0.119236930 [31,] 0.95299173 0.09401654 0.047008268 [32,] 0.93597109 0.12805781 0.064028907 [33,] 0.92589281 0.14821439 0.074107195 [34,] 0.98027945 0.03944110 0.019720548 [35,] 0.97283135 0.05433729 0.027168647 [36,] 0.99065144 0.01869712 0.009348561 [37,] 0.98347502 0.03304996 0.016524982 [38,] 0.98382147 0.03235706 0.016178531 [39,] 0.97325877 0.05348245 0.026741227 > postscript(file="/var/www/html/freestat/rcomp/tmp/18qcc1229765196.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/2b0vi1229765196.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/3se0s1229765196.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/4brdo1229765196.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/54lzn1229765196.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 = 72 Frequency = 1 1 2 3 4 5 6 2.32077742 1.83216255 0.98234198 -5.60580078 -3.67318526 1.13140044 7 8 9 10 11 12 1.01921621 3.69163570 -7.66185843 -6.95845271 -5.05897577 -1.43942636 13 14 15 16 17 18 -1.49600788 0.77913967 1.95112447 7.58969619 2.04713718 -1.53127764 19 20 21 22 23 24 -3.58757280 6.07063269 -2.15020465 -1.06819417 -2.25920335 -4.34843761 25 26 27 28 29 30 3.76855297 3.81010384 1.08806119 5.21796494 2.25583459 5.37128487 31 32 33 34 35 36 3.12105233 -0.56283663 5.42123515 8.06520586 -4.24238413 0.95040877 37 38 39 40 41 42 -0.88402561 0.08294492 4.48777449 2.64921570 1.23795885 -6.00522270 43 44 45 46 47 48 6.54038361 -1.29976644 6.64333483 5.10628271 6.39711200 -1.13635212 49 50 51 52 53 54 -3.81547844 -2.70380742 -8.33142495 -6.09091365 -5.36912922 -2.00338116 55 56 57 58 59 60 -8.19941250 -8.36631052 -6.08411853 -9.54276702 -1.35376161 0.54126992 61 62 63 64 65 66 0.10618155 -3.80054357 -0.17787718 -3.76016239 3.50138385 3.03719619 67 68 69 70 71 72 1.10633315 0.46664519 3.83161164 4.39792533 6.51721286 5.43253740 > postscript(file="/var/www/html/freestat/rcomp/tmp/6w4vq1229765196.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 = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 2.32077742 NA 1 1.83216255 2.32077742 2 0.98234198 1.83216255 3 -5.60580078 0.98234198 4 -3.67318526 -5.60580078 5 1.13140044 -3.67318526 6 1.01921621 1.13140044 7 3.69163570 1.01921621 8 -7.66185843 3.69163570 9 -6.95845271 -7.66185843 10 -5.05897577 -6.95845271 11 -1.43942636 -5.05897577 12 -1.49600788 -1.43942636 13 0.77913967 -1.49600788 14 1.95112447 0.77913967 15 7.58969619 1.95112447 16 2.04713718 7.58969619 17 -1.53127764 2.04713718 18 -3.58757280 -1.53127764 19 6.07063269 -3.58757280 20 -2.15020465 6.07063269 21 -1.06819417 -2.15020465 22 -2.25920335 -1.06819417 23 -4.34843761 -2.25920335 24 3.76855297 -4.34843761 25 3.81010384 3.76855297 26 1.08806119 3.81010384 27 5.21796494 1.08806119 28 2.25583459 5.21796494 29 5.37128487 2.25583459 30 3.12105233 5.37128487 31 -0.56283663 3.12105233 32 5.42123515 -0.56283663 33 8.06520586 5.42123515 34 -4.24238413 8.06520586 35 0.95040877 -4.24238413 36 -0.88402561 0.95040877 37 0.08294492 -0.88402561 38 4.48777449 0.08294492 39 2.64921570 4.48777449 40 1.23795885 2.64921570 41 -6.00522270 1.23795885 42 6.54038361 -6.00522270 43 -1.29976644 6.54038361 44 6.64333483 -1.29976644 45 5.10628271 6.64333483 46 6.39711200 5.10628271 47 -1.13635212 6.39711200 48 -3.81547844 -1.13635212 49 -2.70380742 -3.81547844 50 -8.33142495 -2.70380742 51 -6.09091365 -8.33142495 52 -5.36912922 -6.09091365 53 -2.00338116 -5.36912922 54 -8.19941250 -2.00338116 55 -8.36631052 -8.19941250 56 -6.08411853 -8.36631052 57 -9.54276702 -6.08411853 58 -1.35376161 -9.54276702 59 0.54126992 -1.35376161 60 0.10618155 0.54126992 61 -3.80054357 0.10618155 62 -0.17787718 -3.80054357 63 -3.76016239 -0.17787718 64 3.50138385 -3.76016239 65 3.03719619 3.50138385 66 1.10633315 3.03719619 67 0.46664519 1.10633315 68 3.83161164 0.46664519 69 4.39792533 3.83161164 70 6.51721286 4.39792533 71 5.43253740 6.51721286 72 NA 5.43253740 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 1.83216255 2.32077742 [2,] 0.98234198 1.83216255 [3,] -5.60580078 0.98234198 [4,] -3.67318526 -5.60580078 [5,] 1.13140044 -3.67318526 [6,] 1.01921621 1.13140044 [7,] 3.69163570 1.01921621 [8,] -7.66185843 3.69163570 [9,] -6.95845271 -7.66185843 [10,] -5.05897577 -6.95845271 [11,] -1.43942636 -5.05897577 [12,] -1.49600788 -1.43942636 [13,] 0.77913967 -1.49600788 [14,] 1.95112447 0.77913967 [15,] 7.58969619 1.95112447 [16,] 2.04713718 7.58969619 [17,] -1.53127764 2.04713718 [18,] -3.58757280 -1.53127764 [19,] 6.07063269 -3.58757280 [20,] -2.15020465 6.07063269 [21,] -1.06819417 -2.15020465 [22,] -2.25920335 -1.06819417 [23,] -4.34843761 -2.25920335 [24,] 3.76855297 -4.34843761 [25,] 3.81010384 3.76855297 [26,] 1.08806119 3.81010384 [27,] 5.21796494 1.08806119 [28,] 2.25583459 5.21796494 [29,] 5.37128487 2.25583459 [30,] 3.12105233 5.37128487 [31,] -0.56283663 3.12105233 [32,] 5.42123515 -0.56283663 [33,] 8.06520586 5.42123515 [34,] -4.24238413 8.06520586 [35,] 0.95040877 -4.24238413 [36,] -0.88402561 0.95040877 [37,] 0.08294492 -0.88402561 [38,] 4.48777449 0.08294492 [39,] 2.64921570 4.48777449 [40,] 1.23795885 2.64921570 [41,] -6.00522270 1.23795885 [42,] 6.54038361 -6.00522270 [43,] -1.29976644 6.54038361 [44,] 6.64333483 -1.29976644 [45,] 5.10628271 6.64333483 [46,] 6.39711200 5.10628271 [47,] -1.13635212 6.39711200 [48,] -3.81547844 -1.13635212 [49,] -2.70380742 -3.81547844 [50,] -8.33142495 -2.70380742 [51,] -6.09091365 -8.33142495 [52,] -5.36912922 -6.09091365 [53,] -2.00338116 -5.36912922 [54,] -8.19941250 -2.00338116 [55,] -8.36631052 -8.19941250 [56,] -6.08411853 -8.36631052 [57,] -9.54276702 -6.08411853 [58,] -1.35376161 -9.54276702 [59,] 0.54126992 -1.35376161 [60,] 0.10618155 0.54126992 [61,] -3.80054357 0.10618155 [62,] -0.17787718 -3.80054357 [63,] -3.76016239 -0.17787718 [64,] 3.50138385 -3.76016239 [65,] 3.03719619 3.50138385 [66,] 1.10633315 3.03719619 [67,] 0.46664519 1.10633315 [68,] 3.83161164 0.46664519 [69,] 4.39792533 3.83161164 [70,] 6.51721286 4.39792533 [71,] 5.43253740 6.51721286 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 1.83216255 2.32077742 2 0.98234198 1.83216255 3 -5.60580078 0.98234198 4 -3.67318526 -5.60580078 5 1.13140044 -3.67318526 6 1.01921621 1.13140044 7 3.69163570 1.01921621 8 -7.66185843 3.69163570 9 -6.95845271 -7.66185843 10 -5.05897577 -6.95845271 11 -1.43942636 -5.05897577 12 -1.49600788 -1.43942636 13 0.77913967 -1.49600788 14 1.95112447 0.77913967 15 7.58969619 1.95112447 16 2.04713718 7.58969619 17 -1.53127764 2.04713718 18 -3.58757280 -1.53127764 19 6.07063269 -3.58757280 20 -2.15020465 6.07063269 21 -1.06819417 -2.15020465 22 -2.25920335 -1.06819417 23 -4.34843761 -2.25920335 24 3.76855297 -4.34843761 25 3.81010384 3.76855297 26 1.08806119 3.81010384 27 5.21796494 1.08806119 28 2.25583459 5.21796494 29 5.37128487 2.25583459 30 3.12105233 5.37128487 31 -0.56283663 3.12105233 32 5.42123515 -0.56283663 33 8.06520586 5.42123515 34 -4.24238413 8.06520586 35 0.95040877 -4.24238413 36 -0.88402561 0.95040877 37 0.08294492 -0.88402561 38 4.48777449 0.08294492 39 2.64921570 4.48777449 40 1.23795885 2.64921570 41 -6.00522270 1.23795885 42 6.54038361 -6.00522270 43 -1.29976644 6.54038361 44 6.64333483 -1.29976644 45 5.10628271 6.64333483 46 6.39711200 5.10628271 47 -1.13635212 6.39711200 48 -3.81547844 -1.13635212 49 -2.70380742 -3.81547844 50 -8.33142495 -2.70380742 51 -6.09091365 -8.33142495 52 -5.36912922 -6.09091365 53 -2.00338116 -5.36912922 54 -8.19941250 -2.00338116 55 -8.36631052 -8.19941250 56 -6.08411853 -8.36631052 57 -9.54276702 -6.08411853 58 -1.35376161 -9.54276702 59 0.54126992 -1.35376161 60 0.10618155 0.54126992 61 -3.80054357 0.10618155 62 -0.17787718 -3.80054357 63 -3.76016239 -0.17787718 64 3.50138385 -3.76016239 65 3.03719619 3.50138385 66 1.10633315 3.03719619 67 0.46664519 1.10633315 68 3.83161164 0.46664519 69 4.39792533 3.83161164 70 6.51721286 4.39792533 71 5.43253740 6.51721286 > 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/7h7aq1229765196.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/8tnn71229765196.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/9fycm1229765196.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/10fr711229765196.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/11w5j21229765196.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/12aa011229765196.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/13t5dh1229765196.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/14fdf41229765196.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/155ifb1229765196.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/16o1q11229765196.tab") + } > > system("convert tmp/18qcc1229765196.ps tmp/18qcc1229765196.png") > system("convert tmp/2b0vi1229765196.ps tmp/2b0vi1229765196.png") > system("convert tmp/3se0s1229765196.ps tmp/3se0s1229765196.png") > system("convert tmp/4brdo1229765196.ps tmp/4brdo1229765196.png") > system("convert tmp/54lzn1229765196.ps tmp/54lzn1229765196.png") > system("convert tmp/6w4vq1229765196.ps tmp/6w4vq1229765196.png") > system("convert tmp/7h7aq1229765196.ps tmp/7h7aq1229765196.png") > system("convert tmp/8tnn71229765196.ps tmp/8tnn71229765196.png") > system("convert tmp/9fycm1229765196.ps tmp/9fycm1229765196.png") > system("convert tmp/10fr711229765196.ps tmp/10fr711229765196.png") > > > proc.time() user system elapsed 3.850 2.524 4.348