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(91.2,0,99.2,0,108.2,0,101.5,0,106.9,0,104.4,0,77.9,0,60,0,99.5,0,95,0,105.6,0,102.5,0,93.3,0,97.3,0,127,0,111.7,0,96.4,0,133,0,72.2,0,95.8,0,124.1,0,127.6,0,110.7,0,104.6,0,112.7,1,115.3,1,139.4,1,119,1,97.4,1,154,1,81.5,1,88.8,1,127.7,1,105.1,1,114.9,1,106.4,1,104.5,1,121.6,1,141.4,1,99,1,126.7,1,134.1,1,81.3,1,88.6,1,132.7,1,132.9,1,134.4,1,103.7,1,119.7,1,115,1,132.9,1,108.5,1,113.9,1,142,1,97.7,1,92.2,1,128.8,1,134.9,1,128.2,1,114.8,1,117.9,1,119.1,1,120.7,1,129.1,1,117.6,1,129.2,1,100,1,87.3,1),dim=c(2,68),dimnames=list(c('X','Y'),1:68)) > y <- array(NA,dim=c(2,68),dimnames=list(c('X','Y'),1:68)) > 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 X Y M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 91.2 0 1 0 0 0 0 0 0 0 0 0 0 1 2 99.2 0 0 1 0 0 0 0 0 0 0 0 0 2 3 108.2 0 0 0 1 0 0 0 0 0 0 0 0 3 4 101.5 0 0 0 0 1 0 0 0 0 0 0 0 4 5 106.9 0 0 0 0 0 1 0 0 0 0 0 0 5 6 104.4 0 0 0 0 0 0 1 0 0 0 0 0 6 7 77.9 0 0 0 0 0 0 0 1 0 0 0 0 7 8 60.0 0 0 0 0 0 0 0 0 1 0 0 0 8 9 99.5 0 0 0 0 0 0 0 0 0 1 0 0 9 10 95.0 0 0 0 0 0 0 0 0 0 0 1 0 10 11 105.6 0 0 0 0 0 0 0 0 0 0 0 1 11 12 102.5 0 0 0 0 0 0 0 0 0 0 0 0 12 13 93.3 0 1 0 0 0 0 0 0 0 0 0 0 13 14 97.3 0 0 1 0 0 0 0 0 0 0 0 0 14 15 127.0 0 0 0 1 0 0 0 0 0 0 0 0 15 16 111.7 0 0 0 0 1 0 0 0 0 0 0 0 16 17 96.4 0 0 0 0 0 1 0 0 0 0 0 0 17 18 133.0 0 0 0 0 0 0 1 0 0 0 0 0 18 19 72.2 0 0 0 0 0 0 0 1 0 0 0 0 19 20 95.8 0 0 0 0 0 0 0 0 1 0 0 0 20 21 124.1 0 0 0 0 0 0 0 0 0 1 0 0 21 22 127.6 0 0 0 0 0 0 0 0 0 0 1 0 22 23 110.7 0 0 0 0 0 0 0 0 0 0 0 1 23 24 104.6 0 0 0 0 0 0 0 0 0 0 0 0 24 25 112.7 1 1 0 0 0 0 0 0 0 0 0 0 25 26 115.3 1 0 1 0 0 0 0 0 0 0 0 0 26 27 139.4 1 0 0 1 0 0 0 0 0 0 0 0 27 28 119.0 1 0 0 0 1 0 0 0 0 0 0 0 28 29 97.4 1 0 0 0 0 1 0 0 0 0 0 0 29 30 154.0 1 0 0 0 0 0 1 0 0 0 0 0 30 31 81.5 1 0 0 0 0 0 0 1 0 0 0 0 31 32 88.8 1 0 0 0 0 0 0 0 1 0 0 0 32 33 127.7 1 0 0 0 0 0 0 0 0 1 0 0 33 34 105.1 1 0 0 0 0 0 0 0 0 0 1 0 34 35 114.9 1 0 0 0 0 0 0 0 0 0 0 1 35 36 106.4 1 0 0 0 0 0 0 0 0 0 0 0 36 37 104.5 1 1 0 0 0 0 0 0 0 0 0 0 37 38 121.6 1 0 1 0 0 0 0 0 0 0 0 0 38 39 141.4 1 0 0 1 0 0 0 0 0 0 0 0 39 40 99.0 1 0 0 0 1 0 0 0 0 0 0 0 40 41 126.7 1 0 0 0 0 1 0 0 0 0 0 0 41 42 134.1 1 0 0 0 0 0 1 0 0 0 0 0 42 43 81.3 1 0 0 0 0 0 0 1 0 0 0 0 43 44 88.6 1 0 0 0 0 0 0 0 1 0 0 0 44 45 132.7 1 0 0 0 0 0 0 0 0 1 0 0 45 46 132.9 1 0 0 0 0 0 0 0 0 0 1 0 46 47 134.4 1 0 0 0 0 0 0 0 0 0 0 1 47 48 103.7 1 0 0 0 0 0 0 0 0 0 0 0 48 49 119.7 1 1 0 0 0 0 0 0 0 0 0 0 49 50 115.0 1 0 1 0 0 0 0 0 0 0 0 0 50 51 132.9 1 0 0 1 0 0 0 0 0 0 0 0 51 52 108.5 1 0 0 0 1 0 0 0 0 0 0 0 52 53 113.9 1 0 0 0 0 1 0 0 0 0 0 0 53 54 142.0 1 0 0 0 0 0 1 0 0 0 0 0 54 55 97.7 1 0 0 0 0 0 0 1 0 0 0 0 55 56 92.2 1 0 0 0 0 0 0 0 1 0 0 0 56 57 128.8 1 0 0 0 0 0 0 0 0 1 0 0 57 58 134.9 1 0 0 0 0 0 0 0 0 0 1 0 58 59 128.2 1 0 0 0 0 0 0 0 0 0 0 1 59 60 114.8 1 0 0 0 0 0 0 0 0 0 0 0 60 61 117.9 1 1 0 0 0 0 0 0 0 0 0 0 61 62 119.1 1 0 1 0 0 0 0 0 0 0 0 0 62 63 120.7 1 0 0 1 0 0 0 0 0 0 0 0 63 64 129.1 1 0 0 0 1 0 0 0 0 0 0 0 64 65 117.6 1 0 0 0 0 1 0 0 0 0 0 0 65 66 129.2 1 0 0 0 0 0 1 0 0 0 0 0 66 67 100.0 1 0 0 0 0 0 0 1 0 0 0 0 67 68 87.3 1 0 0 0 0 0 0 0 1 0 0 0 68 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Y M1 M2 M3 M4 93.7594 6.6017 0.9154 5.3743 22.1499 5.1088 M5 M6 M7 M8 M9 M10 3.2177 25.9432 -21.9812 -21.8723 16.8833 13.1822 M11 t 12.6011 0.2411 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -17.0002 -4.8091 -0.2215 6.6329 20.4627 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 93.7594 4.8616 19.286 < 2e-16 *** Y 6.6017 4.4463 1.485 0.143422 M1 0.9154 5.8992 0.155 0.877265 M2 5.3743 5.8857 0.913 0.365242 M3 22.1499 5.8741 3.771 0.000405 *** M4 5.1088 5.8645 0.871 0.387537 M5 3.2177 5.8569 0.549 0.585010 M6 25.9432 5.8513 4.434 4.58e-05 *** M7 -21.9812 5.8477 -3.759 0.000421 *** M8 -21.8723 5.8461 -3.741 0.000445 *** M9 16.8833 6.1123 2.762 0.007832 ** M10 13.1822 6.1075 2.158 0.035363 * M11 12.6011 6.1046 2.064 0.043817 * t 0.2411 0.1086 2.220 0.030649 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 9.651 on 54 degrees of freedom Multiple R-squared: 0.7813, Adjusted R-squared: 0.7287 F-statistic: 14.84 on 13 and 54 DF, p-value: 1.955e-13 > 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.5964834 0.80703319 0.40351660 [2,] 0.7694324 0.46113514 0.23056757 [3,] 0.7462730 0.50745390 0.25372695 [4,] 0.8956924 0.20861530 0.10430765 [5,] 0.8724605 0.25507903 0.12753951 [6,] 0.8930776 0.21384483 0.10692242 [7,] 0.8547931 0.29041375 0.14520688 [8,] 0.8087143 0.38257147 0.19128573 [9,] 0.7326435 0.53471300 0.26735650 [10,] 0.6467229 0.70655411 0.35327706 [11,] 0.5863037 0.82739254 0.41369627 [12,] 0.5408368 0.91832643 0.45916322 [13,] 0.6663267 0.66734654 0.33367327 [14,] 0.8348123 0.33037545 0.16518772 [15,] 0.8004148 0.39917046 0.19958523 [16,] 0.7437374 0.51252512 0.25626256 [17,] 0.6661654 0.66766929 0.33383464 [18,] 0.8497345 0.30053098 0.15026549 [19,] 0.8480632 0.30387358 0.15193679 [20,] 0.8021318 0.39573648 0.19786824 [21,] 0.8198982 0.36020355 0.18010177 [22,] 0.7641614 0.47167719 0.23583859 [23,] 0.8041827 0.39163450 0.19581725 [24,] 0.9310571 0.13788584 0.06894292 [25,] 0.9434966 0.11300688 0.05650344 [26,] 0.9166521 0.16669571 0.08334786 [27,] 0.9500431 0.09991385 0.04995692 [28,] 0.9161028 0.16779437 0.08389719 [29,] 0.8685154 0.26296919 0.13148459 [30,] 0.8037065 0.39258700 0.19629350 [31,] 0.7416140 0.51677197 0.25838599 [32,] 0.7161003 0.56779949 0.28389974 [33,] 0.5865414 0.82691723 0.41345861 [34,] 0.4585587 0.91711740 0.54144130 [35,] 0.4146479 0.82929581 0.58535209 > postscript(file="/var/www/html/freestat/rcomp/tmp/1dwuq1227359805.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/2lnm11227359805.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/3xwdm1227359805.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/4yjvo1227359805.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/5oom11227359805.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 = 68 Frequency = 1 1 2 3 4 5 6 -3.71588050 -0.41588050 -8.43254717 1.66745283 8.71745283 -16.74921384 7 8 9 10 11 12 4.43411950 -13.81588050 -13.31259434 -14.35259434 -3.41259434 5.84740566 13 14 15 16 17 18 -4.50908805 -5.20908805 7.47424528 8.97424528 -4.67575472 8.95757862 19 20 21 22 23 24 -4.15908805 19.09091195 8.39419811 15.35419811 -1.20580189 5.05419811 25 26 27 28 29 30 5.39605346 3.29605346 10.37938679 6.77938679 -13.17061321 20.46272013 31 32 33 34 35 36 -4.35394654 2.59605346 2.49933962 -16.64066038 -6.50066038 -2.64066038 37 38 39 40 41 42 -5.69715409 6.70284591 9.48617925 -16.11382075 13.23617925 -2.33048742 43 44 45 46 47 48 -7.44715409 -0.49715409 4.60613208 8.26613208 10.10613208 -8.23386792 49 50 51 52 53 54 6.60963836 -2.79036164 -1.90702830 -9.50702830 -2.45702830 2.67630503 55 56 57 58 59 60 6.05963836 0.20963836 -2.18707547 7.37292453 1.01292453 -0.02707547 61 62 63 64 65 66 1.91643082 -1.58356918 -17.00023585 8.19976415 -1.65023585 -13.01690252 67 68 5.46643082 -7.58356918 > postscript(file="/var/www/html/freestat/rcomp/tmp/6ea8z1227359805.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 = 68 Frequency = 1 lag(myerror, k = 1) myerror 0 -3.71588050 NA 1 -0.41588050 -3.71588050 2 -8.43254717 -0.41588050 3 1.66745283 -8.43254717 4 8.71745283 1.66745283 5 -16.74921384 8.71745283 6 4.43411950 -16.74921384 7 -13.81588050 4.43411950 8 -13.31259434 -13.81588050 9 -14.35259434 -13.31259434 10 -3.41259434 -14.35259434 11 5.84740566 -3.41259434 12 -4.50908805 5.84740566 13 -5.20908805 -4.50908805 14 7.47424528 -5.20908805 15 8.97424528 7.47424528 16 -4.67575472 8.97424528 17 8.95757862 -4.67575472 18 -4.15908805 8.95757862 19 19.09091195 -4.15908805 20 8.39419811 19.09091195 21 15.35419811 8.39419811 22 -1.20580189 15.35419811 23 5.05419811 -1.20580189 24 5.39605346 5.05419811 25 3.29605346 5.39605346 26 10.37938679 3.29605346 27 6.77938679 10.37938679 28 -13.17061321 6.77938679 29 20.46272013 -13.17061321 30 -4.35394654 20.46272013 31 2.59605346 -4.35394654 32 2.49933962 2.59605346 33 -16.64066038 2.49933962 34 -6.50066038 -16.64066038 35 -2.64066038 -6.50066038 36 -5.69715409 -2.64066038 37 6.70284591 -5.69715409 38 9.48617925 6.70284591 39 -16.11382075 9.48617925 40 13.23617925 -16.11382075 41 -2.33048742 13.23617925 42 -7.44715409 -2.33048742 43 -0.49715409 -7.44715409 44 4.60613208 -0.49715409 45 8.26613208 4.60613208 46 10.10613208 8.26613208 47 -8.23386792 10.10613208 48 6.60963836 -8.23386792 49 -2.79036164 6.60963836 50 -1.90702830 -2.79036164 51 -9.50702830 -1.90702830 52 -2.45702830 -9.50702830 53 2.67630503 -2.45702830 54 6.05963836 2.67630503 55 0.20963836 6.05963836 56 -2.18707547 0.20963836 57 7.37292453 -2.18707547 58 1.01292453 7.37292453 59 -0.02707547 1.01292453 60 1.91643082 -0.02707547 61 -1.58356918 1.91643082 62 -17.00023585 -1.58356918 63 8.19976415 -17.00023585 64 -1.65023585 8.19976415 65 -13.01690252 -1.65023585 66 5.46643082 -13.01690252 67 -7.58356918 5.46643082 68 NA -7.58356918 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.41588050 -3.71588050 [2,] -8.43254717 -0.41588050 [3,] 1.66745283 -8.43254717 [4,] 8.71745283 1.66745283 [5,] -16.74921384 8.71745283 [6,] 4.43411950 -16.74921384 [7,] -13.81588050 4.43411950 [8,] -13.31259434 -13.81588050 [9,] -14.35259434 -13.31259434 [10,] -3.41259434 -14.35259434 [11,] 5.84740566 -3.41259434 [12,] -4.50908805 5.84740566 [13,] -5.20908805 -4.50908805 [14,] 7.47424528 -5.20908805 [15,] 8.97424528 7.47424528 [16,] -4.67575472 8.97424528 [17,] 8.95757862 -4.67575472 [18,] -4.15908805 8.95757862 [19,] 19.09091195 -4.15908805 [20,] 8.39419811 19.09091195 [21,] 15.35419811 8.39419811 [22,] -1.20580189 15.35419811 [23,] 5.05419811 -1.20580189 [24,] 5.39605346 5.05419811 [25,] 3.29605346 5.39605346 [26,] 10.37938679 3.29605346 [27,] 6.77938679 10.37938679 [28,] -13.17061321 6.77938679 [29,] 20.46272013 -13.17061321 [30,] -4.35394654 20.46272013 [31,] 2.59605346 -4.35394654 [32,] 2.49933962 2.59605346 [33,] -16.64066038 2.49933962 [34,] -6.50066038 -16.64066038 [35,] -2.64066038 -6.50066038 [36,] -5.69715409 -2.64066038 [37,] 6.70284591 -5.69715409 [38,] 9.48617925 6.70284591 [39,] -16.11382075 9.48617925 [40,] 13.23617925 -16.11382075 [41,] -2.33048742 13.23617925 [42,] -7.44715409 -2.33048742 [43,] -0.49715409 -7.44715409 [44,] 4.60613208 -0.49715409 [45,] 8.26613208 4.60613208 [46,] 10.10613208 8.26613208 [47,] -8.23386792 10.10613208 [48,] 6.60963836 -8.23386792 [49,] -2.79036164 6.60963836 [50,] -1.90702830 -2.79036164 [51,] -9.50702830 -1.90702830 [52,] -2.45702830 -9.50702830 [53,] 2.67630503 -2.45702830 [54,] 6.05963836 2.67630503 [55,] 0.20963836 6.05963836 [56,] -2.18707547 0.20963836 [57,] 7.37292453 -2.18707547 [58,] 1.01292453 7.37292453 [59,] -0.02707547 1.01292453 [60,] 1.91643082 -0.02707547 [61,] -1.58356918 1.91643082 [62,] -17.00023585 -1.58356918 [63,] 8.19976415 -17.00023585 [64,] -1.65023585 8.19976415 [65,] -13.01690252 -1.65023585 [66,] 5.46643082 -13.01690252 [67,] -7.58356918 5.46643082 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.41588050 -3.71588050 2 -8.43254717 -0.41588050 3 1.66745283 -8.43254717 4 8.71745283 1.66745283 5 -16.74921384 8.71745283 6 4.43411950 -16.74921384 7 -13.81588050 4.43411950 8 -13.31259434 -13.81588050 9 -14.35259434 -13.31259434 10 -3.41259434 -14.35259434 11 5.84740566 -3.41259434 12 -4.50908805 5.84740566 13 -5.20908805 -4.50908805 14 7.47424528 -5.20908805 15 8.97424528 7.47424528 16 -4.67575472 8.97424528 17 8.95757862 -4.67575472 18 -4.15908805 8.95757862 19 19.09091195 -4.15908805 20 8.39419811 19.09091195 21 15.35419811 8.39419811 22 -1.20580189 15.35419811 23 5.05419811 -1.20580189 24 5.39605346 5.05419811 25 3.29605346 5.39605346 26 10.37938679 3.29605346 27 6.77938679 10.37938679 28 -13.17061321 6.77938679 29 20.46272013 -13.17061321 30 -4.35394654 20.46272013 31 2.59605346 -4.35394654 32 2.49933962 2.59605346 33 -16.64066038 2.49933962 34 -6.50066038 -16.64066038 35 -2.64066038 -6.50066038 36 -5.69715409 -2.64066038 37 6.70284591 -5.69715409 38 9.48617925 6.70284591 39 -16.11382075 9.48617925 40 13.23617925 -16.11382075 41 -2.33048742 13.23617925 42 -7.44715409 -2.33048742 43 -0.49715409 -7.44715409 44 4.60613208 -0.49715409 45 8.26613208 4.60613208 46 10.10613208 8.26613208 47 -8.23386792 10.10613208 48 6.60963836 -8.23386792 49 -2.79036164 6.60963836 50 -1.90702830 -2.79036164 51 -9.50702830 -1.90702830 52 -2.45702830 -9.50702830 53 2.67630503 -2.45702830 54 6.05963836 2.67630503 55 0.20963836 6.05963836 56 -2.18707547 0.20963836 57 7.37292453 -2.18707547 58 1.01292453 7.37292453 59 -0.02707547 1.01292453 60 1.91643082 -0.02707547 61 -1.58356918 1.91643082 62 -17.00023585 -1.58356918 63 8.19976415 -17.00023585 64 -1.65023585 8.19976415 65 -13.01690252 -1.65023585 66 5.46643082 -13.01690252 67 -7.58356918 5.46643082 > 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/7w85l1227359805.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/8e6781227359805.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/953zg1227359805.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/10n7kh1227359805.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/11lxi11227359805.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/12q4hj1227359805.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/13hab01227359805.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/14b4ka1227359805.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/15hk0l1227359805.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/16qw961227359805.tab") + } > > system("convert tmp/1dwuq1227359805.ps tmp/1dwuq1227359805.png") > system("convert tmp/2lnm11227359805.ps tmp/2lnm11227359805.png") > system("convert tmp/3xwdm1227359805.ps tmp/3xwdm1227359805.png") > system("convert tmp/4yjvo1227359805.ps tmp/4yjvo1227359805.png") > system("convert tmp/5oom11227359805.ps tmp/5oom11227359805.png") > system("convert tmp/6ea8z1227359805.ps tmp/6ea8z1227359805.png") > system("convert tmp/7w85l1227359805.ps tmp/7w85l1227359805.png") > system("convert tmp/8e6781227359805.ps tmp/8e6781227359805.png") > system("convert tmp/953zg1227359805.ps tmp/953zg1227359805.png") > system("convert tmp/10n7kh1227359805.ps tmp/10n7kh1227359805.png") > > > proc.time() user system elapsed 3.723 2.484 4.065