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(10
+ ,14
+ ,11
+ ,24
+ ,26
+ ,14
+ ,11
+ ,7
+ ,25
+ ,23
+ ,18
+ ,6
+ ,17
+ ,30
+ ,25
+ ,15
+ ,12
+ ,10
+ ,19
+ ,23
+ ,18
+ ,8
+ ,12
+ ,22
+ ,19
+ ,11
+ ,10
+ ,12
+ ,22
+ ,29
+ ,17
+ ,10
+ ,11
+ ,25
+ ,25
+ ,19
+ ,11
+ ,11
+ ,23
+ ,21
+ ,7
+ ,16
+ ,12
+ ,17
+ ,22
+ ,12
+ ,11
+ ,13
+ ,21
+ ,25
+ ,13
+ ,13
+ ,14
+ ,19
+ ,24
+ ,15
+ ,12
+ ,16
+ ,19
+ ,18
+ ,14
+ ,8
+ ,11
+ ,15
+ ,22
+ ,14
+ ,12
+ ,10
+ ,16
+ ,15
+ ,16
+ ,11
+ ,11
+ ,23
+ ,22
+ ,16
+ ,4
+ ,15
+ ,27
+ ,28
+ ,12
+ ,9
+ ,9
+ ,22
+ ,20
+ ,12
+ ,8
+ ,11
+ ,14
+ ,12
+ ,13
+ ,8
+ ,17
+ ,22
+ ,24
+ ,16
+ ,14
+ ,17
+ ,23
+ ,20
+ ,9
+ ,15
+ ,11
+ ,23
+ ,21
+ ,11
+ ,11
+ ,11
+ ,20
+ ,28
+ ,14
+ ,8
+ ,15
+ ,23
+ ,24
+ ,11
+ ,9
+ ,13
+ ,19
+ ,24
+ ,17
+ ,9
+ ,13
+ ,22
+ ,23
+ ,14
+ ,8
+ ,12
+ ,32
+ ,25
+ ,15
+ ,9
+ ,17
+ ,25
+ ,21
+ ,11
+ ,16
+ ,9
+ ,29
+ ,26
+ ,15
+ ,11
+ ,9
+ ,28
+ ,22
+ ,14
+ ,16
+ ,12
+ ,17
+ ,22
+ ,11
+ ,12
+ ,18
+ ,28
+ ,22
+ ,12
+ ,12
+ ,12
+ ,29
+ ,23
+ ,9
+ ,10
+ ,15
+ ,14
+ ,17
+ ,16
+ ,9
+ ,16
+ ,25
+ ,23
+ ,13
+ ,10
+ ,10
+ ,26
+ ,23
+ ,15
+ ,12
+ ,11
+ ,20
+ ,25
+ ,10
+ ,14
+ ,9
+ ,32
+ ,24
+ ,13
+ ,14
+ ,17
+ ,25
+ ,21
+ ,16
+ ,10
+ ,12
+ ,20
+ ,28
+ ,15
+ ,6
+ ,6
+ ,15
+ ,16
+ ,13
+ ,13
+ ,12
+ ,24
+ ,29
+ ,16
+ ,11
+ ,11
+ ,23
+ ,22
+ ,15
+ ,7
+ ,7
+ ,22
+ ,28
+ ,16
+ ,15
+ ,13
+ ,14
+ ,16
+ ,15
+ ,9
+ ,12
+ ,24
+ ,25
+ ,13
+ ,10
+ ,13
+ ,24
+ ,24
+ ,11
+ ,10
+ ,12
+ ,22
+ ,29
+ ,17
+ ,10
+ ,11
+ ,19
+ ,23
+ ,10
+ ,11
+ ,9
+ ,31
+ ,30
+ ,17
+ ,8
+ ,11
+ ,22
+ ,24
+ ,14
+ ,13
+ ,10
+ ,19
+ ,25
+ ,15
+ ,11
+ ,11
+ ,25
+ ,25
+ ,16
+ ,9
+ ,15
+ ,27
+ ,26
+ ,12
+ ,12
+ ,14
+ ,22
+ ,24
+ ,11
+ ,12
+ ,13
+ ,19
+ ,22
+ ,16
+ ,8
+ ,16
+ ,25
+ ,24
+ ,9
+ ,14
+ ,8
+ ,19
+ ,27
+ ,15
+ ,11
+ ,16
+ ,20
+ ,24
+ ,15
+ ,10
+ ,12
+ ,17
+ ,21
+ ,13
+ ,11
+ ,9
+ ,17
+ ,23
+ ,15
+ ,10
+ ,15
+ ,22
+ ,20
+ ,15
+ ,12
+ ,16
+ ,19
+ ,18
+ ,18
+ ,8
+ ,15
+ ,21
+ ,22
+ ,16
+ ,14
+ ,11
+ ,20
+ ,29
+ ,12
+ ,14
+ ,11
+ ,17
+ ,15
+ ,15
+ ,8
+ ,16
+ ,18
+ ,24
+ ,13
+ ,6
+ ,8
+ ,29
+ ,23
+ ,13
+ ,8
+ ,13
+ ,21
+ ,24
+ ,13
+ ,14
+ ,15
+ ,22
+ ,24
+ ,14
+ ,11
+ ,7
+ ,26
+ ,22
+ ,15
+ ,11
+ ,12
+ ,17
+ ,16
+ ,11
+ ,14
+ ,14
+ ,25
+ ,19
+ ,14
+ ,11
+ ,17
+ ,21
+ ,23
+ ,17
+ ,8
+ ,10
+ ,22
+ ,24
+ ,13
+ ,11
+ ,13
+ ,24
+ ,18
+ ,12
+ ,8
+ ,9
+ ,18
+ ,23
+ ,13
+ ,13
+ ,12
+ ,22
+ ,15
+ ,16
+ ,12
+ ,15
+ ,29
+ ,22
+ ,13
+ ,9
+ ,12
+ ,10
+ ,13
+ ,19
+ ,7
+ ,11
+ ,26
+ ,22)
+ ,dim=c(5
+ ,80)
+ ,dimnames=list(c('Perceived_happiness'
+ ,'Doubts_about_actions'
+ ,'Parental_expectations'
+ ,'Personal_standards'
+ ,'Organization')
+ ,1:80))
> y <- array(NA,dim=c(5,80),dimnames=list(c('Perceived_happiness','Doubts_about_actions','Parental_expectations','Personal_standards','Organization'),1:80))
> 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 = 'Do not include Seasonal 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
Perceived_happiness Doubts_about_actions Parental_expectations
1 10 14 11
2 14 11 7
3 18 6 17
4 15 12 10
5 18 8 12
6 11 10 12
7 17 10 11
8 19 11 11
9 7 16 12
10 12 11 13
11 13 13 14
12 15 12 16
13 14 8 11
14 14 12 10
15 16 11 11
16 16 4 15
17 12 9 9
18 12 8 11
19 13 8 17
20 16 14 17
21 9 15 11
22 11 11 11
23 14 8 15
24 11 9 13
25 17 9 13
26 14 8 12
27 15 9 17
28 11 16 9
29 15 11 9
30 14 16 12
31 11 12 18
32 12 12 12
33 9 10 15
34 16 9 16
35 13 10 10
36 15 12 11
37 10 14 9
38 13 14 17
39 16 10 12
40 15 6 6
41 13 13 12
42 16 11 11
43 15 7 7
44 16 15 13
45 15 9 12
46 13 10 13
47 11 10 12
48 17 10 11
49 10 11 9
50 17 8 11
51 14 13 10
52 15 11 11
53 16 9 15
54 12 12 14
55 11 12 13
56 16 8 16
57 9 14 8
58 15 11 16
59 15 10 12
60 13 11 9
61 15 10 15
62 15 12 16
63 18 8 15
64 16 14 11
65 12 14 11
66 15 8 16
67 13 6 8
68 13 8 13
69 13 14 15
70 14 11 7
71 15 11 12
72 11 14 14
73 14 11 17
74 17 8 10
75 13 11 13
76 12 8 9
77 13 13 12
78 16 12 15
79 13 9 12
80 19 7 11
Personal_standards Organization t
1 24 26 1
2 25 23 2
3 30 25 3
4 19 23 4
5 22 19 5
6 22 29 6
7 25 25 7
8 23 21 8
9 17 22 9
10 21 25 10
11 19 24 11
12 19 18 12
13 15 22 13
14 16 15 14
15 23 22 15
16 27 28 16
17 22 20 17
18 14 12 18
19 22 24 19
20 23 20 20
21 23 21 21
22 20 28 22
23 23 24 23
24 19 24 24
25 22 23 25
26 32 25 26
27 25 21 27
28 29 26 28
29 28 22 29
30 17 22 30
31 28 22 31
32 29 23 32
33 14 17 33
34 25 23 34
35 26 23 35
36 20 25 36
37 32 24 37
38 25 21 38
39 20 28 39
40 15 16 40
41 24 29 41
42 23 22 42
43 22 28 43
44 14 16 44
45 24 25 45
46 24 24 46
47 22 29 47
48 19 23 48
49 31 30 49
50 22 24 50
51 19 25 51
52 25 25 52
53 27 26 53
54 22 24 54
55 19 22 55
56 25 24 56
57 19 27 57
58 20 24 58
59 17 21 59
60 17 23 60
61 22 20 61
62 19 18 62
63 21 22 63
64 20 29 64
65 17 15 65
66 18 24 66
67 29 23 67
68 21 24 68
69 22 24 69
70 26 22 70
71 17 16 71
72 25 19 72
73 21 23 73
74 22 24 74
75 24 18 75
76 18 23 76
77 22 15 77
78 29 22 78
79 10 13 79
80 26 22 80
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Doubts_about_actions Parental_expectations
17.17152 -0.41647 0.11349
Personal_standards Organization t
0.04611 -0.06622 0.00539
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-5.40686 -1.85336 -0.01822 1.62259 5.44817
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.17152 2.48312 6.915 1.41e-09 ***
Doubts_about_actions -0.41647 0.09971 -4.177 7.98e-05 ***
Parental_expectations 0.11349 0.09226 1.230 0.223
Personal_standards 0.04611 0.06490 0.710 0.480
Organization -0.06622 0.07693 -0.861 0.392
t 0.00539 0.01106 0.487 0.627
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.263 on 74 degrees of freedom
Multiple R-squared: 0.2195, Adjusted R-squared: 0.1668
F-statistic: 4.163 on 5 and 74 DF, p-value: 0.002182
> 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.8573967 0.2852065 0.14260326
[2,] 0.7882074 0.4235852 0.21179262
[3,] 0.7337529 0.5324942 0.26624710
[4,] 0.6300993 0.7398013 0.36990066
[5,] 0.5886211 0.8227578 0.41137892
[6,] 0.6096994 0.7806012 0.39030061
[7,] 0.5375662 0.9248676 0.46243378
[8,] 0.5361574 0.9276851 0.46384256
[9,] 0.7125630 0.5748740 0.28743702
[10,] 0.8292956 0.3414088 0.17070439
[11,] 0.7850230 0.4299540 0.21497700
[12,] 0.8024398 0.3951204 0.19756022
[13,] 0.8208321 0.3583359 0.17916793
[14,] 0.8041740 0.3916520 0.19582602
[15,] 0.7468075 0.5063851 0.25319254
[16,] 0.7346700 0.5306600 0.26533002
[17,] 0.8112222 0.3775555 0.18877777
[18,] 0.7864568 0.4270864 0.21354321
[19,] 0.7289543 0.5420914 0.27104572
[20,] 0.6706251 0.6587498 0.32937489
[21,] 0.6439750 0.7120499 0.35602496
[22,] 0.7732552 0.4534896 0.22674481
[23,] 0.8157960 0.3684081 0.18420403
[24,] 0.7778305 0.4443390 0.22216952
[25,] 0.9173657 0.1652686 0.08263428
[26,] 0.9079224 0.1841552 0.09207762
[27,] 0.8794849 0.2410302 0.12051510
[28,] 0.9092442 0.1815115 0.09075576
[29,] 0.9076137 0.1847725 0.09238627
[30,] 0.8851177 0.2297645 0.11488225
[31,] 0.9067038 0.1865924 0.09329622
[32,] 0.8777979 0.2444043 0.12220214
[33,] 0.8449029 0.3101942 0.15509711
[34,] 0.8452532 0.3094936 0.15474681
[35,] 0.8039555 0.3920891 0.19604454
[36,] 0.8792023 0.2415954 0.12079771
[37,] 0.8431331 0.3137339 0.15686695
[38,] 0.8090773 0.3818454 0.19092269
[39,] 0.8373617 0.3252765 0.16263827
[40,] 0.8796707 0.2406585 0.12032925
[41,] 0.9267934 0.1464132 0.07320659
[42,] 0.9275678 0.1448644 0.07243218
[43,] 0.9200206 0.1599588 0.07997940
[44,] 0.9064756 0.1870488 0.09352440
[45,] 0.8766745 0.2466510 0.12332551
[46,] 0.8510936 0.2978127 0.14890635
[47,] 0.8489656 0.3020688 0.15103441
[48,] 0.7989397 0.4021206 0.20106032
[49,] 0.8497274 0.3005452 0.15027261
[50,] 0.7992240 0.4015520 0.20077598
[51,] 0.7453568 0.5092865 0.25464325
[52,] 0.6733265 0.6533470 0.32667349
[53,] 0.5906676 0.8186648 0.40933238
[54,] 0.5299508 0.9400985 0.47004924
[55,] 0.6778218 0.6443565 0.32217823
[56,] 0.7338031 0.5323937 0.26619685
[57,] 0.6982934 0.6034133 0.30170664
[58,] 0.6416891 0.7166217 0.35831085
[59,] 0.6493963 0.7012074 0.35060368
[60,] 0.7088842 0.5822316 0.29111579
[61,] 0.7080923 0.5838154 0.29190771
[62,] 0.5688966 0.8622067 0.43110336
[63,] 0.5793670 0.8412659 0.42063295
> postscript(file="/var/www/html/rcomp/tmp/1ifsw1290530003.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/2ifsw1290530003.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/3s6rz1290530003.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/4s6rz1290530003.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/5s6rz1290530003.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 = 80
Frequency = 1
1 2 3 4 5 6 7
-1.9797272 0.9746655 1.6539770 2.3165566 3.0151355 -2.4951556 3.2097426
8 9 10 11 12 13 14
5.4481721 -4.2454960 -1.4324912 0.3075691 1.2614428 -0.3930781 0.8712542
15 16 17 18 19 20 21
2.4766593 -0.6850733 -2.2264054 -3.0360844 -2.2966658 2.8857632 -2.9560331
22 23 24 25 26 27 28
-2.0254398 -1.1373653 -3.3148786 2.4751846 -1.1618536 -0.2602995 -0.2959033
29 30 31 32 33 34 35
1.3976203 2.6413156 -3.2180601 -1.5224324 -5.4068586 0.9478895 -1.0062335
36 37 38 39 40 41 42
2.1169172 -2.4481082 -0.2372589 2.3529804 -0.2014122 0.4733748 2.3311314
43 44 45 46 47 48 49
0.5572284 3.7769357 0.5210845 -1.2475413 -2.7161425 3.1329829 -3.3187750
50 51 52 53 54 55 56
2.2171575 1.6121295 1.3836620 1.0653960 -1.4789938 -2.3650017 0.4790619
57 58 59 60 61 62 63
-2.6443403 0.9482304 0.9199954 -0.1960397 0.2719929 0.9919466 2.6068246
64 65 66 67 68 69 70
4.0637980 -0.7302953 -0.2520667 -2.7559349 -2.0607213 0.1596041 0.4958239
71 72 73 74 75 76 77
0.9406988 -2.2124942 -0.3584304 2.2012845 -1.3846833 -2.5777865 -0.5554759
78 79 80
1.8229589 -1.8112319 3.3221202
> postscript(file="/var/www/html/rcomp/tmp/63y8k1290530003.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 = 80
Frequency = 1
lag(myerror, k = 1) myerror
0 -1.9797272 NA
1 0.9746655 -1.9797272
2 1.6539770 0.9746655
3 2.3165566 1.6539770
4 3.0151355 2.3165566
5 -2.4951556 3.0151355
6 3.2097426 -2.4951556
7 5.4481721 3.2097426
8 -4.2454960 5.4481721
9 -1.4324912 -4.2454960
10 0.3075691 -1.4324912
11 1.2614428 0.3075691
12 -0.3930781 1.2614428
13 0.8712542 -0.3930781
14 2.4766593 0.8712542
15 -0.6850733 2.4766593
16 -2.2264054 -0.6850733
17 -3.0360844 -2.2264054
18 -2.2966658 -3.0360844
19 2.8857632 -2.2966658
20 -2.9560331 2.8857632
21 -2.0254398 -2.9560331
22 -1.1373653 -2.0254398
23 -3.3148786 -1.1373653
24 2.4751846 -3.3148786
25 -1.1618536 2.4751846
26 -0.2602995 -1.1618536
27 -0.2959033 -0.2602995
28 1.3976203 -0.2959033
29 2.6413156 1.3976203
30 -3.2180601 2.6413156
31 -1.5224324 -3.2180601
32 -5.4068586 -1.5224324
33 0.9478895 -5.4068586
34 -1.0062335 0.9478895
35 2.1169172 -1.0062335
36 -2.4481082 2.1169172
37 -0.2372589 -2.4481082
38 2.3529804 -0.2372589
39 -0.2014122 2.3529804
40 0.4733748 -0.2014122
41 2.3311314 0.4733748
42 0.5572284 2.3311314
43 3.7769357 0.5572284
44 0.5210845 3.7769357
45 -1.2475413 0.5210845
46 -2.7161425 -1.2475413
47 3.1329829 -2.7161425
48 -3.3187750 3.1329829
49 2.2171575 -3.3187750
50 1.6121295 2.2171575
51 1.3836620 1.6121295
52 1.0653960 1.3836620
53 -1.4789938 1.0653960
54 -2.3650017 -1.4789938
55 0.4790619 -2.3650017
56 -2.6443403 0.4790619
57 0.9482304 -2.6443403
58 0.9199954 0.9482304
59 -0.1960397 0.9199954
60 0.2719929 -0.1960397
61 0.9919466 0.2719929
62 2.6068246 0.9919466
63 4.0637980 2.6068246
64 -0.7302953 4.0637980
65 -0.2520667 -0.7302953
66 -2.7559349 -0.2520667
67 -2.0607213 -2.7559349
68 0.1596041 -2.0607213
69 0.4958239 0.1596041
70 0.9406988 0.4958239
71 -2.2124942 0.9406988
72 -0.3584304 -2.2124942
73 2.2012845 -0.3584304
74 -1.3846833 2.2012845
75 -2.5777865 -1.3846833
76 -0.5554759 -2.5777865
77 1.8229589 -0.5554759
78 -1.8112319 1.8229589
79 3.3221202 -1.8112319
80 NA 3.3221202
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.9746655 -1.9797272
[2,] 1.6539770 0.9746655
[3,] 2.3165566 1.6539770
[4,] 3.0151355 2.3165566
[5,] -2.4951556 3.0151355
[6,] 3.2097426 -2.4951556
[7,] 5.4481721 3.2097426
[8,] -4.2454960 5.4481721
[9,] -1.4324912 -4.2454960
[10,] 0.3075691 -1.4324912
[11,] 1.2614428 0.3075691
[12,] -0.3930781 1.2614428
[13,] 0.8712542 -0.3930781
[14,] 2.4766593 0.8712542
[15,] -0.6850733 2.4766593
[16,] -2.2264054 -0.6850733
[17,] -3.0360844 -2.2264054
[18,] -2.2966658 -3.0360844
[19,] 2.8857632 -2.2966658
[20,] -2.9560331 2.8857632
[21,] -2.0254398 -2.9560331
[22,] -1.1373653 -2.0254398
[23,] -3.3148786 -1.1373653
[24,] 2.4751846 -3.3148786
[25,] -1.1618536 2.4751846
[26,] -0.2602995 -1.1618536
[27,] -0.2959033 -0.2602995
[28,] 1.3976203 -0.2959033
[29,] 2.6413156 1.3976203
[30,] -3.2180601 2.6413156
[31,] -1.5224324 -3.2180601
[32,] -5.4068586 -1.5224324
[33,] 0.9478895 -5.4068586
[34,] -1.0062335 0.9478895
[35,] 2.1169172 -1.0062335
[36,] -2.4481082 2.1169172
[37,] -0.2372589 -2.4481082
[38,] 2.3529804 -0.2372589
[39,] -0.2014122 2.3529804
[40,] 0.4733748 -0.2014122
[41,] 2.3311314 0.4733748
[42,] 0.5572284 2.3311314
[43,] 3.7769357 0.5572284
[44,] 0.5210845 3.7769357
[45,] -1.2475413 0.5210845
[46,] -2.7161425 -1.2475413
[47,] 3.1329829 -2.7161425
[48,] -3.3187750 3.1329829
[49,] 2.2171575 -3.3187750
[50,] 1.6121295 2.2171575
[51,] 1.3836620 1.6121295
[52,] 1.0653960 1.3836620
[53,] -1.4789938 1.0653960
[54,] -2.3650017 -1.4789938
[55,] 0.4790619 -2.3650017
[56,] -2.6443403 0.4790619
[57,] 0.9482304 -2.6443403
[58,] 0.9199954 0.9482304
[59,] -0.1960397 0.9199954
[60,] 0.2719929 -0.1960397
[61,] 0.9919466 0.2719929
[62,] 2.6068246 0.9919466
[63,] 4.0637980 2.6068246
[64,] -0.7302953 4.0637980
[65,] -0.2520667 -0.7302953
[66,] -2.7559349 -0.2520667
[67,] -2.0607213 -2.7559349
[68,] 0.1596041 -2.0607213
[69,] 0.4958239 0.1596041
[70,] 0.9406988 0.4958239
[71,] -2.2124942 0.9406988
[72,] -0.3584304 -2.2124942
[73,] 2.2012845 -0.3584304
[74,] -1.3846833 2.2012845
[75,] -2.5777865 -1.3846833
[76,] -0.5554759 -2.5777865
[77,] 1.8229589 -0.5554759
[78,] -1.8112319 1.8229589
[79,] 3.3221202 -1.8112319
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.9746655 -1.9797272
2 1.6539770 0.9746655
3 2.3165566 1.6539770
4 3.0151355 2.3165566
5 -2.4951556 3.0151355
6 3.2097426 -2.4951556
7 5.4481721 3.2097426
8 -4.2454960 5.4481721
9 -1.4324912 -4.2454960
10 0.3075691 -1.4324912
11 1.2614428 0.3075691
12 -0.3930781 1.2614428
13 0.8712542 -0.3930781
14 2.4766593 0.8712542
15 -0.6850733 2.4766593
16 -2.2264054 -0.6850733
17 -3.0360844 -2.2264054
18 -2.2966658 -3.0360844
19 2.8857632 -2.2966658
20 -2.9560331 2.8857632
21 -2.0254398 -2.9560331
22 -1.1373653 -2.0254398
23 -3.3148786 -1.1373653
24 2.4751846 -3.3148786
25 -1.1618536 2.4751846
26 -0.2602995 -1.1618536
27 -0.2959033 -0.2602995
28 1.3976203 -0.2959033
29 2.6413156 1.3976203
30 -3.2180601 2.6413156
31 -1.5224324 -3.2180601
32 -5.4068586 -1.5224324
33 0.9478895 -5.4068586
34 -1.0062335 0.9478895
35 2.1169172 -1.0062335
36 -2.4481082 2.1169172
37 -0.2372589 -2.4481082
38 2.3529804 -0.2372589
39 -0.2014122 2.3529804
40 0.4733748 -0.2014122
41 2.3311314 0.4733748
42 0.5572284 2.3311314
43 3.7769357 0.5572284
44 0.5210845 3.7769357
45 -1.2475413 0.5210845
46 -2.7161425 -1.2475413
47 3.1329829 -2.7161425
48 -3.3187750 3.1329829
49 2.2171575 -3.3187750
50 1.6121295 2.2171575
51 1.3836620 1.6121295
52 1.0653960 1.3836620
53 -1.4789938 1.0653960
54 -2.3650017 -1.4789938
55 0.4790619 -2.3650017
56 -2.6443403 0.4790619
57 0.9482304 -2.6443403
58 0.9199954 0.9482304
59 -0.1960397 0.9199954
60 0.2719929 -0.1960397
61 0.9919466 0.2719929
62 2.6068246 0.9919466
63 4.0637980 2.6068246
64 -0.7302953 4.0637980
65 -0.2520667 -0.7302953
66 -2.7559349 -0.2520667
67 -2.0607213 -2.7559349
68 0.1596041 -2.0607213
69 0.4958239 0.1596041
70 0.9406988 0.4958239
71 -2.2124942 0.9406988
72 -0.3584304 -2.2124942
73 2.2012845 -0.3584304
74 -1.3846833 2.2012845
75 -2.5777865 -1.3846833
76 -0.5554759 -2.5777865
77 1.8229589 -0.5554759
78 -1.8112319 1.8229589
79 3.3221202 -1.8112319
> 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/7w7751290530003.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/8w7751290530003.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/9w7751290530003.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/10oypq1290530003.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/11ah5w1290530003.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/12vzm21290530003.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/13ki1d1290530003.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/14d9iy1290530003.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/15jb0k1290530004.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/16nczq1290530004.tab")
+ }
> try(system("convert tmp/1ifsw1290530003.ps tmp/1ifsw1290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/2ifsw1290530003.ps tmp/2ifsw1290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/3s6rz1290530003.ps tmp/3s6rz1290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/4s6rz1290530003.ps tmp/4s6rz1290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/5s6rz1290530003.ps tmp/5s6rz1290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/63y8k1290530003.ps tmp/63y8k1290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/7w7751290530003.ps tmp/7w7751290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/8w7751290530003.ps tmp/8w7751290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/9w7751290530003.ps tmp/9w7751290530003.png",intern=TRUE))
character(0)
> try(system("convert tmp/10oypq1290530003.ps tmp/10oypq1290530003.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.684 1.605 6.676