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(2172 + ,2155 + ,3016 + ,0 + ,2150 + ,2172 + ,2155 + ,0 + ,2533 + ,2150 + ,2172 + ,0 + ,2058 + ,2533 + ,2150 + ,0 + ,2160 + ,2058 + ,2533 + ,0 + ,2260 + ,2160 + ,2058 + ,0 + ,2498 + ,2260 + ,2160 + ,0 + ,2695 + ,2498 + ,2260 + ,0 + ,2799 + ,2695 + ,2498 + ,0 + ,2946 + ,2799 + ,2695 + ,0 + ,2930 + ,2946 + ,2799 + ,0 + ,2318 + ,2930 + ,2946 + ,0 + ,2540 + ,2318 + ,2930 + ,0 + ,2570 + ,2540 + ,2318 + ,0 + ,2669 + ,2570 + ,2540 + ,0 + ,2450 + ,2669 + ,2570 + ,0 + ,2842 + ,2450 + ,2669 + ,0 + ,3440 + ,2842 + ,2450 + ,0 + ,2678 + ,3440 + ,2842 + ,0 + ,2981 + ,2678 + ,3440 + ,0 + ,2260 + ,2981 + ,2678 + ,0 + ,2844 + ,2260 + ,2981 + ,0 + ,2546 + ,2844 + ,2260 + ,0 + ,2456 + ,2546 + ,2844 + ,0 + ,2295 + ,2456 + ,2546 + ,0 + ,2379 + ,2295 + ,2456 + ,0 + ,2479 + ,2379 + ,2295 + ,0 + ,2057 + ,2479 + ,2379 + ,0 + ,2280 + ,2057 + ,2479 + ,0 + ,2351 + ,2280 + ,2057 + ,0 + ,2276 + ,2351 + ,2280 + ,0 + ,2548 + ,2276 + ,2351 + ,0 + ,2311 + ,2548 + ,2276 + ,0 + ,2201 + ,2311 + ,2548 + ,0 + ,2725 + ,2201 + ,2311 + ,1 + ,2408 + ,2725 + ,2201 + ,1 + ,2139 + ,2408 + ,2725 + ,1 + ,1898 + ,2139 + ,2408 + ,1 + ,2537 + ,1898 + ,2139 + ,1 + ,2068 + ,2537 + ,1898 + ,1 + ,2063 + ,2068 + ,2537 + ,1 + ,2520 + ,2063 + ,2068 + ,1 + ,2434 + ,2520 + ,2063 + ,1 + ,2190 + ,2434 + ,2520 + ,1 + ,2794 + ,2190 + ,2434 + ,1 + ,2070 + ,2794 + ,2190 + ,1 + ,2615 + ,2070 + ,2794 + ,1 + ,2265 + ,2615 + ,2070 + ,1 + ,2139 + ,2265 + ,2615 + ,1 + ,2428 + ,2139 + ,2265 + ,1 + ,2137 + ,2428 + ,2139 + ,1 + ,1823 + ,2137 + ,2428 + ,1 + ,2063 + ,1823 + ,2137 + ,1 + ,1806 + ,2063 + ,1823 + ,1 + ,1758 + ,1806 + ,2063 + ,1 + ,2243 + ,1758 + ,1806 + ,1 + ,1993 + ,2243 + ,1758 + ,1 + ,1932 + ,1993 + ,2243 + ,1 + ,2465 + ,1932 + ,1993 + ,1) + ,dim=c(4 + ,59) + ,dimnames=list(c('y' + ,'y(t-1)' + ,'y(t-2)' + ,'x') + ,1:59)) > y <- array(NA,dim=c(4,59),dimnames=list(c('y','y(t-1)','y(t-2)','x'),1:59)) > 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 y(t-1) y(t-2) x M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 2172 2155 3016 0 1 0 0 0 0 0 0 0 0 0 0 1 2 2150 2172 2155 0 0 1 0 0 0 0 0 0 0 0 0 2 3 2533 2150 2172 0 0 0 1 0 0 0 0 0 0 0 0 3 4 2058 2533 2150 0 0 0 0 1 0 0 0 0 0 0 0 4 5 2160 2058 2533 0 0 0 0 0 1 0 0 0 0 0 0 5 6 2260 2160 2058 0 0 0 0 0 0 1 0 0 0 0 0 6 7 2498 2260 2160 0 0 0 0 0 0 0 1 0 0 0 0 7 8 2695 2498 2260 0 0 0 0 0 0 0 0 1 0 0 0 8 9 2799 2695 2498 0 0 0 0 0 0 0 0 0 1 0 0 9 10 2946 2799 2695 0 0 0 0 0 0 0 0 0 0 1 0 10 11 2930 2946 2799 0 0 0 0 0 0 0 0 0 0 0 1 11 12 2318 2930 2946 0 0 0 0 0 0 0 0 0 0 0 0 12 13 2540 2318 2930 0 1 0 0 0 0 0 0 0 0 0 0 13 14 2570 2540 2318 0 0 1 0 0 0 0 0 0 0 0 0 14 15 2669 2570 2540 0 0 0 1 0 0 0 0 0 0 0 0 15 16 2450 2669 2570 0 0 0 0 1 0 0 0 0 0 0 0 16 17 2842 2450 2669 0 0 0 0 0 1 0 0 0 0 0 0 17 18 3440 2842 2450 0 0 0 0 0 0 1 0 0 0 0 0 18 19 2678 3440 2842 0 0 0 0 0 0 0 1 0 0 0 0 19 20 2981 2678 3440 0 0 0 0 0 0 0 0 1 0 0 0 20 21 2260 2981 2678 0 0 0 0 0 0 0 0 0 1 0 0 21 22 2844 2260 2981 0 0 0 0 0 0 0 0 0 0 1 0 22 23 2546 2844 2260 0 0 0 0 0 0 0 0 0 0 0 1 23 24 2456 2546 2844 0 0 0 0 0 0 0 0 0 0 0 0 24 25 2295 2456 2546 0 1 0 0 0 0 0 0 0 0 0 0 25 26 2379 2295 2456 0 0 1 0 0 0 0 0 0 0 0 0 26 27 2479 2379 2295 0 0 0 1 0 0 0 0 0 0 0 0 27 28 2057 2479 2379 0 0 0 0 1 0 0 0 0 0 0 0 28 29 2280 2057 2479 0 0 0 0 0 1 0 0 0 0 0 0 29 30 2351 2280 2057 0 0 0 0 0 0 1 0 0 0 0 0 30 31 2276 2351 2280 0 0 0 0 0 0 0 1 0 0 0 0 31 32 2548 2276 2351 0 0 0 0 0 0 0 0 1 0 0 0 32 33 2311 2548 2276 0 0 0 0 0 0 0 0 0 1 0 0 33 34 2201 2311 2548 0 0 0 0 0 0 0 0 0 0 1 0 34 35 2725 2201 2311 1 0 0 0 0 0 0 0 0 0 0 1 35 36 2408 2725 2201 1 0 0 0 0 0 0 0 0 0 0 0 36 37 2139 2408 2725 1 1 0 0 0 0 0 0 0 0 0 0 37 38 1898 2139 2408 1 0 1 0 0 0 0 0 0 0 0 0 38 39 2537 1898 2139 1 0 0 1 0 0 0 0 0 0 0 0 39 40 2068 2537 1898 1 0 0 0 1 0 0 0 0 0 0 0 40 41 2063 2068 2537 1 0 0 0 0 1 0 0 0 0 0 0 41 42 2520 2063 2068 1 0 0 0 0 0 1 0 0 0 0 0 42 43 2434 2520 2063 1 0 0 0 0 0 0 1 0 0 0 0 43 44 2190 2434 2520 1 0 0 0 0 0 0 0 1 0 0 0 44 45 2794 2190 2434 1 0 0 0 0 0 0 0 0 1 0 0 45 46 2070 2794 2190 1 0 0 0 0 0 0 0 0 0 1 0 46 47 2615 2070 2794 1 0 0 0 0 0 0 0 0 0 0 1 47 48 2265 2615 2070 1 0 0 0 0 0 0 0 0 0 0 0 48 49 2139 2265 2615 1 1 0 0 0 0 0 0 0 0 0 0 49 50 2428 2139 2265 1 0 1 0 0 0 0 0 0 0 0 0 50 51 2137 2428 2139 1 0 0 1 0 0 0 0 0 0 0 0 51 52 1823 2137 2428 1 0 0 0 1 0 0 0 0 0 0 0 52 53 2063 1823 2137 1 0 0 0 0 1 0 0 0 0 0 0 53 54 1806 2063 1823 1 0 0 0 0 0 1 0 0 0 0 0 54 55 1758 1806 2063 1 0 0 0 0 0 0 1 0 0 0 0 55 56 2243 1758 1806 1 0 0 0 0 0 0 0 1 0 0 0 56 57 1993 2243 1758 1 0 0 0 0 0 0 0 0 1 0 0 57 58 1932 1993 2243 1 0 0 0 0 0 0 0 0 0 1 0 58 59 2465 1932 1993 1 0 0 0 0 0 0 0 0 0 0 1 59 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `y(t-1)` `y(t-2)` x M1 M2 1112.0265 0.2232 0.3193 35.0305 -124.8705 65.4881 M3 M4 M5 M6 M7 M8 271.2934 -153.1527 68.4632 346.8300 101.9945 281.2621 M9 M10 M11 t 188.6535 119.3090 414.9658 -5.8146 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -439.016 -160.068 -6.265 151.969 669.185 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1112.0265 496.6067 2.239 0.0304 * `y(t-1)` 0.2232 0.1407 1.586 0.1200 `y(t-2)` 0.3193 0.1435 2.226 0.0313 * x 35.0305 138.1842 0.254 0.8011 M1 -124.8705 187.0353 -0.668 0.5079 M2 65.4881 183.4317 0.357 0.7228 M3 271.2934 182.7823 1.484 0.1450 M4 -153.1527 176.5306 -0.868 0.3904 M5 68.4632 191.9232 0.357 0.7230 M6 346.8300 186.6839 1.858 0.0700 . M7 101.9945 176.6097 0.578 0.5666 M8 281.2621 179.7720 1.565 0.1250 M9 188.6535 175.4464 1.075 0.2882 M10 119.3090 177.4129 0.672 0.5049 M11 414.9658 175.0039 2.371 0.0223 * t -5.8146 4.0466 -1.437 0.1580 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 254.9 on 43 degrees of freedom Multiple R-squared: 0.5536, Adjusted R-squared: 0.3979 F-statistic: 3.555 on 15 and 43 DF, p-value: 0.0005536 > 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.9228132 0.15437370 0.07718685 [2,] 0.8713051 0.25738979 0.12869489 [3,] 0.9849407 0.03011850 0.01505925 [4,] 0.9793307 0.04133854 0.02066927 [5,] 0.9769418 0.04611649 0.02305825 [6,] 0.9594782 0.08104354 0.04052177 [7,] 0.9318966 0.13620677 0.06810338 [8,] 0.8890150 0.22197003 0.11098502 [9,] 0.8354801 0.32903978 0.16451989 [10,] 0.7707774 0.45844511 0.22922256 [11,] 0.6843817 0.63123654 0.31561827 [12,] 0.6264490 0.74710203 0.37355101 [13,] 0.5167343 0.96653139 0.48326570 [14,] 0.4346150 0.86922993 0.56538504 [15,] 0.3408069 0.68161378 0.65919311 [16,] 0.3110440 0.62208807 0.68895596 [17,] 0.2224296 0.44485924 0.77757038 [18,] 0.1456343 0.29126861 0.85436570 [19,] 0.1228372 0.24567445 0.87716278 [20,] 0.4173579 0.83471575 0.58264212 [21,] 0.3579139 0.71582776 0.64208612 [22,] 0.3424210 0.68484203 0.65757898 > postscript(file="/var/www/html/rcomp/tmp/1oqqf1261239809.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/2d9h01261239809.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/32hg01261239809.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/409w91261239809.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/5g9gl1261239809.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 = 59 Frequency = 1 1 2 3 4 5 6 -253.304315 -188.758479 -6.265484 -129.479373 -259.522195 -303.194594 7 8 9 10 11 12 130.567485 69.058677 151.520547 287.568782 -84.291996 -318.871336 13 14 15 16 17 18 175.540911 166.827595 -11.736301 167.846489 361.326354 669.185122 19 20 21 22 23 24 -100.809113 7.923001 -439.015690 284.358385 -203.664123 7.190805 25 26 27 28 29 30 92.107106 56.237355 -11.103731 -51.984333 17.492669 -99.111879 31 32 33 34 35 36 -10.506753 82.115125 -93.236452 -162.010259 137.337925 159.262882 37 38 39 40 41 42 -75.580334 -339.868351 238.821765 134.378522 -185.734822 149.563189 43 44 45 46 47 48 213.791966 -330.365792 453.982997 -251.790888 -27.846389 152.417649 49 50 51 52 53 54 61.236632 305.561879 -209.716250 -120.761305 66.437995 -416.441838 55 56 57 58 59 -233.043584 171.268989 -73.251402 -158.126020 178.464583 > postscript(file="/var/www/html/rcomp/tmp/6dryp1261239809.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 = 59 Frequency = 1 lag(myerror, k = 1) myerror 0 -253.304315 NA 1 -188.758479 -253.304315 2 -6.265484 -188.758479 3 -129.479373 -6.265484 4 -259.522195 -129.479373 5 -303.194594 -259.522195 6 130.567485 -303.194594 7 69.058677 130.567485 8 151.520547 69.058677 9 287.568782 151.520547 10 -84.291996 287.568782 11 -318.871336 -84.291996 12 175.540911 -318.871336 13 166.827595 175.540911 14 -11.736301 166.827595 15 167.846489 -11.736301 16 361.326354 167.846489 17 669.185122 361.326354 18 -100.809113 669.185122 19 7.923001 -100.809113 20 -439.015690 7.923001 21 284.358385 -439.015690 22 -203.664123 284.358385 23 7.190805 -203.664123 24 92.107106 7.190805 25 56.237355 92.107106 26 -11.103731 56.237355 27 -51.984333 -11.103731 28 17.492669 -51.984333 29 -99.111879 17.492669 30 -10.506753 -99.111879 31 82.115125 -10.506753 32 -93.236452 82.115125 33 -162.010259 -93.236452 34 137.337925 -162.010259 35 159.262882 137.337925 36 -75.580334 159.262882 37 -339.868351 -75.580334 38 238.821765 -339.868351 39 134.378522 238.821765 40 -185.734822 134.378522 41 149.563189 -185.734822 42 213.791966 149.563189 43 -330.365792 213.791966 44 453.982997 -330.365792 45 -251.790888 453.982997 46 -27.846389 -251.790888 47 152.417649 -27.846389 48 61.236632 152.417649 49 305.561879 61.236632 50 -209.716250 305.561879 51 -120.761305 -209.716250 52 66.437995 -120.761305 53 -416.441838 66.437995 54 -233.043584 -416.441838 55 171.268989 -233.043584 56 -73.251402 171.268989 57 -158.126020 -73.251402 58 178.464583 -158.126020 59 NA 178.464583 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -188.758479 -253.304315 [2,] -6.265484 -188.758479 [3,] -129.479373 -6.265484 [4,] -259.522195 -129.479373 [5,] -303.194594 -259.522195 [6,] 130.567485 -303.194594 [7,] 69.058677 130.567485 [8,] 151.520547 69.058677 [9,] 287.568782 151.520547 [10,] -84.291996 287.568782 [11,] -318.871336 -84.291996 [12,] 175.540911 -318.871336 [13,] 166.827595 175.540911 [14,] -11.736301 166.827595 [15,] 167.846489 -11.736301 [16,] 361.326354 167.846489 [17,] 669.185122 361.326354 [18,] -100.809113 669.185122 [19,] 7.923001 -100.809113 [20,] -439.015690 7.923001 [21,] 284.358385 -439.015690 [22,] -203.664123 284.358385 [23,] 7.190805 -203.664123 [24,] 92.107106 7.190805 [25,] 56.237355 92.107106 [26,] -11.103731 56.237355 [27,] -51.984333 -11.103731 [28,] 17.492669 -51.984333 [29,] -99.111879 17.492669 [30,] -10.506753 -99.111879 [31,] 82.115125 -10.506753 [32,] -93.236452 82.115125 [33,] -162.010259 -93.236452 [34,] 137.337925 -162.010259 [35,] 159.262882 137.337925 [36,] -75.580334 159.262882 [37,] -339.868351 -75.580334 [38,] 238.821765 -339.868351 [39,] 134.378522 238.821765 [40,] -185.734822 134.378522 [41,] 149.563189 -185.734822 [42,] 213.791966 149.563189 [43,] -330.365792 213.791966 [44,] 453.982997 -330.365792 [45,] -251.790888 453.982997 [46,] -27.846389 -251.790888 [47,] 152.417649 -27.846389 [48,] 61.236632 152.417649 [49,] 305.561879 61.236632 [50,] -209.716250 305.561879 [51,] -120.761305 -209.716250 [52,] 66.437995 -120.761305 [53,] -416.441838 66.437995 [54,] -233.043584 -416.441838 [55,] 171.268989 -233.043584 [56,] -73.251402 171.268989 [57,] -158.126020 -73.251402 [58,] 178.464583 -158.126020 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -188.758479 -253.304315 2 -6.265484 -188.758479 3 -129.479373 -6.265484 4 -259.522195 -129.479373 5 -303.194594 -259.522195 6 130.567485 -303.194594 7 69.058677 130.567485 8 151.520547 69.058677 9 287.568782 151.520547 10 -84.291996 287.568782 11 -318.871336 -84.291996 12 175.540911 -318.871336 13 166.827595 175.540911 14 -11.736301 166.827595 15 167.846489 -11.736301 16 361.326354 167.846489 17 669.185122 361.326354 18 -100.809113 669.185122 19 7.923001 -100.809113 20 -439.015690 7.923001 21 284.358385 -439.015690 22 -203.664123 284.358385 23 7.190805 -203.664123 24 92.107106 7.190805 25 56.237355 92.107106 26 -11.103731 56.237355 27 -51.984333 -11.103731 28 17.492669 -51.984333 29 -99.111879 17.492669 30 -10.506753 -99.111879 31 82.115125 -10.506753 32 -93.236452 82.115125 33 -162.010259 -93.236452 34 137.337925 -162.010259 35 159.262882 137.337925 36 -75.580334 159.262882 37 -339.868351 -75.580334 38 238.821765 -339.868351 39 134.378522 238.821765 40 -185.734822 134.378522 41 149.563189 -185.734822 42 213.791966 149.563189 43 -330.365792 213.791966 44 453.982997 -330.365792 45 -251.790888 453.982997 46 -27.846389 -251.790888 47 152.417649 -27.846389 48 61.236632 152.417649 49 305.561879 61.236632 50 -209.716250 305.561879 51 -120.761305 -209.716250 52 66.437995 -120.761305 53 -416.441838 66.437995 54 -233.043584 -416.441838 55 171.268989 -233.043584 56 -73.251402 171.268989 57 -158.126020 -73.251402 58 178.464583 -158.126020 > 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/7s5y41261239809.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/8vj3z1261239809.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/9lrms1261239809.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/10ey8h1261239809.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/11fcgc1261239809.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/129qa81261239809.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/13kv9y1261239809.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/14ujof1261239810.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/15kfb21261239810.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/163y0z1261239810.tab") + } > > try(system("convert tmp/1oqqf1261239809.ps tmp/1oqqf1261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/2d9h01261239809.ps tmp/2d9h01261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/32hg01261239809.ps tmp/32hg01261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/409w91261239809.ps tmp/409w91261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/5g9gl1261239809.ps tmp/5g9gl1261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/6dryp1261239809.ps tmp/6dryp1261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/7s5y41261239809.ps tmp/7s5y41261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/8vj3z1261239809.ps tmp/8vj3z1261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/9lrms1261239809.ps tmp/9lrms1261239809.png",intern=TRUE)) character(0) > try(system("convert tmp/10ey8h1261239809.ps tmp/10ey8h1261239809.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.36 1.59 4.17