R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: i686-pc-linux-gnu (32-bit)
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(9.2
+ ,2.07
+ ,102.06
+ ,0.44
+ ,0.67
+ ,11.7
+ ,1.92
+ ,81.65
+ ,0.44
+ ,0.80
+ ,15.8
+ ,1.95
+ ,86.18
+ ,0.46
+ ,0.76
+ ,8.6
+ ,1.89
+ ,81.65
+ ,0.42
+ ,0.65
+ ,23.2
+ ,2.10
+ ,92.99
+ ,0.45
+ ,0.90
+ ,27.4
+ ,1.95
+ ,102.06
+ ,0.43
+ ,0.78
+ ,9.3
+ ,1.92
+ ,83.91
+ ,0.49
+ ,0.77
+ ,16
+ ,2.07
+ ,106.59
+ ,0.47
+ ,0.75
+ ,4.7
+ ,2.10
+ ,106.59
+ ,0.44
+ ,0.82
+ ,12.5
+ ,2.04
+ ,95.25
+ ,0.48
+ ,0.83
+ ,20.1
+ ,2.10
+ ,111.13
+ ,0.52
+ ,0.63
+ ,9.1
+ ,2.10
+ ,111.13
+ ,0.49
+ ,0.76
+ ,8.1
+ ,1.92
+ ,83.91
+ ,0.37
+ ,0.71
+ ,8.6
+ ,1.86
+ ,83.91
+ ,0.42
+ ,0.78
+ ,20.3
+ ,1.89
+ ,81.65
+ ,0.44
+ ,0.78
+ ,25
+ ,2.07
+ ,99.79
+ ,0.50
+ ,0.88
+ ,19.2
+ ,1.98
+ ,88.00
+ ,0.50
+ ,0.83
+ ,3.3
+ ,2.32
+ ,102.06
+ ,0.43
+ ,0.57
+ ,11.2
+ ,1.92
+ ,95.25
+ ,0.37
+ ,0.82
+ ,10.5
+ ,2.16
+ ,108.86
+ ,0.50
+ ,0.71
+ ,10.1
+ ,2.07
+ ,102.06
+ ,0.40
+ ,0.77
+ ,7.2
+ ,2.23
+ ,119.29
+ ,0.48
+ ,0.66
+ ,13.6
+ ,1.95
+ ,95.25
+ ,0.48
+ ,0.24
+ ,9
+ ,2.07
+ ,106.59
+ ,0.43
+ ,0.73
+ ,24.6
+ ,2.19
+ ,104.33
+ ,0.56
+ ,0.72
+ ,12.6
+ ,1.95
+ ,86.18
+ ,0.44
+ ,0.76
+ ,5.6
+ ,2.01
+ ,99.79
+ ,0.49
+ ,0.75
+ ,8.7
+ ,2.07
+ ,95.25
+ ,0.40
+ ,0.74
+ ,7.7
+ ,1.86
+ ,81.65
+ ,0.42
+ ,0.71
+ ,24.1
+ ,1.98
+ ,106.59
+ ,0.49
+ ,0.74
+ ,11.7
+ ,1.95
+ ,83.91
+ ,0.48
+ ,0.86
+ ,7.7
+ ,1.83
+ ,79.38
+ ,0.39
+ ,0.72
+ ,9.6
+ ,1.83
+ ,87.09
+ ,0.44
+ ,0.79
+ ,7.2
+ ,2.23
+ ,119.29
+ ,0.48
+ ,0.66
+ ,12.3
+ ,1.86
+ ,81.65
+ ,0.34
+ ,0.82
+ ,8.9
+ ,2.04
+ ,108.86
+ ,0.52
+ ,0.73
+ ,13.6
+ ,1.95
+ ,95.25
+ ,0.48
+ ,0.85
+ ,11.2
+ ,1.77
+ ,72.57
+ ,0.41
+ ,0.81
+ ,2.8
+ ,2.10
+ ,104.33
+ ,0.41
+ ,0.60
+ ,3.2
+ ,2.13
+ ,111.13
+ ,0.41
+ ,0.57
+ ,9.4
+ ,2.23
+ ,103.42
+ ,0.45
+ ,0.73
+ ,11.9
+ ,1.80
+ ,70.31
+ ,0.29
+ ,0.71
+ ,15.4
+ ,1.89
+ ,90.72
+ ,0.45
+ ,0.80
+ ,7.4
+ ,2.07
+ ,106.59
+ ,0.55
+ ,0.78
+ ,18.9
+ ,2.13
+ ,106.59
+ ,0.48
+ ,0.74
+ ,7.9
+ ,1.80
+ ,47.63
+ ,0.36
+ ,0.84
+ ,12.2
+ ,1.86
+ ,81.65
+ ,0.53
+ ,0.79
+ ,11
+ ,1.74
+ ,83.91
+ ,0.35
+ ,0.70
+ ,2.8
+ ,2.16
+ ,111.13
+ ,0.41
+ ,0.78
+ ,11.8
+ ,1.77
+ ,81.65
+ ,0.43
+ ,0.87
+ ,17.1
+ ,2.26
+ ,108.86
+ ,0.60
+ ,0.71
+ ,11.6
+ ,2.07
+ ,102.06
+ ,0.48
+ ,0.70
+ ,5.8
+ ,2.07
+ ,97.52
+ ,0.46
+ ,0.73
+ ,8.3
+ ,2.13
+ ,104.33
+ ,0.44
+ ,0.76)
+ ,dim=c(5
+ ,54)
+ ,dimnames=list(c('V1'
+ ,'V2'
+ ,'V3'
+ ,'V4'
+ ,'V5')
+ ,1:54))
> y <- array(NA,dim=c(5,54),dimnames=list(c('V1','V2','V3','V4','V5'),1:54))
> 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'
> par3 <- 'No Linear Trend'
> par2 <- 'Do not include Seasonal Dummies'
> par1 <- '1'
> #'GNU S' R Code compiled by R2WASP v. 1.2.327 ()
> #Author: root
> #To cite this work: Wessa P., (2013), Multiple Regression (v1.0.29) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_multipleregression.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, 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
V1 V2 V3 V4 V5
1 9.2 2.07 102.06 0.44 0.67
2 11.7 1.92 81.65 0.44 0.80
3 15.8 1.95 86.18 0.46 0.76
4 8.6 1.89 81.65 0.42 0.65
5 23.2 2.10 92.99 0.45 0.90
6 27.4 1.95 102.06 0.43 0.78
7 9.3 1.92 83.91 0.49 0.77
8 16.0 2.07 106.59 0.47 0.75
9 4.7 2.10 106.59 0.44 0.82
10 12.5 2.04 95.25 0.48 0.83
11 20.1 2.10 111.13 0.52 0.63
12 9.1 2.10 111.13 0.49 0.76
13 8.1 1.92 83.91 0.37 0.71
14 8.6 1.86 83.91 0.42 0.78
15 20.3 1.89 81.65 0.44 0.78
16 25.0 2.07 99.79 0.50 0.88
17 19.2 1.98 88.00 0.50 0.83
18 3.3 2.32 102.06 0.43 0.57
19 11.2 1.92 95.25 0.37 0.82
20 10.5 2.16 108.86 0.50 0.71
21 10.1 2.07 102.06 0.40 0.77
22 7.2 2.23 119.29 0.48 0.66
23 13.6 1.95 95.25 0.48 0.24
24 9.0 2.07 106.59 0.43 0.73
25 24.6 2.19 104.33 0.56 0.72
26 12.6 1.95 86.18 0.44 0.76
27 5.6 2.01 99.79 0.49 0.75
28 8.7 2.07 95.25 0.40 0.74
29 7.7 1.86 81.65 0.42 0.71
30 24.1 1.98 106.59 0.49 0.74
31 11.7 1.95 83.91 0.48 0.86
32 7.7 1.83 79.38 0.39 0.72
33 9.6 1.83 87.09 0.44 0.79
34 7.2 2.23 119.29 0.48 0.66
35 12.3 1.86 81.65 0.34 0.82
36 8.9 2.04 108.86 0.52 0.73
37 13.6 1.95 95.25 0.48 0.85
38 11.2 1.77 72.57 0.41 0.81
39 2.8 2.10 104.33 0.41 0.60
40 3.2 2.13 111.13 0.41 0.57
41 9.4 2.23 103.42 0.45 0.73
42 11.9 1.80 70.31 0.29 0.71
43 15.4 1.89 90.72 0.45 0.80
44 7.4 2.07 106.59 0.55 0.78
45 18.9 2.13 106.59 0.48 0.74
46 7.9 1.80 47.63 0.36 0.84
47 12.2 1.86 81.65 0.53 0.79
48 11.0 1.74 83.91 0.35 0.70
49 2.8 2.16 111.13 0.41 0.78
50 11.8 1.77 81.65 0.43 0.87
51 17.1 2.26 108.86 0.60 0.71
52 11.6 2.07 102.06 0.48 0.70
53 5.8 2.07 97.52 0.46 0.73
54 8.3 2.13 104.33 0.44 0.76
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) V2 V3 V4 V5
4.56113 -12.29148 0.02497 46.70430 11.47316
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-9.016 -3.551 -1.272 2.541 15.227
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.56113 14.94772 0.305 0.76155
V2 -12.29148 9.77056 -1.258 0.21435
V3 0.02497 0.10164 0.246 0.80698
V4 46.70430 15.59345 2.995 0.00429 **
V5 11.47316 7.83009 1.465 0.14924
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 5.435 on 49 degrees of freedom
Multiple R-squared: 0.2153, Adjusted R-squared: 0.1513
F-statistic: 3.362 on 4 and 49 DF, p-value: 0.0165
> 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.3613033 0.72260655 0.63869672
[2,] 0.9682215 0.06355700 0.03177850
[3,] 0.9392445 0.12151106 0.06075553
[4,] 0.9656523 0.06869541 0.03434770
[5,] 0.9702222 0.05955567 0.02977784
[6,] 0.9479826 0.10403478 0.05201739
[7,] 0.9378275 0.12434508 0.06217254
[8,] 0.9499702 0.10005956 0.05002978
[9,] 0.9729543 0.05409142 0.02704571
[10,] 0.9635545 0.07289103 0.03644551
[11,] 0.9469941 0.10601186 0.05300593
[12,] 0.9236059 0.15278820 0.07639410
[13,] 0.8961942 0.20761164 0.10380582
[14,] 0.8552384 0.28952319 0.14476160
[15,] 0.8156548 0.36869045 0.18434522
[16,] 0.8166709 0.36665824 0.18332912
[17,] 0.7595785 0.48084291 0.24042146
[18,] 0.8947417 0.21051661 0.10525830
[19,] 0.8560744 0.28785114 0.14392557
[20,] 0.9187710 0.16245802 0.08122901
[21,] 0.8811063 0.23778742 0.11889371
[22,] 0.8530923 0.29381542 0.14690771
[23,] 0.9703063 0.05938739 0.02969370
[24,] 0.9584536 0.08309275 0.04154638
[25,] 0.9382642 0.12347164 0.06173582
[26,] 0.9205076 0.15898488 0.07949244
[27,] 0.8898438 0.22031242 0.11015621
[28,] 0.8668795 0.26624092 0.13312046
[29,] 0.8539789 0.29204227 0.14602114
[30,] 0.7968371 0.40632575 0.20316288
[31,] 0.7198216 0.56035672 0.28017836
[32,] 0.6992577 0.60148455 0.30074228
[33,] 0.7519875 0.49602495 0.24801247
[34,] 0.6525426 0.69491487 0.34745744
[35,] 0.5920743 0.81585143 0.40792571
[36,] 0.5586177 0.88276456 0.44138228
[37,] 0.5989313 0.80213734 0.40106867
[38,] 0.8557585 0.28848302 0.14424151
[39,] 0.8224537 0.35509257 0.17754628
> postscript(file="/var/wessaorg/rcomp/tmp/1g3me1384967104.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/wessaorg/rcomp/tmp/29zdr1384967104.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/wessaorg/rcomp/tmp/3lonk1384967104.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/wessaorg/rcomp/tmp/48stx1384967104.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/wessaorg/rcomp/tmp/56s1f1384967104.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 = 54
Frequency = 1
1 2 3 4 5 6
-0.70293755 -1.02856694 2.85191132 -1.84225139 10.78640003 15.22707986
7 8 9 10 11 12
-5.47601571 3.66497398 -6.66827365 -1.30552531 7.06192629 -4.02845544
13 14 15 16 17 18
-0.38310984 -3.75893516 7.43215176 9.94211887 3.90392015 -1.91570766
19 20 21 22 23 24
1.17170152 -1.72767331 0.91791854 -2.91994527 5.45740559 -1.23739073
25 26 27 28 29 30
9.93718806 0.58599736 -8.23681632 0.03214777 -3.79938550 9.83938603
31 32 33 34 35 36
-3.27281258 -2.82505439 -4.25589665 -2.91994527 3.27491107 -5.96620057
37 38 39 40 41 42
-1.54122202 -1.85917941 -4.58662092 -3.64346636 0.27431024 6.01782581
43 44 45 46 47 48
1.60918264 -9.01556499 6.95015157 -2.17670407 -5.35471154 1.35324078
49 50 51 52 53 54
-6.08408546 -3.10836764 1.43104482 -0.51530443 -5.61205690 -1.95471108
> postscript(file="/var/wessaorg/rcomp/tmp/6ahll1384967104.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 = 54
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.70293755 NA
1 -1.02856694 -0.70293755
2 2.85191132 -1.02856694
3 -1.84225139 2.85191132
4 10.78640003 -1.84225139
5 15.22707986 10.78640003
6 -5.47601571 15.22707986
7 3.66497398 -5.47601571
8 -6.66827365 3.66497398
9 -1.30552531 -6.66827365
10 7.06192629 -1.30552531
11 -4.02845544 7.06192629
12 -0.38310984 -4.02845544
13 -3.75893516 -0.38310984
14 7.43215176 -3.75893516
15 9.94211887 7.43215176
16 3.90392015 9.94211887
17 -1.91570766 3.90392015
18 1.17170152 -1.91570766
19 -1.72767331 1.17170152
20 0.91791854 -1.72767331
21 -2.91994527 0.91791854
22 5.45740559 -2.91994527
23 -1.23739073 5.45740559
24 9.93718806 -1.23739073
25 0.58599736 9.93718806
26 -8.23681632 0.58599736
27 0.03214777 -8.23681632
28 -3.79938550 0.03214777
29 9.83938603 -3.79938550
30 -3.27281258 9.83938603
31 -2.82505439 -3.27281258
32 -4.25589665 -2.82505439
33 -2.91994527 -4.25589665
34 3.27491107 -2.91994527
35 -5.96620057 3.27491107
36 -1.54122202 -5.96620057
37 -1.85917941 -1.54122202
38 -4.58662092 -1.85917941
39 -3.64346636 -4.58662092
40 0.27431024 -3.64346636
41 6.01782581 0.27431024
42 1.60918264 6.01782581
43 -9.01556499 1.60918264
44 6.95015157 -9.01556499
45 -2.17670407 6.95015157
46 -5.35471154 -2.17670407
47 1.35324078 -5.35471154
48 -6.08408546 1.35324078
49 -3.10836764 -6.08408546
50 1.43104482 -3.10836764
51 -0.51530443 1.43104482
52 -5.61205690 -0.51530443
53 -1.95471108 -5.61205690
54 NA -1.95471108
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.02856694 -0.70293755
[2,] 2.85191132 -1.02856694
[3,] -1.84225139 2.85191132
[4,] 10.78640003 -1.84225139
[5,] 15.22707986 10.78640003
[6,] -5.47601571 15.22707986
[7,] 3.66497398 -5.47601571
[8,] -6.66827365 3.66497398
[9,] -1.30552531 -6.66827365
[10,] 7.06192629 -1.30552531
[11,] -4.02845544 7.06192629
[12,] -0.38310984 -4.02845544
[13,] -3.75893516 -0.38310984
[14,] 7.43215176 -3.75893516
[15,] 9.94211887 7.43215176
[16,] 3.90392015 9.94211887
[17,] -1.91570766 3.90392015
[18,] 1.17170152 -1.91570766
[19,] -1.72767331 1.17170152
[20,] 0.91791854 -1.72767331
[21,] -2.91994527 0.91791854
[22,] 5.45740559 -2.91994527
[23,] -1.23739073 5.45740559
[24,] 9.93718806 -1.23739073
[25,] 0.58599736 9.93718806
[26,] -8.23681632 0.58599736
[27,] 0.03214777 -8.23681632
[28,] -3.79938550 0.03214777
[29,] 9.83938603 -3.79938550
[30,] -3.27281258 9.83938603
[31,] -2.82505439 -3.27281258
[32,] -4.25589665 -2.82505439
[33,] -2.91994527 -4.25589665
[34,] 3.27491107 -2.91994527
[35,] -5.96620057 3.27491107
[36,] -1.54122202 -5.96620057
[37,] -1.85917941 -1.54122202
[38,] -4.58662092 -1.85917941
[39,] -3.64346636 -4.58662092
[40,] 0.27431024 -3.64346636
[41,] 6.01782581 0.27431024
[42,] 1.60918264 6.01782581
[43,] -9.01556499 1.60918264
[44,] 6.95015157 -9.01556499
[45,] -2.17670407 6.95015157
[46,] -5.35471154 -2.17670407
[47,] 1.35324078 -5.35471154
[48,] -6.08408546 1.35324078
[49,] -3.10836764 -6.08408546
[50,] 1.43104482 -3.10836764
[51,] -0.51530443 1.43104482
[52,] -5.61205690 -0.51530443
[53,] -1.95471108 -5.61205690
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.02856694 -0.70293755
2 2.85191132 -1.02856694
3 -1.84225139 2.85191132
4 10.78640003 -1.84225139
5 15.22707986 10.78640003
6 -5.47601571 15.22707986
7 3.66497398 -5.47601571
8 -6.66827365 3.66497398
9 -1.30552531 -6.66827365
10 7.06192629 -1.30552531
11 -4.02845544 7.06192629
12 -0.38310984 -4.02845544
13 -3.75893516 -0.38310984
14 7.43215176 -3.75893516
15 9.94211887 7.43215176
16 3.90392015 9.94211887
17 -1.91570766 3.90392015
18 1.17170152 -1.91570766
19 -1.72767331 1.17170152
20 0.91791854 -1.72767331
21 -2.91994527 0.91791854
22 5.45740559 -2.91994527
23 -1.23739073 5.45740559
24 9.93718806 -1.23739073
25 0.58599736 9.93718806
26 -8.23681632 0.58599736
27 0.03214777 -8.23681632
28 -3.79938550 0.03214777
29 9.83938603 -3.79938550
30 -3.27281258 9.83938603
31 -2.82505439 -3.27281258
32 -4.25589665 -2.82505439
33 -2.91994527 -4.25589665
34 3.27491107 -2.91994527
35 -5.96620057 3.27491107
36 -1.54122202 -5.96620057
37 -1.85917941 -1.54122202
38 -4.58662092 -1.85917941
39 -3.64346636 -4.58662092
40 0.27431024 -3.64346636
41 6.01782581 0.27431024
42 1.60918264 6.01782581
43 -9.01556499 1.60918264
44 6.95015157 -9.01556499
45 -2.17670407 6.95015157
46 -5.35471154 -2.17670407
47 1.35324078 -5.35471154
48 -6.08408546 1.35324078
49 -3.10836764 -6.08408546
50 1.43104482 -3.10836764
51 -0.51530443 1.43104482
52 -5.61205690 -0.51530443
53 -1.95471108 -5.61205690
> 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/wessaorg/rcomp/tmp/7fbr81384967104.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/wessaorg/rcomp/tmp/83gax1384967104.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/wessaorg/rcomp/tmp/9pxty1384967104.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/wessaorg/rcomp/tmp/10fukm1384967104.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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, signif(mysum$coefficients[i,1],6), 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/wessaorg/rcomp/tmp/116ud81384967104.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,signif(mysum$coefficients[i,1],6))
+ a<-table.element(a, signif(mysum$coefficients[i,2],6))
+ a<-table.element(a, signif(mysum$coefficients[i,3],4))
+ a<-table.element(a, signif(mysum$coefficients[i,4],6))
+ a<-table.element(a, signif(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/wessaorg/rcomp/tmp/12uwzs1384967104.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, signif(sqrt(mysum$r.squared),6))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, signif(mysum$r.squared,6))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, signif(mysum$adj.r.squared,6))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, signif(mysum$fstatistic[1],6))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, signif(mysum$fstatistic[2],6))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, signif(mysum$fstatistic[3],6))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, signif(1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]),6))
> 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, signif(mysum$sigma,6))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, signif(sum(myerror*myerror),6))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/wessaorg/rcomp/tmp/13juhg1384967104.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,signif(x[i],6))
+ a<-table.element(a,signif(x[i]-mysum$resid[i],6))
+ a<-table.element(a,signif(mysum$resid[i],6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/wessaorg/rcomp/tmp/144gxj1384967104.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,signif(gqarr[mypoint-kp3+1,1],6))
+ a<-table.element(a,signif(gqarr[mypoint-kp3+1,2],6))
+ a<-table.element(a,signif(gqarr[mypoint-kp3+1,3],6))
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/wessaorg/rcomp/tmp/15pjcy1384967104.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,signif(numsignificant1,6))
+ a<-table.element(a,signif(numsignificant1/numgqtests,6))
+ 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,signif(numsignificant5,6))
+ a<-table.element(a,signif(numsignificant5/numgqtests,6))
+ 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,signif(numsignificant10,6))
+ a<-table.element(a,signif(numsignificant10/numgqtests,6))
+ 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/wessaorg/rcomp/tmp/16ydne1384967104.tab")
+ }
>
> try(system("convert tmp/1g3me1384967104.ps tmp/1g3me1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/29zdr1384967104.ps tmp/29zdr1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/3lonk1384967104.ps tmp/3lonk1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/48stx1384967104.ps tmp/48stx1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/56s1f1384967104.ps tmp/56s1f1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ahll1384967104.ps tmp/6ahll1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/7fbr81384967104.ps tmp/7fbr81384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/83gax1384967104.ps tmp/83gax1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/9pxty1384967104.ps tmp/9pxty1384967104.png",intern=TRUE))
character(0)
> try(system("convert tmp/10fukm1384967104.ps tmp/10fukm1384967104.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
7.644 1.386 9.015