R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-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(6654000
+ ,5712000
+ ,0
+ ,0
+ ,3.3
+ ,38.6
+ ,645
+ ,3
+ ,5
+ ,3
+ ,1000
+ ,6600
+ ,6.3
+ ,2
+ ,8.3
+ ,4.5
+ ,42
+ ,3
+ ,1
+ ,3
+ ,3385
+ ,44500
+ ,0
+ ,0
+ ,12.5
+ ,14
+ ,60
+ ,1
+ ,1
+ ,1
+ ,0.92
+ ,5700
+ ,0
+ ,0
+ ,16.5
+ ,0
+ ,25
+ ,5
+ ,2
+ ,3
+ ,2547000
+ ,4603000
+ ,2.1
+ ,1.8
+ ,3.9
+ ,69
+ ,624
+ ,3
+ ,5
+ ,4
+ ,10550
+ ,179500
+ ,9.1
+ ,0.7
+ ,9.8
+ ,27
+ ,180
+ ,4
+ ,4
+ ,4
+ ,0.023
+ ,0.3
+ ,15.8
+ ,3.9
+ ,19.7
+ ,19
+ ,35
+ ,1
+ ,1
+ ,1
+ ,160000
+ ,169000
+ ,5.2
+ ,1
+ ,6.2
+ ,30.4
+ ,392
+ ,4
+ ,5
+ ,4
+ ,3300
+ ,25600
+ ,10.9
+ ,3.6
+ ,14.5
+ ,28
+ ,63
+ ,1
+ ,2
+ ,1
+ ,52160
+ ,440000
+ ,8.3
+ ,1.4
+ ,9.7
+ ,50
+ ,230
+ ,1
+ ,1
+ ,1
+ ,0.425
+ ,6400
+ ,11
+ ,1.5
+ ,12.5
+ ,7
+ ,112
+ ,5
+ ,4
+ ,4
+ ,465000
+ ,423000
+ ,3.2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4.5
+ ,60
+ ,2
+ ,1
+ ,2
+ ,2000
+ ,12300
+ ,4.9
+ ,0.5
+ ,5.4
+ ,7.5
+ ,200
+ ,3
+ ,1
+ ,3
+ ,0.104
+ ,2500
+ ,13.2
+ ,2.6
+ ,15.8
+ ,2.3
+ ,46
+ ,3
+ ,2
+ ,2
+ ,4190
+ ,58000
+ ,9.7
+ ,0.6
+ ,10.3
+ ,24
+ ,210
+ ,4
+ ,3
+ ,4
+ ,3500
+ ,3900
+ ,12.8
+ ,6.6
+ ,19.4
+ ,3
+ ,14
+ ,2
+ ,1
+ ,1
+ ,4050
+ ,17000
+ ,0
+ ,0
+ ,0
+ ,13
+ ,38
+ ,3
+ ,1
+ ,1)
+ ,dim=c(10
+ ,62)
+ ,dimnames=list(c('gewicht'
+ ,'brein'
+ ,'nietdroomslaap'
+ ,'droomslaap'
+ ,'totaleslaap'
+ ,'levensduur'
+ ,'drachttijd'
+ ,'jager?'
+ ,'blootgesteldheidslaap'
+ ,'algemeengevaar')
+ ,1:62))
> y <- array(NA,dim=c(10,62),dimnames=list(c('gewicht','brein','nietdroomslaap','droomslaap','totaleslaap','levensduur','drachttijd','jager?','blootgesteldheidslaap','algemeengevaar'),1:62))
> 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 = '5'
> #'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
> 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
totaleslaap gewicht brein nietdroomslaap droomslaap levensduur
1 3.3 6.654e+06 5.712e+06 0.0 0.0 38.6
2 8.3 1.000e+03 6.600e+03 6.3 2.0 4.5
3 12.5 3.385e+03 4.450e+04 0.0 0.0 14.0
4 16.5 9.200e-01 5.700e+03 0.0 0.0 0.0
5 3.9 2.547e+06 4.603e+06 2.1 1.8 69.0
6 9.8 1.055e+04 1.795e+05 9.1 0.7 27.0
7 19.7 2.300e-02 3.000e-01 15.8 3.9 19.0
8 6.2 1.600e+05 1.690e+05 5.2 1.0 30.4
9 14.5 3.300e+03 2.560e+04 10.9 3.6 28.0
10 9.7 5.216e+04 4.400e+05 8.3 1.4 50.0
11 12.5 4.250e-01 6.400e+03 11.0 1.5 7.0
12 3.9 4.650e+05 4.230e+05 3.2 0.7 30.0
13 10.3 5.500e-01 2.400e+03 7.6 2.7 0.0
14 3.1 1.871e+05 4.190e+05 0.0 0.0 40.0
15 8.4 7.500e-02 1.200e+03 6.3 2.1 3.5
16 8.6 3.000e+03 2.500e+04 8.6 0.0 50.0
17 10.7 7.850e-01 3.500e+03 6.6 4.1 6.0
18 10.7 2.000e-01 5.000e+03 9.5 1.2 10.4
19 6.1 1.410e+03 1.750e+04 4.8 1.3 34.0
20 18.1 6.000e+04 8.100e+04 12.0 6.1 7.0
21 0.0 5.290e+05 6.800e+05 0.0 0.3 28.0
22 3.8 2.766e+04 1.150e+05 3.3 0.5 20.0
23 14.4 1.200e-01 1.000e+03 11.0 3.4 3.9
24 12.0 2.070e+05 4.060e+05 0.0 0.0 39.3
25 6.2 8.500e+04 3.250e+05 4.7 1.5 41.0
26 13.0 3.633e+04 1.195e+05 0.0 0.0 16.2
27 13.8 1.010e-01 4.000e+03 10.4 3.4 9.0
28 8.2 1.040e+03 5.500e+03 7.4 0.8 7.6
29 2.9 5.210e+05 6.550e+05 2.1 0.8 46.0
30 10.8 1.000e+05 1.570e+05 0.0 0.0 22.4
31 0.0 3.500e+04 5.600e+04 0.0 0.0 16.3
32 9.1 5.000e-03 1.400e-01 7.7 1.4 2.6
33 19.9 1.000e-02 2.500e-01 17.9 2.0 24.0
34 8.0 6.200e+04 1.320e+06 6.1 1.9 100.0
35 10.6 1.220e-01 3.000e+03 8.2 2.4 0.0
36 11.2 1.350e+03 8.100e+03 8.4 2.8 0.0
37 13.2 2.300e-02 4.000e-01 11.9 1.3 3.2
38 12.8 4.800e-02 3.300e-01 10.8 2.0 2.0
39 19.4 1.700e+03 6.300e+03 13.8 5.6 5.0
40 17.4 3.500e+03 1.080e+04 14.3 3.1 6.5
41 0.0 2.500e+05 4.900e+05 0.0 1.0 23.6
42 17.0 4.800e-01 1.550e+04 15.2 1.8 12.0
43 10.9 1.000e+04 1.150e+05 10.0 0.9 20.2
44 13.7 1.620e+03 1.140e+04 11.9 1.8 13.0
45 8.4 1.920e+05 1.800e+05 6.5 1.9 27.0
46 8.4 2.500e+03 1.210e+04 7.5 0.9 18.0
47 12.5 4.288e+03 3.920e+04 0.0 0.0 13.7
48 13.2 2.800e-01 1.900e+03 10.6 2.6 4.7
49 9.8 4.235e+03 5.040e+04 7.4 2.4 9.8
50 9.6 6.800e+03 1.790e+05 8.4 1.2 29.0
51 6.6 7.500e-01 1.230e+04 5.7 0.9 7.0
52 5.4 3.600e+03 2.100e+04 4.9 0.5 6.0
53 2.6 1.483e+04 9.820e+04 0.0 0.0 17.0
54 3.8 5.550e+04 1.750e+05 3.2 0.6 20.0
55 11.0 1.400e+03 1.250e+04 0.0 0.0 12.7
56 10.3 6.000e-02 1.000e+03 8.1 2.2 3.5
57 13.3 9.000e-01 2.600e+03 11.0 2.3 4.5
58 5.4 2.000e+03 1.230e+04 4.9 0.5 7.5
59 15.8 1.040e-01 2.500e+03 13.2 2.6 2.3
60 10.3 4.190e+03 5.800e+04 9.7 0.6 24.0
61 19.4 3.500e+03 3.900e+03 12.8 6.6 3.0
62 0.0 4.050e+03 1.700e+04 0.0 0.0 13.0
drachttijd jager? blootgesteldheidslaap algemeengevaar
1 645.0 3 5 3
2 42.0 3 1 3
3 60.0 1 1 1
4 25.0 5 2 3
5 624.0 3 5 4
6 180.0 4 4 4
7 35.0 1 1 1
8 392.0 4 5 4
9 63.0 1 2 1
10 230.0 1 1 1
11 112.0 5 4 4
12 281.0 5 5 5
13 0.0 2 1 2
14 365.0 5 5 5
15 42.0 1 1 1
16 28.0 2 2 2
17 42.0 2 2 2
18 120.0 2 2 2
19 0.0 1 2 1
20 0.0 1 1 1
21 400.0 5 5 5
22 148.0 5 5 5
23 16.0 3 1 2
24 252.0 1 4 1
25 310.0 1 3 1
26 63.0 1 1 1
27 28.0 5 1 3
28 68.0 5 3 4
29 336.0 5 5 5
30 100.0 1 1 1
31 33.0 3 5 4
32 21.5 5 2 4
33 50.0 1 1 1
34 267.0 1 1 1
35 30.0 2 1 1
36 45.0 3 1 3
37 19.0 4 1 3
38 30.0 4 1 3
39 12.0 2 1 1
40 120.0 2 1 1
41 440.0 5 5 5
42 140.0 2 2 2
43 170.0 4 4 4
44 17.0 2 1 2
45 115.0 4 4 4
46 31.0 5 5 5
47 63.0 2 2 2
48 21.0 3 1 3
49 52.0 1 1 1
50 164.0 2 3 2
51 225.0 2 2 2
52 225.0 3 2 3
53 150.0 5 5 5
54 151.0 5 5 5
55 90.0 2 2 2
56 0.0 3 1 2
57 60.0 2 1 2
58 200.0 3 1 3
59 46.0 3 2 2
60 210.0 4 3 4
61 14.0 2 1 1
62 38.0 3 1 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) gewicht brein
1.023e+01 -9.307e-07 1.399e-06
nietdroomslaap droomslaap levensduur
5.381e-01 1.381e-01 -4.230e-02
drachttijd `jager?` blootgesteldheidslaap
-6.705e-03 6.931e-01 3.422e-01
algemeengevaar
-2.128e+00
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-9.7402 -1.3904 -0.0028 1.3338 8.6623
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.023e+01 1.429e+00 7.160 2.75e-09 ***
gewicht -9.307e-07 1.579e-06 -0.589 0.5581
brein 1.399e-06 1.750e-06 0.799 0.4278
nietdroomslaap 5.381e-01 1.189e-01 4.525 3.53e-05 ***
droomslaap 1.381e-01 3.922e-01 0.352 0.7262
levensduur -4.230e-02 3.691e-02 -1.146 0.2570
drachttijd -6.705e-03 5.353e-03 -1.253 0.2159
`jager?` 6.931e-01 7.491e-01 0.925 0.3591
blootgesteldheidslaap 3.422e-01 5.509e-01 0.621 0.5371
algemeengevaar -2.128e+00 9.761e-01 -2.180 0.0338 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.006 on 52 degrees of freedom
Multiple R-squared: 0.7108, Adjusted R-squared: 0.6608
F-statistic: 14.2 on 9 and 52 DF, p-value: 3.215e-11
> 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.5946630 0.8106739 0.4053370
[2,] 0.4576543 0.9153087 0.5423457
[3,] 0.6360276 0.7279449 0.3639724
[4,] 0.6231740 0.7536521 0.3768260
[5,] 0.5186841 0.9626317 0.4813159
[6,] 0.4107626 0.8215252 0.5892374
[7,] 0.5827086 0.8345828 0.4172914
[8,] 0.5264680 0.9470639 0.4735320
[9,] 0.4928149 0.9856297 0.5071851
[10,] 0.3935920 0.7871840 0.6064080
[11,] 0.3984074 0.7968148 0.6015926
[12,] 0.4777142 0.9554285 0.5222858
[13,] 0.5721729 0.8556542 0.4278271
[14,] 0.7119354 0.5761293 0.2880646
[15,] 0.6765957 0.6468087 0.3234043
[16,] 0.6383014 0.7233973 0.3616986
[17,] 0.5610437 0.8779125 0.4389563
[18,] 0.5802354 0.8395293 0.4197646
[19,] 0.7257271 0.5485459 0.2742729
[20,] 0.6616322 0.6767356 0.3383678
[21,] 0.6478656 0.7042688 0.3521344
[22,] 0.5688035 0.8623930 0.4311965
[23,] 0.6665076 0.6669848 0.3334924
[24,] 0.5949088 0.8101824 0.4050912
[25,] 0.5348542 0.9302915 0.4651458
[26,] 0.4996398 0.9992797 0.5003602
[27,] 0.4219848 0.8439696 0.5780152
[28,] 0.3879127 0.7758253 0.6120873
[29,] 0.3867728 0.7735456 0.6132272
[30,] 0.3241190 0.6482380 0.6758810
[31,] 0.2892380 0.5784761 0.7107620
[32,] 0.2161079 0.4322159 0.7838921
[33,] 0.1507826 0.3015652 0.8492174
[34,] 0.3450202 0.6900404 0.6549798
[35,] 0.5419678 0.9160645 0.4580322
[36,] 0.4041099 0.8082198 0.5958901
[37,] 0.4919507 0.9839014 0.5080493
> postscript(file="/var/wessaorg/rcomp/tmp/1lif61321987457.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/2ecab1321987457.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/37twe1321987457.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/40azq1321987457.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/5b21d1321987457.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 = 62
Frequency = 1
1 2 3 4 5
-0.1759561142 -1.1715046873 4.2967428994 8.6623356082 0.0474640424
6 7 8 9 10
1.0536579764 2.5589415815 0.8877510956 0.2306830200 -1.0079163098
11 12 13 14 15
0.8579298403 0.3077918893 -1.8696551884 2.0596435179 -3.9908305551
16 17 18 19 20
-1.8031386341 -0.9331432139 -1.3863186497 -4.7282486485 1.9003311514
21 22 23 24 25
-1.4015698883 -1.1094731948 -0.1147979559 4.8116255247 -2.9218731870
26 27 28 29 30
4.8356968950 0.6419062714 -1.3333655187 0.6592135379 3.1528739523
31 32 33 34 35
-4.6446981586 -0.8519845805 2.2032798948 -0.4513476688 -3.7788262582
36 37 38 39 40
0.3159648966 -0.0823738601 0.0359135718 1.6536966998 0.5127441432
41 42 43 44 45
-1.4100831321 1.9506397914 1.3767128983 -0.0064848806 0.6194640645
46 47 48 49 50
0.4265913494 5.4051115470 1.2050272341 -2.9554868860 -1.3917560847
51 52 53 54 55
-2.8500537133 -2.1805344529 -0.5665819353 -1.1073539098 4.0784939542
56 57 58 59 60
-2.6127710637 -0.0516715606 -1.9317971573 0.0009104966 1.8250548732
61 62
1.9875990494 -9.7401962197
> postscript(file="/var/wessaorg/rcomp/tmp/6ghh71321987457.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 = 62
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.1759561142 NA
1 -1.1715046873 -0.1759561142
2 4.2967428994 -1.1715046873
3 8.6623356082 4.2967428994
4 0.0474640424 8.6623356082
5 1.0536579764 0.0474640424
6 2.5589415815 1.0536579764
7 0.8877510956 2.5589415815
8 0.2306830200 0.8877510956
9 -1.0079163098 0.2306830200
10 0.8579298403 -1.0079163098
11 0.3077918893 0.8579298403
12 -1.8696551884 0.3077918893
13 2.0596435179 -1.8696551884
14 -3.9908305551 2.0596435179
15 -1.8031386341 -3.9908305551
16 -0.9331432139 -1.8031386341
17 -1.3863186497 -0.9331432139
18 -4.7282486485 -1.3863186497
19 1.9003311514 -4.7282486485
20 -1.4015698883 1.9003311514
21 -1.1094731948 -1.4015698883
22 -0.1147979559 -1.1094731948
23 4.8116255247 -0.1147979559
24 -2.9218731870 4.8116255247
25 4.8356968950 -2.9218731870
26 0.6419062714 4.8356968950
27 -1.3333655187 0.6419062714
28 0.6592135379 -1.3333655187
29 3.1528739523 0.6592135379
30 -4.6446981586 3.1528739523
31 -0.8519845805 -4.6446981586
32 2.2032798948 -0.8519845805
33 -0.4513476688 2.2032798948
34 -3.7788262582 -0.4513476688
35 0.3159648966 -3.7788262582
36 -0.0823738601 0.3159648966
37 0.0359135718 -0.0823738601
38 1.6536966998 0.0359135718
39 0.5127441432 1.6536966998
40 -1.4100831321 0.5127441432
41 1.9506397914 -1.4100831321
42 1.3767128983 1.9506397914
43 -0.0064848806 1.3767128983
44 0.6194640645 -0.0064848806
45 0.4265913494 0.6194640645
46 5.4051115470 0.4265913494
47 1.2050272341 5.4051115470
48 -2.9554868860 1.2050272341
49 -1.3917560847 -2.9554868860
50 -2.8500537133 -1.3917560847
51 -2.1805344529 -2.8500537133
52 -0.5665819353 -2.1805344529
53 -1.1073539098 -0.5665819353
54 4.0784939542 -1.1073539098
55 -2.6127710637 4.0784939542
56 -0.0516715606 -2.6127710637
57 -1.9317971573 -0.0516715606
58 0.0009104966 -1.9317971573
59 1.8250548732 0.0009104966
60 1.9875990494 1.8250548732
61 -9.7401962197 1.9875990494
62 NA -9.7401962197
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.1715046873 -0.1759561142
[2,] 4.2967428994 -1.1715046873
[3,] 8.6623356082 4.2967428994
[4,] 0.0474640424 8.6623356082
[5,] 1.0536579764 0.0474640424
[6,] 2.5589415815 1.0536579764
[7,] 0.8877510956 2.5589415815
[8,] 0.2306830200 0.8877510956
[9,] -1.0079163098 0.2306830200
[10,] 0.8579298403 -1.0079163098
[11,] 0.3077918893 0.8579298403
[12,] -1.8696551884 0.3077918893
[13,] 2.0596435179 -1.8696551884
[14,] -3.9908305551 2.0596435179
[15,] -1.8031386341 -3.9908305551
[16,] -0.9331432139 -1.8031386341
[17,] -1.3863186497 -0.9331432139
[18,] -4.7282486485 -1.3863186497
[19,] 1.9003311514 -4.7282486485
[20,] -1.4015698883 1.9003311514
[21,] -1.1094731948 -1.4015698883
[22,] -0.1147979559 -1.1094731948
[23,] 4.8116255247 -0.1147979559
[24,] -2.9218731870 4.8116255247
[25,] 4.8356968950 -2.9218731870
[26,] 0.6419062714 4.8356968950
[27,] -1.3333655187 0.6419062714
[28,] 0.6592135379 -1.3333655187
[29,] 3.1528739523 0.6592135379
[30,] -4.6446981586 3.1528739523
[31,] -0.8519845805 -4.6446981586
[32,] 2.2032798948 -0.8519845805
[33,] -0.4513476688 2.2032798948
[34,] -3.7788262582 -0.4513476688
[35,] 0.3159648966 -3.7788262582
[36,] -0.0823738601 0.3159648966
[37,] 0.0359135718 -0.0823738601
[38,] 1.6536966998 0.0359135718
[39,] 0.5127441432 1.6536966998
[40,] -1.4100831321 0.5127441432
[41,] 1.9506397914 -1.4100831321
[42,] 1.3767128983 1.9506397914
[43,] -0.0064848806 1.3767128983
[44,] 0.6194640645 -0.0064848806
[45,] 0.4265913494 0.6194640645
[46,] 5.4051115470 0.4265913494
[47,] 1.2050272341 5.4051115470
[48,] -2.9554868860 1.2050272341
[49,] -1.3917560847 -2.9554868860
[50,] -2.8500537133 -1.3917560847
[51,] -2.1805344529 -2.8500537133
[52,] -0.5665819353 -2.1805344529
[53,] -1.1073539098 -0.5665819353
[54,] 4.0784939542 -1.1073539098
[55,] -2.6127710637 4.0784939542
[56,] -0.0516715606 -2.6127710637
[57,] -1.9317971573 -0.0516715606
[58,] 0.0009104966 -1.9317971573
[59,] 1.8250548732 0.0009104966
[60,] 1.9875990494 1.8250548732
[61,] -9.7401962197 1.9875990494
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.1715046873 -0.1759561142
2 4.2967428994 -1.1715046873
3 8.6623356082 4.2967428994
4 0.0474640424 8.6623356082
5 1.0536579764 0.0474640424
6 2.5589415815 1.0536579764
7 0.8877510956 2.5589415815
8 0.2306830200 0.8877510956
9 -1.0079163098 0.2306830200
10 0.8579298403 -1.0079163098
11 0.3077918893 0.8579298403
12 -1.8696551884 0.3077918893
13 2.0596435179 -1.8696551884
14 -3.9908305551 2.0596435179
15 -1.8031386341 -3.9908305551
16 -0.9331432139 -1.8031386341
17 -1.3863186497 -0.9331432139
18 -4.7282486485 -1.3863186497
19 1.9003311514 -4.7282486485
20 -1.4015698883 1.9003311514
21 -1.1094731948 -1.4015698883
22 -0.1147979559 -1.1094731948
23 4.8116255247 -0.1147979559
24 -2.9218731870 4.8116255247
25 4.8356968950 -2.9218731870
26 0.6419062714 4.8356968950
27 -1.3333655187 0.6419062714
28 0.6592135379 -1.3333655187
29 3.1528739523 0.6592135379
30 -4.6446981586 3.1528739523
31 -0.8519845805 -4.6446981586
32 2.2032798948 -0.8519845805
33 -0.4513476688 2.2032798948
34 -3.7788262582 -0.4513476688
35 0.3159648966 -3.7788262582
36 -0.0823738601 0.3159648966
37 0.0359135718 -0.0823738601
38 1.6536966998 0.0359135718
39 0.5127441432 1.6536966998
40 -1.4100831321 0.5127441432
41 1.9506397914 -1.4100831321
42 1.3767128983 1.9506397914
43 -0.0064848806 1.3767128983
44 0.6194640645 -0.0064848806
45 0.4265913494 0.6194640645
46 5.4051115470 0.4265913494
47 1.2050272341 5.4051115470
48 -2.9554868860 1.2050272341
49 -1.3917560847 -2.9554868860
50 -2.8500537133 -1.3917560847
51 -2.1805344529 -2.8500537133
52 -0.5665819353 -2.1805344529
53 -1.1073539098 -0.5665819353
54 4.0784939542 -1.1073539098
55 -2.6127710637 4.0784939542
56 -0.0516715606 -2.6127710637
57 -1.9317971573 -0.0516715606
58 0.0009104966 -1.9317971573
59 1.8250548732 0.0009104966
60 1.9875990494 1.8250548732
61 -9.7401962197 1.9875990494
> 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/75l2g1321987457.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/8fia11321987457.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/91q7f1321987457.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')
Warning messages:
1: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced
2: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/wessaorg/rcomp/tmp/103irb1321987457.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, 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/wessaorg/rcomp/tmp/11copc1321987457.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/wessaorg/rcomp/tmp/12zo2b1321987457.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/wessaorg/rcomp/tmp/13r3o71321987457.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/wessaorg/rcomp/tmp/14l5fr1321987457.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/wessaorg/rcomp/tmp/15rh871321987457.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/wessaorg/rcomp/tmp/160j821321987457.tab")
+ }
>
> try(system("convert tmp/1lif61321987457.ps tmp/1lif61321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/2ecab1321987457.ps tmp/2ecab1321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/37twe1321987457.ps tmp/37twe1321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/40azq1321987457.ps tmp/40azq1321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/5b21d1321987457.ps tmp/5b21d1321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ghh71321987457.ps tmp/6ghh71321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/75l2g1321987457.ps tmp/75l2g1321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/8fia11321987457.ps tmp/8fia11321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/91q7f1321987457.ps tmp/91q7f1321987457.png",intern=TRUE))
character(0)
> try(system("convert tmp/103irb1321987457.ps tmp/103irb1321987457.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.270 0.473 3.818