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.
Natural language support but running in an English locale
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(8.8,8.1,0,8.5,9.9,0,8.6,11.5,0,8.7,23.4,0,9.1,25.4,0,8.8,27.9,0,6.3,26.1,0,2.5,18.8,0,-2.7,14.1,0,-4.5,11.5,0,-7,15.8,0,-9.3,12.4,0,-12.2,4.5,0,-13.2,-2.2,1,-13.7,-4.2,1,-15,-9.4,1,-16.9,-14.5,1,-16.3,-17.9,1,-16.7,-15.1,1,-16,-15.2,1,-14.5,-15.7,1,-12.2,-18,1,-7.5,-18.1,1,-4.4,-13.5,1,-1.1,-9.9,1,1.3,-4.8,1,-0.1,-1.7,0,0.4,-0.1,0,2.4,2.2,0,1,10.2,0,3.3,7.6,0,1.8,10.8,0,3.2,3.8,0,1.3,11,0,1.5,10.8,0,1.3,20.1,0,2,14.9,0,3,13,0,4.4,10.9,0,3.1,9.6,0,2.6,4,0,2.7,-1.1,0,4,-7.7,0,4.1,-8.9,0,3,-8,0,2.7,-7.1,0,4,-5.3,0,4.8,-2.5,0,6,-2.4,0,4.6,-2.9,0,4.4,-4.8,0,6.6,-7.2,0,4.7,1.7,0,7.6,2.2,0,5.3,13.4,0,6.6,12.3,0,4,13.7,0,3.8,4.4,0,1.2,-2.5,0),dim=c(3,59),dimnames=list(c('Industriële_productie','registratie_personenwagens','crisis'),1:59))
> y <- array(NA,dim=c(3,59),dimnames=list(c('Industriële_productie','registratie_personenwagens','crisis'),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 = 'No Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '1'
> 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
Industriële_productie registratie_personenwagens crisis
1 8.8 8.1 0
2 8.5 9.9 0
3 8.6 11.5 0
4 8.7 23.4 0
5 9.1 25.4 0
6 8.8 27.9 0
7 6.3 26.1 0
8 2.5 18.8 0
9 -2.7 14.1 0
10 -4.5 11.5 0
11 -7.0 15.8 0
12 -9.3 12.4 0
13 -12.2 4.5 0
14 -13.2 -2.2 1
15 -13.7 -4.2 1
16 -15.0 -9.4 1
17 -16.9 -14.5 1
18 -16.3 -17.9 1
19 -16.7 -15.1 1
20 -16.0 -15.2 1
21 -14.5 -15.7 1
22 -12.2 -18.0 1
23 -7.5 -18.1 1
24 -4.4 -13.5 1
25 -1.1 -9.9 1
26 1.3 -4.8 1
27 -0.1 -1.7 0
28 0.4 -0.1 0
29 2.4 2.2 0
30 1.0 10.2 0
31 3.3 7.6 0
32 1.8 10.8 0
33 3.2 3.8 0
34 1.3 11.0 0
35 1.5 10.8 0
36 1.3 20.1 0
37 2.0 14.9 0
38 3.0 13.0 0
39 4.4 10.9 0
40 3.1 9.6 0
41 2.6 4.0 0
42 2.7 -1.1 0
43 4.0 -7.7 0
44 4.1 -8.9 0
45 3.0 -8.0 0
46 2.7 -7.1 0
47 4.0 -5.3 0
48 4.8 -2.5 0
49 6.0 -2.4 0
50 4.6 -2.9 0
51 4.4 -4.8 0
52 6.6 -7.2 0
53 4.7 1.7 0
54 7.6 2.2 0
55 5.3 13.4 0
56 6.6 12.3 0
57 4.0 13.7 0
58 3.8 4.4 0
59 1.2 -2.5 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) registratie_personenwagens
2.63558 0.04837
crisis
-13.29196
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-15.0533 -2.2693 0.2968 2.3436 12.1886
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.63558 0.88421 2.981 0.00425 **
registratie_personenwagens 0.04837 0.07211 0.671 0.50512
crisis -13.29196 2.07419 -6.408 3.27e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.91 on 56 degrees of freedom
Multiple R-squared: 0.6042, Adjusted R-squared: 0.59
F-statistic: 42.74 on 2 and 56 DF, p-value: 5.368e-12
> 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.000136104 2.722080e-04 9.998639e-01
[2,] 0.006177298 1.235460e-02 9.938227e-01
[3,] 0.098749562 1.974991e-01 9.012504e-01
[4,] 0.529766158 9.404677e-01 4.702338e-01
[5,] 0.775370746 4.492585e-01 2.246293e-01
[6,] 0.941714688 1.165706e-01 5.828531e-02
[7,] 0.991746137 1.650773e-02 8.253863e-03
[8,] 0.999644481 7.110373e-04 3.555186e-04
[9,] 0.999271230 1.457540e-03 7.287699e-04
[10,] 0.998665642 2.668717e-03 1.334358e-03
[11,] 0.998069575 3.860850e-03 1.930425e-03
[12,] 0.998206269 3.587462e-03 1.793731e-03
[13,] 0.998628358 2.743285e-03 1.371642e-03
[14,] 0.999348107 1.303785e-03 6.518926e-04
[15,] 0.999842307 3.153867e-04 1.576934e-04
[16,] 0.999985369 2.926193e-05 1.463096e-05
[17,] 0.999999695 6.093284e-07 3.046642e-07
[18,] 0.999999987 2.569734e-08 1.284867e-08
[19,] 0.999999998 3.432719e-09 1.716360e-09
[20,] 0.999999999 1.485306e-09 7.426529e-10
[21,] 0.999999999 1.527511e-09 7.637553e-10
[22,] 1.000000000 6.368317e-10 3.184158e-10
[23,] 1.000000000 4.020108e-10 2.010054e-10
[24,] 1.000000000 9.926983e-10 4.963492e-10
[25,] 0.999999999 1.747251e-09 8.736256e-10
[26,] 0.999999997 6.080864e-09 3.040432e-09
[27,] 0.999999992 1.580629e-08 7.903143e-09
[28,] 0.999999976 4.813520e-08 2.406760e-08
[29,] 0.999999957 8.510161e-08 4.255081e-08
[30,] 0.999999925 1.494904e-07 7.474518e-08
[31,] 0.999999903 1.943447e-07 9.717235e-08
[32,] 0.999999852 2.952617e-07 1.476309e-07
[33,] 0.999999650 6.990081e-07 3.495041e-07
[34,] 0.999998821 2.358079e-06 1.179040e-06
[35,] 0.999997422 5.155592e-06 2.577796e-06
[36,] 0.999995787 8.426978e-06 4.213489e-06
[37,] 0.999992042 1.591649e-05 7.958246e-06
[38,] 0.999976638 4.672450e-05 2.336225e-05
[39,] 0.999929901 1.401974e-04 7.009872e-05
[40,] 0.999820684 3.586328e-04 1.793164e-04
[41,] 0.999641554 7.168927e-04 3.584464e-04
[42,] 0.998988339 2.023322e-03 1.011661e-03
[43,] 0.997060037 5.879926e-03 2.939963e-03
[44,] 0.993116540 1.376692e-02 6.883460e-03
[45,] 0.981527714 3.694457e-02 1.847229e-02
[46,] 0.953979048 9.204190e-02 4.602095e-02
[47,] 0.932075881 1.358482e-01 6.792412e-02
[48,] 0.840268671 3.194627e-01 1.597313e-01
> postscript(file="/var/www/html/freestat/rcomp/tmp/1pinr1292948656.ps",horizontal=F,onefile=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/2pinr1292948656.ps",horizontal=F,onefile=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/3pinr1292948656.ps",horizontal=F,onefile=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/4hrmc1292948656.ps",horizontal=F,onefile=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/5hrmc1292948656.ps",horizontal=F,onefile=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
5.772595e+00 5.385524e+00 5.408127e+00 4.932486e+00 5.235739e+00
6 7 8 9 10
4.814807e+00 2.401878e+00 -1.044998e+00 -6.017644e+00 -7.691873e+00
11 12 13 14 15
-1.039988e+01 -1.253541e+01 -1.505326e+01 -2.437206e+00 -2.840459e+00
16 17 18 19 20
-3.888919e+00 -5.542216e+00 -4.777747e+00 -5.313192e+00 -4.608355e+00
21 22 23 24 25
-3.084168e+00 -6.729096e-01 4.031928e+00 6.909411e+00 1.003527e+01
26 27 28 29 30
1.218856e+01 -2.653347e+00 -2.230745e+00 -3.420028e-01 -2.128988e+00
31 32 33 34 35
2.967820e-01 -1.358012e+00 3.806001e-01 -1.867687e+00 -1.658012e+00
36 37 38 39 40
-2.307883e+00 -1.356342e+00 -2.644331e-01 1.237151e+00 3.565010e-05
41 42 43 44 45
-2.290746e-01 1.176286e-01 1.736892e+00 1.894939e+00 7.514035e-01
46 47 48 49 50
4.078677e-01 1.620796e+00 2.285351e+00 3.480514e+00 2.104700e+00
51 52 53 54 55
1.996609e+00 4.312705e+00 1.982184e+00 4.857997e+00 2.016218e+00
56 57 58 59
3.369428e+00 7.017056e-01 9.515762e-01 -1.314649e+00
> postscript(file="/var/www/html/freestat/rcomp/tmp/6hrmc1292948656.ps",horizontal=F,onefile=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 5.772595e+00 NA
1 5.385524e+00 5.772595e+00
2 5.408127e+00 5.385524e+00
3 4.932486e+00 5.408127e+00
4 5.235739e+00 4.932486e+00
5 4.814807e+00 5.235739e+00
6 2.401878e+00 4.814807e+00
7 -1.044998e+00 2.401878e+00
8 -6.017644e+00 -1.044998e+00
9 -7.691873e+00 -6.017644e+00
10 -1.039988e+01 -7.691873e+00
11 -1.253541e+01 -1.039988e+01
12 -1.505326e+01 -1.253541e+01
13 -2.437206e+00 -1.505326e+01
14 -2.840459e+00 -2.437206e+00
15 -3.888919e+00 -2.840459e+00
16 -5.542216e+00 -3.888919e+00
17 -4.777747e+00 -5.542216e+00
18 -5.313192e+00 -4.777747e+00
19 -4.608355e+00 -5.313192e+00
20 -3.084168e+00 -4.608355e+00
21 -6.729096e-01 -3.084168e+00
22 4.031928e+00 -6.729096e-01
23 6.909411e+00 4.031928e+00
24 1.003527e+01 6.909411e+00
25 1.218856e+01 1.003527e+01
26 -2.653347e+00 1.218856e+01
27 -2.230745e+00 -2.653347e+00
28 -3.420028e-01 -2.230745e+00
29 -2.128988e+00 -3.420028e-01
30 2.967820e-01 -2.128988e+00
31 -1.358012e+00 2.967820e-01
32 3.806001e-01 -1.358012e+00
33 -1.867687e+00 3.806001e-01
34 -1.658012e+00 -1.867687e+00
35 -2.307883e+00 -1.658012e+00
36 -1.356342e+00 -2.307883e+00
37 -2.644331e-01 -1.356342e+00
38 1.237151e+00 -2.644331e-01
39 3.565010e-05 1.237151e+00
40 -2.290746e-01 3.565010e-05
41 1.176286e-01 -2.290746e-01
42 1.736892e+00 1.176286e-01
43 1.894939e+00 1.736892e+00
44 7.514035e-01 1.894939e+00
45 4.078677e-01 7.514035e-01
46 1.620796e+00 4.078677e-01
47 2.285351e+00 1.620796e+00
48 3.480514e+00 2.285351e+00
49 2.104700e+00 3.480514e+00
50 1.996609e+00 2.104700e+00
51 4.312705e+00 1.996609e+00
52 1.982184e+00 4.312705e+00
53 4.857997e+00 1.982184e+00
54 2.016218e+00 4.857997e+00
55 3.369428e+00 2.016218e+00
56 7.017056e-01 3.369428e+00
57 9.515762e-01 7.017056e-01
58 -1.314649e+00 9.515762e-01
59 NA -1.314649e+00
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 5.385524e+00 5.772595e+00
[2,] 5.408127e+00 5.385524e+00
[3,] 4.932486e+00 5.408127e+00
[4,] 5.235739e+00 4.932486e+00
[5,] 4.814807e+00 5.235739e+00
[6,] 2.401878e+00 4.814807e+00
[7,] -1.044998e+00 2.401878e+00
[8,] -6.017644e+00 -1.044998e+00
[9,] -7.691873e+00 -6.017644e+00
[10,] -1.039988e+01 -7.691873e+00
[11,] -1.253541e+01 -1.039988e+01
[12,] -1.505326e+01 -1.253541e+01
[13,] -2.437206e+00 -1.505326e+01
[14,] -2.840459e+00 -2.437206e+00
[15,] -3.888919e+00 -2.840459e+00
[16,] -5.542216e+00 -3.888919e+00
[17,] -4.777747e+00 -5.542216e+00
[18,] -5.313192e+00 -4.777747e+00
[19,] -4.608355e+00 -5.313192e+00
[20,] -3.084168e+00 -4.608355e+00
[21,] -6.729096e-01 -3.084168e+00
[22,] 4.031928e+00 -6.729096e-01
[23,] 6.909411e+00 4.031928e+00
[24,] 1.003527e+01 6.909411e+00
[25,] 1.218856e+01 1.003527e+01
[26,] -2.653347e+00 1.218856e+01
[27,] -2.230745e+00 -2.653347e+00
[28,] -3.420028e-01 -2.230745e+00
[29,] -2.128988e+00 -3.420028e-01
[30,] 2.967820e-01 -2.128988e+00
[31,] -1.358012e+00 2.967820e-01
[32,] 3.806001e-01 -1.358012e+00
[33,] -1.867687e+00 3.806001e-01
[34,] -1.658012e+00 -1.867687e+00
[35,] -2.307883e+00 -1.658012e+00
[36,] -1.356342e+00 -2.307883e+00
[37,] -2.644331e-01 -1.356342e+00
[38,] 1.237151e+00 -2.644331e-01
[39,] 3.565010e-05 1.237151e+00
[40,] -2.290746e-01 3.565010e-05
[41,] 1.176286e-01 -2.290746e-01
[42,] 1.736892e+00 1.176286e-01
[43,] 1.894939e+00 1.736892e+00
[44,] 7.514035e-01 1.894939e+00
[45,] 4.078677e-01 7.514035e-01
[46,] 1.620796e+00 4.078677e-01
[47,] 2.285351e+00 1.620796e+00
[48,] 3.480514e+00 2.285351e+00
[49,] 2.104700e+00 3.480514e+00
[50,] 1.996609e+00 2.104700e+00
[51,] 4.312705e+00 1.996609e+00
[52,] 1.982184e+00 4.312705e+00
[53,] 4.857997e+00 1.982184e+00
[54,] 2.016218e+00 4.857997e+00
[55,] 3.369428e+00 2.016218e+00
[56,] 7.017056e-01 3.369428e+00
[57,] 9.515762e-01 7.017056e-01
[58,] -1.314649e+00 9.515762e-01
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 5.385524e+00 5.772595e+00
2 5.408127e+00 5.385524e+00
3 4.932486e+00 5.408127e+00
4 5.235739e+00 4.932486e+00
5 4.814807e+00 5.235739e+00
6 2.401878e+00 4.814807e+00
7 -1.044998e+00 2.401878e+00
8 -6.017644e+00 -1.044998e+00
9 -7.691873e+00 -6.017644e+00
10 -1.039988e+01 -7.691873e+00
11 -1.253541e+01 -1.039988e+01
12 -1.505326e+01 -1.253541e+01
13 -2.437206e+00 -1.505326e+01
14 -2.840459e+00 -2.437206e+00
15 -3.888919e+00 -2.840459e+00
16 -5.542216e+00 -3.888919e+00
17 -4.777747e+00 -5.542216e+00
18 -5.313192e+00 -4.777747e+00
19 -4.608355e+00 -5.313192e+00
20 -3.084168e+00 -4.608355e+00
21 -6.729096e-01 -3.084168e+00
22 4.031928e+00 -6.729096e-01
23 6.909411e+00 4.031928e+00
24 1.003527e+01 6.909411e+00
25 1.218856e+01 1.003527e+01
26 -2.653347e+00 1.218856e+01
27 -2.230745e+00 -2.653347e+00
28 -3.420028e-01 -2.230745e+00
29 -2.128988e+00 -3.420028e-01
30 2.967820e-01 -2.128988e+00
31 -1.358012e+00 2.967820e-01
32 3.806001e-01 -1.358012e+00
33 -1.867687e+00 3.806001e-01
34 -1.658012e+00 -1.867687e+00
35 -2.307883e+00 -1.658012e+00
36 -1.356342e+00 -2.307883e+00
37 -2.644331e-01 -1.356342e+00
38 1.237151e+00 -2.644331e-01
39 3.565010e-05 1.237151e+00
40 -2.290746e-01 3.565010e-05
41 1.176286e-01 -2.290746e-01
42 1.736892e+00 1.176286e-01
43 1.894939e+00 1.736892e+00
44 7.514035e-01 1.894939e+00
45 4.078677e-01 7.514035e-01
46 1.620796e+00 4.078677e-01
47 2.285351e+00 1.620796e+00
48 3.480514e+00 2.285351e+00
49 2.104700e+00 3.480514e+00
50 1.996609e+00 2.104700e+00
51 4.312705e+00 1.996609e+00
52 1.982184e+00 4.312705e+00
53 4.857997e+00 1.982184e+00
54 2.016218e+00 4.857997e+00
55 3.369428e+00 2.016218e+00
56 7.017056e-01 3.369428e+00
57 9.515762e-01 7.017056e-01
58 -1.314649e+00 9.515762e-01
> 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/7a04f1292948656.ps",horizontal=F,onefile=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/8a04f1292948656.ps",horizontal=F,onefile=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/9lr301292948656.ps",horizontal=F,onefile=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/10lr301292948656.ps",horizontal=F,onefile=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/11oa161292948656.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/129s0b1292948656.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/13ytxn1292948656.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/146y6r1292948657.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/15nvf91292948657.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/16j5d01292948657.tab")
+ }
>
> try(system("convert tmp/1pinr1292948656.ps tmp/1pinr1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/2pinr1292948656.ps tmp/2pinr1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/3pinr1292948656.ps tmp/3pinr1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/4hrmc1292948656.ps tmp/4hrmc1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/5hrmc1292948656.ps tmp/5hrmc1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/6hrmc1292948656.ps tmp/6hrmc1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/7a04f1292948656.ps tmp/7a04f1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/8a04f1292948656.ps tmp/8a04f1292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/9lr301292948656.ps tmp/9lr301292948656.png",intern=TRUE))
character(0)
> try(system("convert tmp/10lr301292948656.ps tmp/10lr301292948656.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
4.119 2.612 5.466