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.02,0,100.67,0,100.47,0,100.38,0,100.33,0,100.34,0,100.37,0,100.39,0,100.21,0,100.21,0,100.22,0,100.28,0,100.25,0,100.25,0,100.21,0,100.16,0,100.18,0,100.1,1,99.96,1,99.88,1,99.88,1,99.86,1,99.84,1,99.8,1,99.82,1,99.81,1,99.92,1,100.03,1,99.99,1,100.02,1,100.01,1,100.13,1,100.33,1,100.13,1,99.96,1,100.05,1,99.83,1,99.8,1,100.01,1,100.1,1,100.13,1,100.16,1,100.41,1,101.34,1,101.65,1,101.85,1,102.07,1,102.12,1,102.14,1,102.21,1,102.28,1,102.19,1,102.33,1,102.54,1,102.44,1,102.78,1,102.9,1,103.08,1,102.77,1,102.65,1,102.71,1,103.29,1,102.86,1,103.45,1,103.72,1,103.65,1,103.83,1,104.45,1,105.14,1,105.07,1,105.31,1,105.19,1,105.3,1,105.02,1,105.17,1,105.28,1,105.45,1,105.38,1,105.8,1,105.96,1,105.08,1,105.11,1,105.61,1,105.5,1),dim=c(2,84),dimnames=list(c('Suiker','dummie'),1:84)) > y <- array(NA,dim=c(2,84),dimnames=list(c('Suiker','dummie'),1:84)) > 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 = 'Do not include Seasonal Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > 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 Suiker dummie t 1 101.02 0 1 2 100.67 0 2 3 100.47 0 3 4 100.38 0 4 5 100.33 0 5 6 100.34 0 6 7 100.37 0 7 8 100.39 0 8 9 100.21 0 9 10 100.21 0 10 11 100.22 0 11 12 100.28 0 12 13 100.25 0 13 14 100.25 0 14 15 100.21 0 15 16 100.16 0 16 17 100.18 0 17 18 100.10 1 18 19 99.96 1 19 20 99.88 1 20 21 99.88 1 21 22 99.86 1 22 23 99.84 1 23 24 99.80 1 24 25 99.82 1 25 26 99.81 1 26 27 99.92 1 27 28 100.03 1 28 29 99.99 1 29 30 100.02 1 30 31 100.01 1 31 32 100.13 1 32 33 100.33 1 33 34 100.13 1 34 35 99.96 1 35 36 100.05 1 36 37 99.83 1 37 38 99.80 1 38 39 100.01 1 39 40 100.10 1 40 41 100.13 1 41 42 100.16 1 42 43 100.41 1 43 44 101.34 1 44 45 101.65 1 45 46 101.85 1 46 47 102.07 1 47 48 102.12 1 48 49 102.14 1 49 50 102.21 1 50 51 102.28 1 51 52 102.19 1 52 53 102.33 1 53 54 102.54 1 54 55 102.44 1 55 56 102.78 1 56 57 102.90 1 57 58 103.08 1 58 59 102.77 1 59 60 102.65 1 60 61 102.71 1 61 62 103.29 1 62 63 102.86 1 63 64 103.45 1 64 65 103.72 1 65 66 103.65 1 66 67 103.83 1 67 68 104.45 1 68 69 105.14 1 69 70 105.07 1 70 71 105.31 1 71 72 105.19 1 72 73 105.30 1 73 74 105.02 1 74 75 105.17 1 75 76 105.28 1 76 77 105.45 1 77 78 105.38 1 78 79 105.80 1 79 80 105.96 1 80 81 105.08 1 81 82 105.11 1 82 83 105.61 1 83 84 105.50 1 84 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) dummie t 99.4133 -2.4401 0.1040 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.18191 -0.33813 -0.00306 0.39581 1.50273 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 99.413258 0.148892 667.69 <2e-16 *** dummie -2.440071 0.226128 -10.79 <2e-16 *** t 0.104017 0.003747 27.76 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5979 on 81 degrees of freedom Multiple R-squared: 0.9184, Adjusted R-squared: 0.9164 F-statistic: 455.9 on 2 and 81 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,] 2.876379e-02 5.752757e-02 0.971236215 [2,] 1.667953e-02 3.335906e-02 0.983320468 [3,] 9.490063e-03 1.898013e-02 0.990509937 [4,] 2.813173e-03 5.626347e-03 0.997186827 [5,] 8.732973e-04 1.746595e-03 0.999126703 [6,] 3.054685e-04 6.109370e-04 0.999694532 [7,] 1.584050e-04 3.168101e-04 0.999841595 [8,] 6.500955e-05 1.300191e-04 0.999934990 [9,] 2.646557e-05 5.293114e-05 0.999973534 [10,] 8.801875e-06 1.760375e-05 0.999991198 [11,] 2.473181e-06 4.946361e-06 0.999997527 [12,] 7.745136e-07 1.549027e-06 0.999999225 [13,] 3.522650e-07 7.045301e-07 0.999999648 [14,] 1.736665e-07 3.473330e-07 0.999999826 [15,] 8.543680e-08 1.708736e-07 0.999999915 [16,] 3.712060e-08 7.424120e-08 0.999999963 [17,] 1.563057e-08 3.126113e-08 0.999999984 [18,] 6.375724e-09 1.275145e-08 0.999999994 [19,] 2.417524e-09 4.835048e-09 0.999999998 [20,] 9.674022e-10 1.934804e-09 0.999999999 [21,] 3.838435e-10 7.676870e-10 1.000000000 [22,] 4.579808e-10 9.159617e-10 1.000000000 [23,] 2.331248e-09 4.662496e-09 0.999999998 [24,] 4.098174e-09 8.196348e-09 0.999999996 [25,] 7.753050e-09 1.550610e-08 0.999999992 [26,] 9.618474e-09 1.923695e-08 0.999999990 [27,] 3.192081e-08 6.384162e-08 0.999999968 [28,] 5.653841e-07 1.130768e-06 0.999999435 [29,] 5.224414e-07 1.044883e-06 0.999999478 [30,] 2.124448e-07 4.248896e-07 0.999999788 [31,] 1.039007e-07 2.078014e-07 0.999999896 [32,] 4.923634e-08 9.847267e-08 0.999999951 [33,] 3.085062e-08 6.170123e-08 0.999999969 [34,] 2.081734e-08 4.163469e-08 0.999999979 [35,] 2.294610e-08 4.589220e-08 0.999999977 [36,] 3.917901e-08 7.835801e-08 0.999999961 [37,] 1.291991e-07 2.583982e-07 0.999999871 [38,] 1.717229e-06 3.434459e-06 0.999998283 [39,] 4.368521e-03 8.737042e-03 0.995631479 [40,] 1.068426e-01 2.136851e-01 0.893157445 [41,] 3.675584e-01 7.351167e-01 0.632441642 [42,] 6.399730e-01 7.200539e-01 0.360026954 [43,] 7.760407e-01 4.479185e-01 0.223959269 [44,] 8.318128e-01 3.363743e-01 0.168187170 [45,] 8.578206e-01 2.843588e-01 0.142179388 [46,] 8.671117e-01 2.657766e-01 0.132888281 [47,] 8.515678e-01 2.968644e-01 0.148432210 [48,] 8.339866e-01 3.320269e-01 0.166013433 [49,] 8.204841e-01 3.590318e-01 0.179515881 [50,] 7.888440e-01 4.223120e-01 0.211156005 [51,] 7.676712e-01 4.646577e-01 0.232328848 [52,] 7.420416e-01 5.159169e-01 0.257958429 [53,] 7.200622e-01 5.598757e-01 0.279937847 [54,] 6.722201e-01 6.555599e-01 0.327779934 [55,] 6.601166e-01 6.797669e-01 0.339883448 [56,] 6.888462e-01 6.223076e-01 0.311153807 [57,] 6.586375e-01 6.827249e-01 0.341362461 [58,] 7.892704e-01 4.214593e-01 0.210729648 [59,] 8.235060e-01 3.529879e-01 0.176493963 [60,] 8.494255e-01 3.011491e-01 0.150574533 [61,] 9.366124e-01 1.267753e-01 0.063387632 [62,] 9.931289e-01 1.374214e-02 0.006871069 [63,] 9.979323e-01 4.135327e-03 0.002067663 [64,] 9.972292e-01 5.541558e-03 0.002770779 [65,] 9.955683e-01 8.863357e-03 0.004431678 [66,] 9.929338e-01 1.413231e-02 0.007066153 [67,] 9.863408e-01 2.731836e-02 0.013659181 [68,] 9.742154e-01 5.156925e-02 0.025784626 [69,] 9.591691e-01 8.166179e-02 0.040830895 [70,] 9.316230e-01 1.367539e-01 0.068376964 [71,] 8.851638e-01 2.296723e-01 0.114836171 [72,] 7.940126e-01 4.119748e-01 0.205987385 [73,] 6.870590e-01 6.258820e-01 0.312940997 > postscript(file="/var/www/html/rcomp/tmp/1s7zc1229968685.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/2v42k1229968685.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/3vz731229968685.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/4kac51229968685.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/5wkgz1229968685.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 = 84 Frequency = 1 1 2 3 4 5 1.5027252022 1.0487080814 0.7446909605 0.5506738396 0.3966567188 6 7 8 9 10 0.3026395979 0.2286224770 0.1446053562 -0.1394117647 -0.2434288856 11 12 13 14 15 -0.3374460064 -0.3814631273 -0.5154802482 -0.6194973690 -0.7635144899 16 17 18 19 20 -0.9175316108 -1.0015487316 1.2545052871 1.0104881663 0.8264710454 21 22 23 24 25 0.7224539245 0.5984368037 0.4744196828 0.3304025619 0.2463854411 26 27 28 29 30 0.1323683202 0.1383511993 0.1443340784 0.0003169576 -0.0737001633 31 32 33 34 35 -0.1877172842 -0.1717344050 -0.0757515259 -0.3797686468 -0.6537857676 36 37 38 39 40 -0.6678028885 -0.9918200094 -1.1258371302 -1.0198542511 -1.0338713720 41 42 43 44 45 -1.1078884928 -1.1819056137 -1.0359227346 -0.2099398554 -0.0039569763 46 47 48 49 50 0.0920259028 0.2080087820 0.1539916611 0.0699745402 0.0359574194 51 52 53 54 55 0.0019402985 -0.1920768224 -0.1560939432 -0.0501110641 -0.2541281850 56 57 58 59 60 -0.0181453058 -0.0021624267 0.0738204524 -0.3401966684 -0.5642137893 61 62 63 64 65 -0.6082309102 -0.1322480310 -0.6662651519 -0.1802822728 -0.0142993936 66 67 68 69 70 -0.1883165145 -0.1123336354 0.4036492438 0.9896321229 0.8156150020 71 72 73 74 75 0.9515978812 0.7275807603 0.7335636394 0.3495465186 0.3955293977 76 77 78 79 80 0.4015122768 0.4674951560 0.2934780351 0.6094609142 0.6654437934 81 82 83 84 -0.3185733275 -0.3925904484 0.0033924308 -0.2106246901 > postscript(file="/var/www/html/rcomp/tmp/61myn1229968685.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 = 84 Frequency = 1 lag(myerror, k = 1) myerror 0 1.5027252022 NA 1 1.0487080814 1.5027252022 2 0.7446909605 1.0487080814 3 0.5506738396 0.7446909605 4 0.3966567188 0.5506738396 5 0.3026395979 0.3966567188 6 0.2286224770 0.3026395979 7 0.1446053562 0.2286224770 8 -0.1394117647 0.1446053562 9 -0.2434288856 -0.1394117647 10 -0.3374460064 -0.2434288856 11 -0.3814631273 -0.3374460064 12 -0.5154802482 -0.3814631273 13 -0.6194973690 -0.5154802482 14 -0.7635144899 -0.6194973690 15 -0.9175316108 -0.7635144899 16 -1.0015487316 -0.9175316108 17 1.2545052871 -1.0015487316 18 1.0104881663 1.2545052871 19 0.8264710454 1.0104881663 20 0.7224539245 0.8264710454 21 0.5984368037 0.7224539245 22 0.4744196828 0.5984368037 23 0.3304025619 0.4744196828 24 0.2463854411 0.3304025619 25 0.1323683202 0.2463854411 26 0.1383511993 0.1323683202 27 0.1443340784 0.1383511993 28 0.0003169576 0.1443340784 29 -0.0737001633 0.0003169576 30 -0.1877172842 -0.0737001633 31 -0.1717344050 -0.1877172842 32 -0.0757515259 -0.1717344050 33 -0.3797686468 -0.0757515259 34 -0.6537857676 -0.3797686468 35 -0.6678028885 -0.6537857676 36 -0.9918200094 -0.6678028885 37 -1.1258371302 -0.9918200094 38 -1.0198542511 -1.1258371302 39 -1.0338713720 -1.0198542511 40 -1.1078884928 -1.0338713720 41 -1.1819056137 -1.1078884928 42 -1.0359227346 -1.1819056137 43 -0.2099398554 -1.0359227346 44 -0.0039569763 -0.2099398554 45 0.0920259028 -0.0039569763 46 0.2080087820 0.0920259028 47 0.1539916611 0.2080087820 48 0.0699745402 0.1539916611 49 0.0359574194 0.0699745402 50 0.0019402985 0.0359574194 51 -0.1920768224 0.0019402985 52 -0.1560939432 -0.1920768224 53 -0.0501110641 -0.1560939432 54 -0.2541281850 -0.0501110641 55 -0.0181453058 -0.2541281850 56 -0.0021624267 -0.0181453058 57 0.0738204524 -0.0021624267 58 -0.3401966684 0.0738204524 59 -0.5642137893 -0.3401966684 60 -0.6082309102 -0.5642137893 61 -0.1322480310 -0.6082309102 62 -0.6662651519 -0.1322480310 63 -0.1802822728 -0.6662651519 64 -0.0142993936 -0.1802822728 65 -0.1883165145 -0.0142993936 66 -0.1123336354 -0.1883165145 67 0.4036492438 -0.1123336354 68 0.9896321229 0.4036492438 69 0.8156150020 0.9896321229 70 0.9515978812 0.8156150020 71 0.7275807603 0.9515978812 72 0.7335636394 0.7275807603 73 0.3495465186 0.7335636394 74 0.3955293977 0.3495465186 75 0.4015122768 0.3955293977 76 0.4674951560 0.4015122768 77 0.2934780351 0.4674951560 78 0.6094609142 0.2934780351 79 0.6654437934 0.6094609142 80 -0.3185733275 0.6654437934 81 -0.3925904484 -0.3185733275 82 0.0033924308 -0.3925904484 83 -0.2106246901 0.0033924308 84 NA -0.2106246901 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 1.0487080814 1.5027252022 [2,] 0.7446909605 1.0487080814 [3,] 0.5506738396 0.7446909605 [4,] 0.3966567188 0.5506738396 [5,] 0.3026395979 0.3966567188 [6,] 0.2286224770 0.3026395979 [7,] 0.1446053562 0.2286224770 [8,] -0.1394117647 0.1446053562 [9,] -0.2434288856 -0.1394117647 [10,] -0.3374460064 -0.2434288856 [11,] -0.3814631273 -0.3374460064 [12,] -0.5154802482 -0.3814631273 [13,] -0.6194973690 -0.5154802482 [14,] -0.7635144899 -0.6194973690 [15,] -0.9175316108 -0.7635144899 [16,] -1.0015487316 -0.9175316108 [17,] 1.2545052871 -1.0015487316 [18,] 1.0104881663 1.2545052871 [19,] 0.8264710454 1.0104881663 [20,] 0.7224539245 0.8264710454 [21,] 0.5984368037 0.7224539245 [22,] 0.4744196828 0.5984368037 [23,] 0.3304025619 0.4744196828 [24,] 0.2463854411 0.3304025619 [25,] 0.1323683202 0.2463854411 [26,] 0.1383511993 0.1323683202 [27,] 0.1443340784 0.1383511993 [28,] 0.0003169576 0.1443340784 [29,] -0.0737001633 0.0003169576 [30,] -0.1877172842 -0.0737001633 [31,] -0.1717344050 -0.1877172842 [32,] -0.0757515259 -0.1717344050 [33,] -0.3797686468 -0.0757515259 [34,] -0.6537857676 -0.3797686468 [35,] -0.6678028885 -0.6537857676 [36,] -0.9918200094 -0.6678028885 [37,] -1.1258371302 -0.9918200094 [38,] -1.0198542511 -1.1258371302 [39,] -1.0338713720 -1.0198542511 [40,] -1.1078884928 -1.0338713720 [41,] -1.1819056137 -1.1078884928 [42,] -1.0359227346 -1.1819056137 [43,] -0.2099398554 -1.0359227346 [44,] -0.0039569763 -0.2099398554 [45,] 0.0920259028 -0.0039569763 [46,] 0.2080087820 0.0920259028 [47,] 0.1539916611 0.2080087820 [48,] 0.0699745402 0.1539916611 [49,] 0.0359574194 0.0699745402 [50,] 0.0019402985 0.0359574194 [51,] -0.1920768224 0.0019402985 [52,] -0.1560939432 -0.1920768224 [53,] -0.0501110641 -0.1560939432 [54,] -0.2541281850 -0.0501110641 [55,] -0.0181453058 -0.2541281850 [56,] -0.0021624267 -0.0181453058 [57,] 0.0738204524 -0.0021624267 [58,] -0.3401966684 0.0738204524 [59,] -0.5642137893 -0.3401966684 [60,] -0.6082309102 -0.5642137893 [61,] -0.1322480310 -0.6082309102 [62,] -0.6662651519 -0.1322480310 [63,] -0.1802822728 -0.6662651519 [64,] -0.0142993936 -0.1802822728 [65,] -0.1883165145 -0.0142993936 [66,] -0.1123336354 -0.1883165145 [67,] 0.4036492438 -0.1123336354 [68,] 0.9896321229 0.4036492438 [69,] 0.8156150020 0.9896321229 [70,] 0.9515978812 0.8156150020 [71,] 0.7275807603 0.9515978812 [72,] 0.7335636394 0.7275807603 [73,] 0.3495465186 0.7335636394 [74,] 0.3955293977 0.3495465186 [75,] 0.4015122768 0.3955293977 [76,] 0.4674951560 0.4015122768 [77,] 0.2934780351 0.4674951560 [78,] 0.6094609142 0.2934780351 [79,] 0.6654437934 0.6094609142 [80,] -0.3185733275 0.6654437934 [81,] -0.3925904484 -0.3185733275 [82,] 0.0033924308 -0.3925904484 [83,] -0.2106246901 0.0033924308 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 1.0487080814 1.5027252022 2 0.7446909605 1.0487080814 3 0.5506738396 0.7446909605 4 0.3966567188 0.5506738396 5 0.3026395979 0.3966567188 6 0.2286224770 0.3026395979 7 0.1446053562 0.2286224770 8 -0.1394117647 0.1446053562 9 -0.2434288856 -0.1394117647 10 -0.3374460064 -0.2434288856 11 -0.3814631273 -0.3374460064 12 -0.5154802482 -0.3814631273 13 -0.6194973690 -0.5154802482 14 -0.7635144899 -0.6194973690 15 -0.9175316108 -0.7635144899 16 -1.0015487316 -0.9175316108 17 1.2545052871 -1.0015487316 18 1.0104881663 1.2545052871 19 0.8264710454 1.0104881663 20 0.7224539245 0.8264710454 21 0.5984368037 0.7224539245 22 0.4744196828 0.5984368037 23 0.3304025619 0.4744196828 24 0.2463854411 0.3304025619 25 0.1323683202 0.2463854411 26 0.1383511993 0.1323683202 27 0.1443340784 0.1383511993 28 0.0003169576 0.1443340784 29 -0.0737001633 0.0003169576 30 -0.1877172842 -0.0737001633 31 -0.1717344050 -0.1877172842 32 -0.0757515259 -0.1717344050 33 -0.3797686468 -0.0757515259 34 -0.6537857676 -0.3797686468 35 -0.6678028885 -0.6537857676 36 -0.9918200094 -0.6678028885 37 -1.1258371302 -0.9918200094 38 -1.0198542511 -1.1258371302 39 -1.0338713720 -1.0198542511 40 -1.1078884928 -1.0338713720 41 -1.1819056137 -1.1078884928 42 -1.0359227346 -1.1819056137 43 -0.2099398554 -1.0359227346 44 -0.0039569763 -0.2099398554 45 0.0920259028 -0.0039569763 46 0.2080087820 0.0920259028 47 0.1539916611 0.2080087820 48 0.0699745402 0.1539916611 49 0.0359574194 0.0699745402 50 0.0019402985 0.0359574194 51 -0.1920768224 0.0019402985 52 -0.1560939432 -0.1920768224 53 -0.0501110641 -0.1560939432 54 -0.2541281850 -0.0501110641 55 -0.0181453058 -0.2541281850 56 -0.0021624267 -0.0181453058 57 0.0738204524 -0.0021624267 58 -0.3401966684 0.0738204524 59 -0.5642137893 -0.3401966684 60 -0.6082309102 -0.5642137893 61 -0.1322480310 -0.6082309102 62 -0.6662651519 -0.1322480310 63 -0.1802822728 -0.6662651519 64 -0.0142993936 -0.1802822728 65 -0.1883165145 -0.0142993936 66 -0.1123336354 -0.1883165145 67 0.4036492438 -0.1123336354 68 0.9896321229 0.4036492438 69 0.8156150020 0.9896321229 70 0.9515978812 0.8156150020 71 0.7275807603 0.9515978812 72 0.7335636394 0.7275807603 73 0.3495465186 0.7335636394 74 0.3955293977 0.3495465186 75 0.4015122768 0.3955293977 76 0.4674951560 0.4015122768 77 0.2934780351 0.4674951560 78 0.6094609142 0.2934780351 79 0.6654437934 0.6094609142 80 -0.3185733275 0.6654437934 81 -0.3925904484 -0.3185733275 82 0.0033924308 -0.3925904484 83 -0.2106246901 0.0033924308 > 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/7rgjd1229968685.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/8kc4w1229968685.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/91x2y1229968685.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/10vv021229968685.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/11wc1c1229968685.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/1257mg1229968686.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/13dbsd1229968686.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/14qr941229968686.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/15r4z71229968686.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/16q3xu1229968686.tab") + } > > system("convert tmp/1s7zc1229968685.ps tmp/1s7zc1229968685.png") > system("convert tmp/2v42k1229968685.ps tmp/2v42k1229968685.png") > system("convert tmp/3vz731229968685.ps tmp/3vz731229968685.png") > system("convert tmp/4kac51229968685.ps tmp/4kac51229968685.png") > system("convert tmp/5wkgz1229968685.ps tmp/5wkgz1229968685.png") > system("convert tmp/61myn1229968685.ps tmp/61myn1229968685.png") > system("convert tmp/7rgjd1229968685.ps tmp/7rgjd1229968685.png") > system("convert tmp/8kc4w1229968685.ps tmp/8kc4w1229968685.png") > system("convert tmp/91x2y1229968685.ps tmp/91x2y1229968685.png") > system("convert tmp/10vv021229968685.ps tmp/10vv021229968685.png") > > > proc.time() user system elapsed 2.883 1.639 6.310