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(277128
+ ,0
+ ,277915
+ ,286602
+ ,277103
+ ,0
+ ,277128
+ ,283042
+ ,275037
+ ,0
+ ,277103
+ ,276687
+ ,270150
+ ,0
+ ,275037
+ ,277915
+ ,267140
+ ,0
+ ,270150
+ ,277128
+ ,264993
+ ,0
+ ,267140
+ ,277103
+ ,287259
+ ,0
+ ,264993
+ ,275037
+ ,291186
+ ,0
+ ,287259
+ ,270150
+ ,292300
+ ,0
+ ,291186
+ ,267140
+ ,288186
+ ,0
+ ,292300
+ ,264993
+ ,281477
+ ,0
+ ,288186
+ ,287259
+ ,282656
+ ,0
+ ,281477
+ ,291186
+ ,280190
+ ,0
+ ,282656
+ ,292300
+ ,280408
+ ,0
+ ,280190
+ ,288186
+ ,276836
+ ,0
+ ,280408
+ ,281477
+ ,275216
+ ,0
+ ,276836
+ ,282656
+ ,274352
+ ,0
+ ,275216
+ ,280190
+ ,271311
+ ,0
+ ,274352
+ ,280408
+ ,289802
+ ,0
+ ,271311
+ ,276836
+ ,290726
+ ,0
+ ,289802
+ ,275216
+ ,292300
+ ,0
+ ,290726
+ ,274352
+ ,278506
+ ,0
+ ,292300
+ ,271311
+ ,269826
+ ,0
+ ,278506
+ ,289802
+ ,265861
+ ,0
+ ,269826
+ ,290726
+ ,269034
+ ,0
+ ,265861
+ ,292300
+ ,264176
+ ,0
+ ,269034
+ ,278506
+ ,255198
+ ,0
+ ,264176
+ ,269826
+ ,253353
+ ,0
+ ,255198
+ ,265861
+ ,246057
+ ,0
+ ,253353
+ ,269034
+ ,235372
+ ,0
+ ,246057
+ ,264176
+ ,258556
+ ,0
+ ,235372
+ ,255198
+ ,260993
+ ,0
+ ,258556
+ ,253353
+ ,254663
+ ,0
+ ,260993
+ ,246057
+ ,250643
+ ,0
+ ,254663
+ ,235372
+ ,243422
+ ,0
+ ,250643
+ ,258556
+ ,247105
+ ,0
+ ,243422
+ ,260993
+ ,248541
+ ,0
+ ,247105
+ ,254663
+ ,245039
+ ,0
+ ,248541
+ ,250643
+ ,237080
+ ,0
+ ,245039
+ ,243422
+ ,237085
+ ,0
+ ,237080
+ ,247105
+ ,225554
+ ,0
+ ,237085
+ ,248541
+ ,226839
+ ,1
+ ,225554
+ ,245039
+ ,247934
+ ,1
+ ,226839
+ ,237080
+ ,248333
+ ,1
+ ,247934
+ ,237085
+ ,246969
+ ,1
+ ,248333
+ ,225554
+ ,245098
+ ,1
+ ,246969
+ ,226839
+ ,246263
+ ,1
+ ,245098
+ ,247934
+ ,255765
+ ,1
+ ,246263
+ ,248333
+ ,264319
+ ,1
+ ,255765
+ ,246969
+ ,268347
+ ,1
+ ,264319
+ ,245098
+ ,273046
+ ,1
+ ,268347
+ ,246263
+ ,273963
+ ,1
+ ,273046
+ ,255765
+ ,267430
+ ,1
+ ,273963
+ ,264319
+ ,271993
+ ,1
+ ,267430
+ ,268347
+ ,292710
+ ,1
+ ,271993
+ ,273046
+ ,295881
+ ,1
+ ,292710
+ ,273963)
+ ,dim=c(4
+ ,56)
+ ,dimnames=list(c('nwwmb'
+ ,'dummy_variable'
+ ,'y[t-1]'
+ ,'y[t-4]
')
+ ,1:56))
> y <- array(NA,dim=c(4,56),dimnames=list(c('nwwmb','dummy_variable','y[t-1]','y[t-4]
'),1:56))
> 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
nwwmb dummy_variable y[t-1] y[t-4]\r M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 277128 0 277915 286602 1 0 0 0 0 0 0 0 0 0 0 1
2 277103 0 277128 283042 0 1 0 0 0 0 0 0 0 0 0 2
3 275037 0 277103 276687 0 0 1 0 0 0 0 0 0 0 0 3
4 270150 0 275037 277915 0 0 0 1 0 0 0 0 0 0 0 4
5 267140 0 270150 277128 0 0 0 0 1 0 0 0 0 0 0 5
6 264993 0 267140 277103 0 0 0 0 0 1 0 0 0 0 0 6
7 287259 0 264993 275037 0 0 0 0 0 0 1 0 0 0 0 7
8 291186 0 287259 270150 0 0 0 0 0 0 0 1 0 0 0 8
9 292300 0 291186 267140 0 0 0 0 0 0 0 0 1 0 0 9
10 288186 0 292300 264993 0 0 0 0 0 0 0 0 0 1 0 10
11 281477 0 288186 287259 0 0 0 0 0 0 0 0 0 0 1 11
12 282656 0 281477 291186 0 0 0 0 0 0 0 0 0 0 0 12
13 280190 0 282656 292300 1 0 0 0 0 0 0 0 0 0 0 13
14 280408 0 280190 288186 0 1 0 0 0 0 0 0 0 0 0 14
15 276836 0 280408 281477 0 0 1 0 0 0 0 0 0 0 0 15
16 275216 0 276836 282656 0 0 0 1 0 0 0 0 0 0 0 16
17 274352 0 275216 280190 0 0 0 0 1 0 0 0 0 0 0 17
18 271311 0 274352 280408 0 0 0 0 0 1 0 0 0 0 0 18
19 289802 0 271311 276836 0 0 0 0 0 0 1 0 0 0 0 19
20 290726 0 289802 275216 0 0 0 0 0 0 0 1 0 0 0 20
21 292300 0 290726 274352 0 0 0 0 0 0 0 0 1 0 0 21
22 278506 0 292300 271311 0 0 0 0 0 0 0 0 0 1 0 22
23 269826 0 278506 289802 0 0 0 0 0 0 0 0 0 0 1 23
24 265861 0 269826 290726 0 0 0 0 0 0 0 0 0 0 0 24
25 269034 0 265861 292300 1 0 0 0 0 0 0 0 0 0 0 25
26 264176 0 269034 278506 0 1 0 0 0 0 0 0 0 0 0 26
27 255198 0 264176 269826 0 0 1 0 0 0 0 0 0 0 0 27
28 253353 0 255198 265861 0 0 0 1 0 0 0 0 0 0 0 28
29 246057 0 253353 269034 0 0 0 0 1 0 0 0 0 0 0 29
30 235372 0 246057 264176 0 0 0 0 0 1 0 0 0 0 0 30
31 258556 0 235372 255198 0 0 0 0 0 0 1 0 0 0 0 31
32 260993 0 258556 253353 0 0 0 0 0 0 0 1 0 0 0 32
33 254663 0 260993 246057 0 0 0 0 0 0 0 0 1 0 0 33
34 250643 0 254663 235372 0 0 0 0 0 0 0 0 0 1 0 34
35 243422 0 250643 258556 0 0 0 0 0 0 0 0 0 0 1 35
36 247105 0 243422 260993 0 0 0 0 0 0 0 0 0 0 0 36
37 248541 0 247105 254663 1 0 0 0 0 0 0 0 0 0 0 37
38 245039 0 248541 250643 0 1 0 0 0 0 0 0 0 0 0 38
39 237080 0 245039 243422 0 0 1 0 0 0 0 0 0 0 0 39
40 237085 0 237080 247105 0 0 0 1 0 0 0 0 0 0 0 40
41 225554 0 237085 248541 0 0 0 0 1 0 0 0 0 0 0 41
42 226839 1 225554 245039 0 0 0 0 0 1 0 0 0 0 0 42
43 247934 1 226839 237080 0 0 0 0 0 0 1 0 0 0 0 43
44 248333 1 247934 237085 0 0 0 0 0 0 0 1 0 0 0 44
45 246969 1 248333 225554 0 0 0 0 0 0 0 0 1 0 0 45
46 245098 1 246969 226839 0 0 0 0 0 0 0 0 0 1 0 46
47 246263 1 245098 247934 0 0 0 0 0 0 0 0 0 0 1 47
48 255765 1 246263 248333 0 0 0 0 0 0 0 0 0 0 0 48
49 264319 1 255765 246969 1 0 0 0 0 0 0 0 0 0 0 49
50 268347 1 264319 245098 0 1 0 0 0 0 0 0 0 0 0 50
51 273046 1 268347 246263 0 0 1 0 0 0 0 0 0 0 0 51
52 273963 1 273046 255765 0 0 0 1 0 0 0 0 0 0 0 52
53 267430 1 273963 264319 0 0 0 0 1 0 0 0 0 0 0 53
54 271993 1 267430 268347 0 0 0 0 0 1 0 0 0 0 0 54
55 292710 1 271993 273046 0 0 0 0 0 0 1 0 0 0 0 55
56 295881 1 292710 273963 0 0 0 0 0 0 0 1 0 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) dummy_variable `y[t-1]` `y[t-4]\r` M1
1.859e+04 5.070e+03 1.093e+00 -1.417e-01 -1.114e+03
M2 M3 M4 M5 M6
-4.788e+03 -8.151e+03 -5.304e+03 -9.151e+03 -5.801e+03
M7 M8 M9 M10 M11
1.713e+04 -3.934e+03 -8.074e+03 -1.308e+04 -8.828e+03
t
-9.507e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6117.9 -2103.2 424.5 2134.5 5370.0
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.859e+04 1.285e+04 1.447 0.155753
dummy_variable 5.070e+03 2.021e+03 2.509 0.016258 *
`y[t-1]` 1.093e+00 7.659e-02 14.273 < 2e-16 ***
`y[t-4]\r` -1.417e-01 9.166e-02 -1.546 0.130032
M1 -1.114e+03 2.362e+03 -0.472 0.639840
M2 -4.788e+03 2.525e+03 -1.896 0.065191 .
M3 -8.151e+03 2.721e+03 -2.995 0.004688 **
M4 -5.304e+03 2.511e+03 -2.113 0.040931 *
M5 -9.151e+03 2.419e+03 -3.784 0.000507 ***
M6 -5.801e+03 2.359e+03 -2.459 0.018342 *
M7 1.713e+04 2.374e+03 7.216 9.4e-09 ***
M8 -3.934e+03 3.024e+03 -1.301 0.200671
M9 -8.074e+03 3.649e+03 -2.213 0.032689 *
M10 -1.308e+04 3.826e+03 -3.418 0.001463 **
M11 -8.828e+03 2.525e+03 -3.496 0.001173 **
t -9.507e+01 5.495e+01 -1.730 0.091320 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3478 on 40 degrees of freedom
Multiple R-squared: 0.9732, Adjusted R-squared: 0.9632
F-statistic: 96.95 on 15 and 40 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,] 0.1353434 0.2706869 0.8646566
[2,] 0.1109759 0.2219518 0.8890241
[3,] 0.0825155 0.1650310 0.9174845
[4,] 0.3866271 0.7732541 0.6133729
[5,] 0.2632819 0.5265637 0.7367181
[6,] 0.2353628 0.4707257 0.7646372
[7,] 0.3757951 0.7515901 0.6242049
[8,] 0.2949754 0.5899509 0.7050246
[9,] 0.2453514 0.4907028 0.7546486
[10,] 0.2451864 0.4903727 0.7548136
[11,] 0.2263059 0.4526117 0.7736941
[12,] 0.4619594 0.9239188 0.5380406
[13,] 0.6704964 0.6590071 0.3295036
[14,] 0.7734095 0.4531810 0.2265905
[15,] 0.7161660 0.5676680 0.2838340
[16,] 0.8087947 0.3824105 0.1912053
[17,] 0.6945224 0.6109552 0.3054776
[18,] 0.6604566 0.6790868 0.3395434
[19,] 0.6109241 0.7781519 0.3890759
> postscript(file="/var/www/html/rcomp/tmp/14xtk1258920277.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/2tp381258920277.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/37r0u1258920277.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/461yg1258920277.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/5eqqm1258920277.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 = 56
Frequency = 1
1 2 3 4 5 6
-3454.376910 646.226994 1165.208589 -4041.057176 2121.249003 5.972247
7 8 9 10 11 12
1490.421895 1544.668397 2174.269996 1636.683727 -1575.152174 -1238.502826
13 14 15 16 17 18
-3626.919206 2473.599340 1170.790286 870.871465 5369.966140 49.209896
19 20 21 22 23 24
-1477.429677 163.336467 4839.721101 -6007.376757 -1143.324488 -4221.531374
25 26 27 28 29 30
4717.406300 -1793.819974 -3233.030901 1422.841812 534.823538 -6117.931486
31 32 33 34 35 36
4638.578189 2630.297069 -3162.538486 3321.655367 -374.875705 2814.366638
37 38 39 40 41 42
536.035842 -1335.612856 -3031.430402 3444.079352 -3947.369255 1121.290929
43 44 45 46 47 48
-3151.876286 -4652.453660 -3851.452611 1049.037662 3093.352367 2645.667562
49 50 51 52 53 54
1827.853974 9.606496 3928.462427 -1696.735453 -4078.669427 4941.458414
55 56
-1499.694121 314.151727
> postscript(file="/var/www/html/rcomp/tmp/6bbqf1258920277.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 -3454.376910 NA
1 646.226994 -3454.376910
2 1165.208589 646.226994
3 -4041.057176 1165.208589
4 2121.249003 -4041.057176
5 5.972247 2121.249003
6 1490.421895 5.972247
7 1544.668397 1490.421895
8 2174.269996 1544.668397
9 1636.683727 2174.269996
10 -1575.152174 1636.683727
11 -1238.502826 -1575.152174
12 -3626.919206 -1238.502826
13 2473.599340 -3626.919206
14 1170.790286 2473.599340
15 870.871465 1170.790286
16 5369.966140 870.871465
17 49.209896 5369.966140
18 -1477.429677 49.209896
19 163.336467 -1477.429677
20 4839.721101 163.336467
21 -6007.376757 4839.721101
22 -1143.324488 -6007.376757
23 -4221.531374 -1143.324488
24 4717.406300 -4221.531374
25 -1793.819974 4717.406300
26 -3233.030901 -1793.819974
27 1422.841812 -3233.030901
28 534.823538 1422.841812
29 -6117.931486 534.823538
30 4638.578189 -6117.931486
31 2630.297069 4638.578189
32 -3162.538486 2630.297069
33 3321.655367 -3162.538486
34 -374.875705 3321.655367
35 2814.366638 -374.875705
36 536.035842 2814.366638
37 -1335.612856 536.035842
38 -3031.430402 -1335.612856
39 3444.079352 -3031.430402
40 -3947.369255 3444.079352
41 1121.290929 -3947.369255
42 -3151.876286 1121.290929
43 -4652.453660 -3151.876286
44 -3851.452611 -4652.453660
45 1049.037662 -3851.452611
46 3093.352367 1049.037662
47 2645.667562 3093.352367
48 1827.853974 2645.667562
49 9.606496 1827.853974
50 3928.462427 9.606496
51 -1696.735453 3928.462427
52 -4078.669427 -1696.735453
53 4941.458414 -4078.669427
54 -1499.694121 4941.458414
55 314.151727 -1499.694121
56 NA 314.151727
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 646.226994 -3454.376910
[2,] 1165.208589 646.226994
[3,] -4041.057176 1165.208589
[4,] 2121.249003 -4041.057176
[5,] 5.972247 2121.249003
[6,] 1490.421895 5.972247
[7,] 1544.668397 1490.421895
[8,] 2174.269996 1544.668397
[9,] 1636.683727 2174.269996
[10,] -1575.152174 1636.683727
[11,] -1238.502826 -1575.152174
[12,] -3626.919206 -1238.502826
[13,] 2473.599340 -3626.919206
[14,] 1170.790286 2473.599340
[15,] 870.871465 1170.790286
[16,] 5369.966140 870.871465
[17,] 49.209896 5369.966140
[18,] -1477.429677 49.209896
[19,] 163.336467 -1477.429677
[20,] 4839.721101 163.336467
[21,] -6007.376757 4839.721101
[22,] -1143.324488 -6007.376757
[23,] -4221.531374 -1143.324488
[24,] 4717.406300 -4221.531374
[25,] -1793.819974 4717.406300
[26,] -3233.030901 -1793.819974
[27,] 1422.841812 -3233.030901
[28,] 534.823538 1422.841812
[29,] -6117.931486 534.823538
[30,] 4638.578189 -6117.931486
[31,] 2630.297069 4638.578189
[32,] -3162.538486 2630.297069
[33,] 3321.655367 -3162.538486
[34,] -374.875705 3321.655367
[35,] 2814.366638 -374.875705
[36,] 536.035842 2814.366638
[37,] -1335.612856 536.035842
[38,] -3031.430402 -1335.612856
[39,] 3444.079352 -3031.430402
[40,] -3947.369255 3444.079352
[41,] 1121.290929 -3947.369255
[42,] -3151.876286 1121.290929
[43,] -4652.453660 -3151.876286
[44,] -3851.452611 -4652.453660
[45,] 1049.037662 -3851.452611
[46,] 3093.352367 1049.037662
[47,] 2645.667562 3093.352367
[48,] 1827.853974 2645.667562
[49,] 9.606496 1827.853974
[50,] 3928.462427 9.606496
[51,] -1696.735453 3928.462427
[52,] -4078.669427 -1696.735453
[53,] 4941.458414 -4078.669427
[54,] -1499.694121 4941.458414
[55,] 314.151727 -1499.694121
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 646.226994 -3454.376910
2 1165.208589 646.226994
3 -4041.057176 1165.208589
4 2121.249003 -4041.057176
5 5.972247 2121.249003
6 1490.421895 5.972247
7 1544.668397 1490.421895
8 2174.269996 1544.668397
9 1636.683727 2174.269996
10 -1575.152174 1636.683727
11 -1238.502826 -1575.152174
12 -3626.919206 -1238.502826
13 2473.599340 -3626.919206
14 1170.790286 2473.599340
15 870.871465 1170.790286
16 5369.966140 870.871465
17 49.209896 5369.966140
18 -1477.429677 49.209896
19 163.336467 -1477.429677
20 4839.721101 163.336467
21 -6007.376757 4839.721101
22 -1143.324488 -6007.376757
23 -4221.531374 -1143.324488
24 4717.406300 -4221.531374
25 -1793.819974 4717.406300
26 -3233.030901 -1793.819974
27 1422.841812 -3233.030901
28 534.823538 1422.841812
29 -6117.931486 534.823538
30 4638.578189 -6117.931486
31 2630.297069 4638.578189
32 -3162.538486 2630.297069
33 3321.655367 -3162.538486
34 -374.875705 3321.655367
35 2814.366638 -374.875705
36 536.035842 2814.366638
37 -1335.612856 536.035842
38 -3031.430402 -1335.612856
39 3444.079352 -3031.430402
40 -3947.369255 3444.079352
41 1121.290929 -3947.369255
42 -3151.876286 1121.290929
43 -4652.453660 -3151.876286
44 -3851.452611 -4652.453660
45 1049.037662 -3851.452611
46 3093.352367 1049.037662
47 2645.667562 3093.352367
48 1827.853974 2645.667562
49 9.606496 1827.853974
50 3928.462427 9.606496
51 -1696.735453 3928.462427
52 -4078.669427 -1696.735453
53 4941.458414 -4078.669427
54 -1499.694121 4941.458414
55 314.151727 -1499.694121
> 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/7ipdx1258920277.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/8t7sn1258920277.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/91m031258920277.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/109qu81258920277.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/11mwas1258920277.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/12d89z1258920277.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/13cjx01258920277.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/14c0ot1258920277.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/15gj681258920277.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/16wtel1258920277.tab")
+ }
>
> system("convert tmp/14xtk1258920277.ps tmp/14xtk1258920277.png")
> system("convert tmp/2tp381258920277.ps tmp/2tp381258920277.png")
> system("convert tmp/37r0u1258920277.ps tmp/37r0u1258920277.png")
> system("convert tmp/461yg1258920277.ps tmp/461yg1258920277.png")
> system("convert tmp/5eqqm1258920277.ps tmp/5eqqm1258920277.png")
> system("convert tmp/6bbqf1258920277.ps tmp/6bbqf1258920277.png")
> system("convert tmp/7ipdx1258920277.ps tmp/7ipdx1258920277.png")
> system("convert tmp/8t7sn1258920277.ps tmp/8t7sn1258920277.png")
> system("convert tmp/91m031258920277.ps tmp/91m031258920277.png")
> system("convert tmp/109qu81258920277.ps tmp/109qu81258920277.png")
>
>
> proc.time()
user system elapsed
2.393 1.597 3.083