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(102.9
+ ,112.7
+ ,97
+ ,95.1
+ ,97.4
+ ,102.9
+ ,112.7
+ ,97
+ ,111.4
+ ,97.4
+ ,102.9
+ ,112.7
+ ,87.4
+ ,111.4
+ ,97.4
+ ,102.9
+ ,96.8
+ ,87.4
+ ,111.4
+ ,97.4
+ ,114.1
+ ,96.8
+ ,87.4
+ ,111.4
+ ,110.3
+ ,114.1
+ ,96.8
+ ,87.4
+ ,103.9
+ ,110.3
+ ,114.1
+ ,96.8
+ ,101.6
+ ,103.9
+ ,110.3
+ ,114.1
+ ,94.6
+ ,101.6
+ ,103.9
+ ,110.3
+ ,95.9
+ ,94.6
+ ,101.6
+ ,103.9
+ ,104.7
+ ,95.9
+ ,94.6
+ ,101.6
+ ,102.8
+ ,104.7
+ ,95.9
+ ,94.6
+ ,98.1
+ ,102.8
+ ,104.7
+ ,95.9
+ ,113.9
+ ,98.1
+ ,102.8
+ ,104.7
+ ,80.9
+ ,113.9
+ ,98.1
+ ,102.8
+ ,95.7
+ ,80.9
+ ,113.9
+ ,98.1
+ ,113.2
+ ,95.7
+ ,80.9
+ ,113.9
+ ,105.9
+ ,113.2
+ ,95.7
+ ,80.9
+ ,108.8
+ ,105.9
+ ,113.2
+ ,95.7
+ ,102.3
+ ,108.8
+ ,105.9
+ ,113.2
+ ,99
+ ,102.3
+ ,108.8
+ ,105.9
+ ,100.7
+ ,99
+ ,102.3
+ ,108.8
+ ,115.5
+ ,100.7
+ ,99
+ ,102.3
+ ,100.7
+ ,115.5
+ ,100.7
+ ,99
+ ,109.9
+ ,100.7
+ ,115.5
+ ,100.7
+ ,114.6
+ ,109.9
+ ,100.7
+ ,115.5
+ ,85.4
+ ,114.6
+ ,109.9
+ ,100.7
+ ,100.5
+ ,85.4
+ ,114.6
+ ,109.9
+ ,114.8
+ ,100.5
+ ,85.4
+ ,114.6
+ ,116.5
+ ,114.8
+ ,100.5
+ ,85.4
+ ,112.9
+ ,116.5
+ ,114.8
+ ,100.5
+ ,102
+ ,112.9
+ ,116.5
+ ,114.8
+ ,106
+ ,102
+ ,112.9
+ ,116.5
+ ,105.3
+ ,106
+ ,102
+ ,112.9
+ ,118.8
+ ,105.3
+ ,106
+ ,102
+ ,106.1
+ ,118.8
+ ,105.3
+ ,106
+ ,109.3
+ ,106.1
+ ,118.8
+ ,105.3
+ ,117.2
+ ,109.3
+ ,106.1
+ ,118.8
+ ,92.5
+ ,117.2
+ ,109.3
+ ,106.1
+ ,104.2
+ ,92.5
+ ,117.2
+ ,109.3
+ ,112.5
+ ,104.2
+ ,92.5
+ ,117.2
+ ,122.4
+ ,112.5
+ ,104.2
+ ,92.5
+ ,113.3
+ ,122.4
+ ,112.5
+ ,104.2
+ ,100
+ ,113.3
+ ,122.4
+ ,112.5
+ ,110.7
+ ,100
+ ,113.3
+ ,122.4
+ ,112.8
+ ,110.7
+ ,100
+ ,113.3
+ ,109.8
+ ,112.8
+ ,110.7
+ ,100
+ ,117.3
+ ,109.8
+ ,112.8
+ ,110.7
+ ,109.1
+ ,117.3
+ ,109.8
+ ,112.8
+ ,115.9
+ ,109.1
+ ,117.3
+ ,109.8
+ ,96
+ ,115.9
+ ,109.1
+ ,117.3
+ ,99.8
+ ,96
+ ,115.9
+ ,109.1
+ ,116.8
+ ,99.8
+ ,96
+ ,115.9
+ ,115.7
+ ,116.8
+ ,99.8
+ ,96
+ ,99.4
+ ,115.7
+ ,116.8
+ ,99.8
+ ,94.3
+ ,99.4
+ ,115.7
+ ,116.8
+ ,91
+ ,94.3
+ ,99.4
+ ,115.7)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('Y1','Y2','Y3','Y4'),1:58))
> 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 Quarterly 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
Y1 Y2 Y3 Y4 Q1 Q2 Q3 t
1 102.9 112.7 97.0 95.1 1 0 0 1
2 97.4 102.9 112.7 97.0 0 1 0 2
3 111.4 97.4 102.9 112.7 0 0 1 3
4 87.4 111.4 97.4 102.9 0 0 0 4
5 96.8 87.4 111.4 97.4 1 0 0 5
6 114.1 96.8 87.4 111.4 0 1 0 6
7 110.3 114.1 96.8 87.4 0 0 1 7
8 103.9 110.3 114.1 96.8 0 0 0 8
9 101.6 103.9 110.3 114.1 1 0 0 9
10 94.6 101.6 103.9 110.3 0 1 0 10
11 95.9 94.6 101.6 103.9 0 0 1 11
12 104.7 95.9 94.6 101.6 0 0 0 12
13 102.8 104.7 95.9 94.6 1 0 0 13
14 98.1 102.8 104.7 95.9 0 1 0 14
15 113.9 98.1 102.8 104.7 0 0 1 15
16 80.9 113.9 98.1 102.8 0 0 0 16
17 95.7 80.9 113.9 98.1 1 0 0 17
18 113.2 95.7 80.9 113.9 0 1 0 18
19 105.9 113.2 95.7 80.9 0 0 1 19
20 108.8 105.9 113.2 95.7 0 0 0 20
21 102.3 108.8 105.9 113.2 1 0 0 21
22 99.0 102.3 108.8 105.9 0 1 0 22
23 100.7 99.0 102.3 108.8 0 0 1 23
24 115.5 100.7 99.0 102.3 0 0 0 24
25 100.7 115.5 100.7 99.0 1 0 0 25
26 109.9 100.7 115.5 100.7 0 1 0 26
27 114.6 109.9 100.7 115.5 0 0 1 27
28 85.4 114.6 109.9 100.7 0 0 0 28
29 100.5 85.4 114.6 109.9 1 0 0 29
30 114.8 100.5 85.4 114.6 0 1 0 30
31 116.5 114.8 100.5 85.4 0 0 1 31
32 112.9 116.5 114.8 100.5 0 0 0 32
33 102.0 112.9 116.5 114.8 1 0 0 33
34 106.0 102.0 112.9 116.5 0 1 0 34
35 105.3 106.0 102.0 112.9 0 0 1 35
36 118.8 105.3 106.0 102.0 0 0 0 36
37 106.1 118.8 105.3 106.0 1 0 0 37
38 109.3 106.1 118.8 105.3 0 1 0 38
39 117.2 109.3 106.1 118.8 0 0 1 39
40 92.5 117.2 109.3 106.1 0 0 0 40
41 104.2 92.5 117.2 109.3 1 0 0 41
42 112.5 104.2 92.5 117.2 0 1 0 42
43 122.4 112.5 104.2 92.5 0 0 1 43
44 113.3 122.4 112.5 104.2 0 0 0 44
45 100.0 113.3 122.4 112.5 1 0 0 45
46 110.7 100.0 113.3 122.4 0 1 0 46
47 112.8 110.7 100.0 113.3 0 0 1 47
48 109.8 112.8 110.7 100.0 0 0 0 48
49 117.3 109.8 112.8 110.7 1 0 0 49
50 109.1 117.3 109.8 112.8 0 1 0 50
51 115.9 109.1 117.3 109.8 0 0 1 51
52 96.0 115.9 109.1 117.3 0 0 0 52
53 99.8 96.0 115.9 109.1 1 0 0 53
54 116.8 99.8 96.0 115.9 0 1 0 54
55 115.7 116.8 99.8 96.0 0 0 1 55
56 99.4 115.7 116.8 99.8 0 0 0 56
57 94.3 99.4 115.7 116.8 1 0 0 57
58 91.0 94.3 99.4 115.7 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Y2 Y3 Y4 Q1 Q2
116.93961 0.04301 -0.16001 -0.07196 1.00573 4.57015
Q3 t
8.77476 0.16453
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-20.477 -5.275 1.134 5.502 15.709
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 116.93961 29.22315 4.002 0.000208 ***
Y2 0.04301 0.14753 0.292 0.771834
Y3 -0.16001 0.14496 -1.104 0.274956
Y4 -0.07196 0.14995 -0.480 0.633401
Q1 1.00573 3.39148 0.297 0.768040
Q2 4.57015 3.57959 1.277 0.207597
Q3 8.77476 3.30308 2.657 0.010568 *
t 0.16453 0.08254 1.993 0.051703 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 8.396 on 50 degrees of freedom
Multiple R-squared: 0.2589, Adjusted R-squared: 0.1551
F-statistic: 2.495 on 7 and 50 DF, p-value: 0.02802
> 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.8775485 0.2449030 0.1224515
[2,] 0.8197325 0.3605349 0.1802675
[3,] 0.7112027 0.5775946 0.2887973
[4,] 0.6049158 0.7901683 0.3950842
[5,] 0.5546441 0.8907119 0.4453559
[6,] 0.7817609 0.4364783 0.2182391
[7,] 0.7046295 0.5907410 0.2953705
[8,] 0.6454649 0.7090703 0.3545351
[9,] 0.5894289 0.8211422 0.4105711
[10,] 0.7255723 0.5488555 0.2744277
[11,] 0.6420903 0.7158194 0.3579097
[12,] 0.5926593 0.8146814 0.4073407
[13,] 0.6032286 0.7935429 0.3967714
[14,] 0.6934720 0.6130561 0.3065280
[15,] 0.6377425 0.7245149 0.3622575
[16,] 0.5918972 0.8162055 0.4081028
[17,] 0.5237808 0.9524385 0.4762192
[18,] 0.7973398 0.4053204 0.2026602
[19,] 0.7392694 0.5214611 0.2607306
[20,] 0.6697963 0.6604074 0.3302037
[21,] 0.6604280 0.6791441 0.3395720
[22,] 0.6696888 0.6606223 0.3303112
[23,] 0.5945342 0.8109317 0.4054658
[24,] 0.5180767 0.9638467 0.4819233
[25,] 0.5780697 0.8438605 0.4219303
[26,] 0.6561128 0.6877745 0.3438872
[27,] 0.6105640 0.7788720 0.3894360
[28,] 0.5398012 0.9203976 0.4601988
[29,] 0.4515967 0.9031934 0.5484033
[30,] 0.6976344 0.6047313 0.3023656
[31,] 0.6150394 0.7699212 0.3849606
[32,] 0.5356693 0.9286615 0.4643307
[33,] 0.4827820 0.9655639 0.5172180
[34,] 0.3769664 0.7539327 0.6230336
[35,] 0.4848885 0.9697770 0.5151115
[36,] 0.3399351 0.6798702 0.6600649
[37,] 0.3237639 0.6475277 0.6762361
> postscript(file="/var/www/html/rcomp/tmp/12a8s1258575180.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/2qq0f1258575180.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/3q01t1258575180.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/4qqaa1258575180.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/5rby51258575180.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 = 58
Frequency = 1
1 2 3 4 5
2.307053045 -3.851429990 5.577629269 -11.999609638 -0.893134414
6 7 8 9 10
9.440692141 0.304521835 6.122844358 3.564703911 -8.362843128
11 12 13 14 15
-11.959456299 4.109252255 0.364767260 -6.480792084 5.481444554
16 17 18 19 20
-20.476732735 -3.237542180 5.753416090 -6.674915684 9.014536188
21 22 23 24 25
1.310712581 -5.499908967 -8.858510806 13.482813886 -3.089500409
26 27 28 29 30
5.508681763 4.140608511 -16.244201034 0.355618769 5.942979054
31 32 33 34 35
2.973739484 11.285612229 0.671229540 0.957412756 -6.286981678
36 37 38 39 40
15.709053955 1.433926042 3.561060410 5.893551275 -10.937868543
41 42 43 44 45
2.148678034 2.832613862 8.101227108 9.355646303 -2.541805018
46 47 48 49 50
4.257601521 -1.254791623 5.020193133 12.584955232 0.004476145
51 52 53 54 55
3.772270566 -8.582414934 -4.598681404 5.813972521 -1.210336511
56 57 58
-5.859125425 -10.380980989 -19.877932095
> postscript(file="/var/www/html/rcomp/tmp/6qenm1258575180.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 2.307053045 NA
1 -3.851429990 2.307053045
2 5.577629269 -3.851429990
3 -11.999609638 5.577629269
4 -0.893134414 -11.999609638
5 9.440692141 -0.893134414
6 0.304521835 9.440692141
7 6.122844358 0.304521835
8 3.564703911 6.122844358
9 -8.362843128 3.564703911
10 -11.959456299 -8.362843128
11 4.109252255 -11.959456299
12 0.364767260 4.109252255
13 -6.480792084 0.364767260
14 5.481444554 -6.480792084
15 -20.476732735 5.481444554
16 -3.237542180 -20.476732735
17 5.753416090 -3.237542180
18 -6.674915684 5.753416090
19 9.014536188 -6.674915684
20 1.310712581 9.014536188
21 -5.499908967 1.310712581
22 -8.858510806 -5.499908967
23 13.482813886 -8.858510806
24 -3.089500409 13.482813886
25 5.508681763 -3.089500409
26 4.140608511 5.508681763
27 -16.244201034 4.140608511
28 0.355618769 -16.244201034
29 5.942979054 0.355618769
30 2.973739484 5.942979054
31 11.285612229 2.973739484
32 0.671229540 11.285612229
33 0.957412756 0.671229540
34 -6.286981678 0.957412756
35 15.709053955 -6.286981678
36 1.433926042 15.709053955
37 3.561060410 1.433926042
38 5.893551275 3.561060410
39 -10.937868543 5.893551275
40 2.148678034 -10.937868543
41 2.832613862 2.148678034
42 8.101227108 2.832613862
43 9.355646303 8.101227108
44 -2.541805018 9.355646303
45 4.257601521 -2.541805018
46 -1.254791623 4.257601521
47 5.020193133 -1.254791623
48 12.584955232 5.020193133
49 0.004476145 12.584955232
50 3.772270566 0.004476145
51 -8.582414934 3.772270566
52 -4.598681404 -8.582414934
53 5.813972521 -4.598681404
54 -1.210336511 5.813972521
55 -5.859125425 -1.210336511
56 -10.380980989 -5.859125425
57 -19.877932095 -10.380980989
58 NA -19.877932095
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -3.851429990 2.307053045
[2,] 5.577629269 -3.851429990
[3,] -11.999609638 5.577629269
[4,] -0.893134414 -11.999609638
[5,] 9.440692141 -0.893134414
[6,] 0.304521835 9.440692141
[7,] 6.122844358 0.304521835
[8,] 3.564703911 6.122844358
[9,] -8.362843128 3.564703911
[10,] -11.959456299 -8.362843128
[11,] 4.109252255 -11.959456299
[12,] 0.364767260 4.109252255
[13,] -6.480792084 0.364767260
[14,] 5.481444554 -6.480792084
[15,] -20.476732735 5.481444554
[16,] -3.237542180 -20.476732735
[17,] 5.753416090 -3.237542180
[18,] -6.674915684 5.753416090
[19,] 9.014536188 -6.674915684
[20,] 1.310712581 9.014536188
[21,] -5.499908967 1.310712581
[22,] -8.858510806 -5.499908967
[23,] 13.482813886 -8.858510806
[24,] -3.089500409 13.482813886
[25,] 5.508681763 -3.089500409
[26,] 4.140608511 5.508681763
[27,] -16.244201034 4.140608511
[28,] 0.355618769 -16.244201034
[29,] 5.942979054 0.355618769
[30,] 2.973739484 5.942979054
[31,] 11.285612229 2.973739484
[32,] 0.671229540 11.285612229
[33,] 0.957412756 0.671229540
[34,] -6.286981678 0.957412756
[35,] 15.709053955 -6.286981678
[36,] 1.433926042 15.709053955
[37,] 3.561060410 1.433926042
[38,] 5.893551275 3.561060410
[39,] -10.937868543 5.893551275
[40,] 2.148678034 -10.937868543
[41,] 2.832613862 2.148678034
[42,] 8.101227108 2.832613862
[43,] 9.355646303 8.101227108
[44,] -2.541805018 9.355646303
[45,] 4.257601521 -2.541805018
[46,] -1.254791623 4.257601521
[47,] 5.020193133 -1.254791623
[48,] 12.584955232 5.020193133
[49,] 0.004476145 12.584955232
[50,] 3.772270566 0.004476145
[51,] -8.582414934 3.772270566
[52,] -4.598681404 -8.582414934
[53,] 5.813972521 -4.598681404
[54,] -1.210336511 5.813972521
[55,] -5.859125425 -1.210336511
[56,] -10.380980989 -5.859125425
[57,] -19.877932095 -10.380980989
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -3.851429990 2.307053045
2 5.577629269 -3.851429990
3 -11.999609638 5.577629269
4 -0.893134414 -11.999609638
5 9.440692141 -0.893134414
6 0.304521835 9.440692141
7 6.122844358 0.304521835
8 3.564703911 6.122844358
9 -8.362843128 3.564703911
10 -11.959456299 -8.362843128
11 4.109252255 -11.959456299
12 0.364767260 4.109252255
13 -6.480792084 0.364767260
14 5.481444554 -6.480792084
15 -20.476732735 5.481444554
16 -3.237542180 -20.476732735
17 5.753416090 -3.237542180
18 -6.674915684 5.753416090
19 9.014536188 -6.674915684
20 1.310712581 9.014536188
21 -5.499908967 1.310712581
22 -8.858510806 -5.499908967
23 13.482813886 -8.858510806
24 -3.089500409 13.482813886
25 5.508681763 -3.089500409
26 4.140608511 5.508681763
27 -16.244201034 4.140608511
28 0.355618769 -16.244201034
29 5.942979054 0.355618769
30 2.973739484 5.942979054
31 11.285612229 2.973739484
32 0.671229540 11.285612229
33 0.957412756 0.671229540
34 -6.286981678 0.957412756
35 15.709053955 -6.286981678
36 1.433926042 15.709053955
37 3.561060410 1.433926042
38 5.893551275 3.561060410
39 -10.937868543 5.893551275
40 2.148678034 -10.937868543
41 2.832613862 2.148678034
42 8.101227108 2.832613862
43 9.355646303 8.101227108
44 -2.541805018 9.355646303
45 4.257601521 -2.541805018
46 -1.254791623 4.257601521
47 5.020193133 -1.254791623
48 12.584955232 5.020193133
49 0.004476145 12.584955232
50 3.772270566 0.004476145
51 -8.582414934 3.772270566
52 -4.598681404 -8.582414934
53 5.813972521 -4.598681404
54 -1.210336511 5.813972521
55 -5.859125425 -1.210336511
56 -10.380980989 -5.859125425
57 -19.877932095 -10.380980989
> 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/7xkk71258575180.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/8nemt1258575180.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/9e0cm1258575180.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/103nob1258575180.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/11awsg1258575180.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/120clk1258575180.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/13i4dq1258575181.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/14sdbt1258575181.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/15kh4s1258575181.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/167vm01258575181.tab")
+ }
>
> system("convert tmp/12a8s1258575180.ps tmp/12a8s1258575180.png")
> system("convert tmp/2qq0f1258575180.ps tmp/2qq0f1258575180.png")
> system("convert tmp/3q01t1258575180.ps tmp/3q01t1258575180.png")
> system("convert tmp/4qqaa1258575180.ps tmp/4qqaa1258575180.png")
> system("convert tmp/5rby51258575180.ps tmp/5rby51258575180.png")
> system("convert tmp/6qenm1258575180.ps tmp/6qenm1258575180.png")
> system("convert tmp/7xkk71258575180.ps tmp/7xkk71258575180.png")
> system("convert tmp/8nemt1258575180.ps tmp/8nemt1258575180.png")
> system("convert tmp/9e0cm1258575180.ps tmp/9e0cm1258575180.png")
> system("convert tmp/103nob1258575180.ps tmp/103nob1258575180.png")
>
>
> proc.time()
user system elapsed
2.454 1.545 2.858