Home » date » 2008 » Nov » 26 »

Seatbelt Law Question 3 b

*Unverified author*
R Software Module: rwasp_multipleregression.wasp (opens new window with default values)
Title produced by software: Multiple Regression
Date of computation: Wed, 26 Nov 2008 11:17:22 -0700
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2.htm/, Retrieved Wed, 26 Nov 2008 18:18:17 +0000
 
BibTeX entries for LaTeX users:
@Manual{KEY,
    author = {{YOUR NAME}},
    publisher = {Office for Research Development and Education},
    title = {Statistical Computations at FreeStatistics.org, URL http://www.freestatistics.org/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2.htm/},
    year = {2008},
}
@Manual{R,
    title = {R: A Language and Environment for Statistical Computing},
    author = {{R Development Core Team}},
    organization = {R Foundation for Statistical Computing},
    address = {Vienna, Austria},
    year = {2008},
    note = {{ISBN} 3-900051-07-0},
    url = {http://www.R-project.org},
}
 
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
 
Feedback Forum:

Post a new message
 
Original text written by user:
 
IsPrivate?
No (this computation is public)
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
101 0 98.7 1 105.1 0 98.4 1 101.7 0 102.9 0 92.2 1 94.9 1 92.8 1 98.5 1 94.3 1 87.4 1 103.4 0 101.2 0 109.6 0 111.9 0 108.9 0 105.6 0 107.8 0 97.5 1 102.4 0 105.6 0 99.8 1 96.2 1 113.1 0 107.4 0 116.8 0 112.9 0 105.3 0 109.3 0 107.9 0 101.1 0 114.7 0 116.2 0 108.4 0 113.4 0 108.7 0 112.6 0 124.2 0 114.9 0 110.5 0 121.5 0 118.1 0 111.7 0 132.7 0 119 0 116.7 0 120.1 0 113.4 0 106.6 0 116.3 0 112.6 0 111.6 0 125.1 0 110.7 0 109.6 0 114.2 0 113.4 0 116 0 109.6 0 117.8 0 115.8 0 125.3 0 113 0 120.5 0 116.6 0 111.8 0 115.2 0 118.6 0 122.4 0 116.4 0 114.5 0 119.8 0 115.8 0 127.8 0 118.8 0 119.7 0 118.6 0 120.8 0 115.9 0 109.7 0 114.8 0 116.2 0 112.2 0
 
Output produced by software:

Enter (or paste) a matrix (table) containing all data (time) series. Every column represents a different variable and must be delimited by a space or Tab. Every row represents a period in time (or category) and must be delimited by hard returns. The easiest way to enter data is to copy and paste a block of spreadsheet cells. Please, do not use commas or spaces to seperate groups of digits!


Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135


Multiple Linear Regression - Estimated Regression Equation
y[t] = + 100.940779220779 -9.5078787878788x[t] + 2.8386219336219M1[t] + 1.27239538239537M2[t] + 9.28963203463204M3[t] + 4.36626262626262M4[t] + 2.19778499278498M5[t] + 5.05900432900432M6[t] + 1.89277777777777M7[t] -0.287734487734494M8[t] + 3.75807359307359M9[t] + 4.24786435786436M10[t] + 2.25306637806637M11[t] + 0.195923520923521t + e[t]


Multiple Linear Regression - Ordinary Least Squares
VariableParameterS.D.T-STAT
H0: parameter = 0
2-tail p-value1-tail p-value
(Intercept)100.9407792207792.44635641.261700
x-9.50787878787881.974079-4.81648e-064e-06
M12.83862193362192.6730441.06190.2919110.145956
M21.272395382395372.6062740.48820.6269310.313465
M39.289632034632042.6616563.49020.000840.00042
M44.366262626262622.5983151.68040.0973330.048667
M52.197784992784982.6512610.8290.4099460.204973
M65.059004329004322.6464391.91160.0600180.030009
M71.892777777777772.5883330.73130.4670530.233527
M8-0.2877344877344942.56365-0.11220.9109570.455479
M93.758073593073592.5829931.45490.1501580.075079
M104.247864357864362.580721.6460.1042470.052123
M112.253066378066372.5616290.87950.3821160.191058
t0.1959235209235210.0262757.456700


Multiple Linear Regression - Regression Statistics
Multiple R0.86328875740995
R-squared0.745267478670416
Adjusted R-squared0.697960010423493
F-TEST (value)15.7536961136975
F-TEST (DF numerator)13
F-TEST (DF denominator)70
p-value6.66133814775094e-16
Multiple Linear Regression - Residual Statistics
Residual Standard Deviation4.7921172389056
Sum Squared Residuals1607.50713419913


Multiple Linear Regression - Actuals, Interpolation, and Residuals
Time or IndexActualsInterpolation
Forecast
Residuals
Prediction Error
1101103.975324675325-2.97532467532478
298.793.09714285714295.60285714285715
3105.1110.818181818182-5.7181818181818
498.496.58285714285711.81714285714287
5101.7104.118181818182-2.41818181818184
6102.9107.175324675325-4.27532467532465
792.294.6971428571429-2.49714285714285
894.992.71255411255412.18744588744589
992.896.9542857142857-4.15428571428571
1098.597.640.860000000000004
1194.395.8411255411255-1.54112554112554
1287.493.7839826839827-6.38398268398268
13103.4106.326406926407-2.92640692640690
14101.2104.956103896104-3.7561038961039
15109.6113.169264069264-3.56926406926408
16111.9108.4418181818183.45818181818182
17108.9106.4692640692642.43073593073594
18105.6109.526406926407-3.92640692640693
19107.8106.5561038961041.2438961038961
2097.595.06363636363642.43636363636364
21102.4108.813246753247-6.41324675324675
22105.6109.498961038961-3.89896103896105
2399.898.19220779220781.60779220779221
2496.296.1350649350650.064935064935066
25113.1108.6774891774894.42251082251084
26107.4107.3071861471860.0928138528138628
27116.8115.5203463203461.27965367965368
28112.9110.7929004329002.10709956709957
29105.3108.820346320346-3.52034632034632
30109.3111.877489177489-2.57748917748918
31107.9108.907186147186-1.00718614718614
32101.1106.922597402597-5.82259740259741
33114.7111.1643290043293.53567099567100
34116.2111.8500432900434.34995670995671
35108.4110.051168831169-1.65116883116882
36113.4107.9940259740265.40597402597403
37108.7111.028571428571-2.32857142857141
38112.6109.6582683982682.9417316017316
39124.2117.8714285714296.32857142857143
40114.9113.1439826839831.75601731601732
41110.5111.171428571429-0.671428571428568
42121.5114.2285714285717.27142857142857
43118.1111.2582683982686.84173160173159
44111.7109.2736796536802.42632034632035
45132.7113.51541125541119.1845887445887
46119114.2011255411264.79887445887446
47116.7112.4022510822514.29774891774892
48120.1110.3451082251089.75489177489177
49113.4113.3796536796540.0203463203463458
50106.6112.009350649351-5.40935064935065
51116.3120.222510822511-3.92251082251083
52112.6115.495064935065-2.89506493506494
53111.6113.522510822511-1.92251082251082
54125.1116.5796536796548.52034632034632
55110.7113.609350649351-2.90935064935065
56109.6111.624761904762-2.02476190476191
57114.2115.866493506494-1.66649350649351
58113.4116.552207792208-3.15220779220779
59116114.7533333333331.24666666666667
60109.6112.696190476190-3.09619047619048
61117.8115.7307359307362.06926406926409
62115.8114.3604329004331.4395670995671
63125.3122.5735930735932.72640692640692
64113117.846147186147-4.84614718614719
65120.5115.8735930735934.62640692640693
66116.6118.930735930736-2.33073593073594
67111.8115.960432900433-4.16043290043290
68115.2113.9758441558441.22415584415585
69118.6118.2175757575760.382424242424234
70122.4118.903290043293.49670995670996
71116.4117.104415584416-0.704415584415578
72114.5115.047272727273-0.547272727272732
73119.8118.0818181818181.71818181818183
74115.8116.711515151515-0.911515151515152
75127.8124.9246753246752.87532467532467
76118.8120.197229437229-1.39722943722944
77119.7118.2246753246751.47532467532468
78118.6121.281818181818-2.68181818181819
79120.8118.3115151515152.48848484848484
80115.9116.326926406926-0.426926406926401
81109.7120.568658008658-10.868658008658
82114.8121.254372294372-6.4543722943723
83116.2119.455497835498-3.25549783549783
84112.2117.398354978355-5.19835497835498
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/1hwpt1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/1hwpt1227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/2fl1v1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/2fl1v1227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/3zv4o1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/3zv4o1227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/4o9op1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/4o9op1227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/5sy6d1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/5sy6d1227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/634or1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/634or1227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/71ake1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/71ake1227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/8rnm71227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/8rnm71227723438.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/9gx1u1227723438.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2008/Nov/26/t1227723488jkozw8yce1vpwx2/9gx1u1227723438.ps (open in new window)


 
Parameters (Session):
par1 = 1 ; par2 = Include Monthly Dummies ; par3 = Linear Trend ;
 
Parameters (R input):
par1 = 1 ; par2 = Include Monthly Dummies ; par3 = Linear Trend ;
 
R code (references can be found in the software module):
library(lattice)
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
k <- length(x[1,])
df <- as.data.frame(x)
(mylm <- lm(df))
(mysum <- summary(mylm))
bitmap(file='test0.png')
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()
bitmap(file='test1.png')
plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
grid()
dev.off()
bitmap(file='test2.png')
hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
grid()
dev.off()
bitmap(file='test3.png')
densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
dev.off()
bitmap(file='test4.png')
qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
grid()
dev.off()
(myerror <- as.ts(mysum$resid))
bitmap(file='test5.png')
dum <- cbind(lag(myerror,k=1),myerror)
dum
dum1 <- dum[2:length(myerror),]
dum1
z <- as.data.frame(dum1)
z
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()
bitmap(file='test6.png')
acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
grid()
dev.off()
bitmap(file='test7.png')
pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
grid()
dev.off()
bitmap(file='test8.png')
opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
plot(mylm, las = 1, sub='Residual Diagnostics')
par(opar)
dev.off()
load(file='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='mytable1.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<br />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='mytable2.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='mytable3.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<br />Forecast', 1, TRUE)
a<-table.element(a, 'Residuals<br />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='mytable4.tab')
 





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

  • personalize online software applications according to your needs
  • enforce strict security rules with respect to the data that you upload (e.g. statistical data)
  • manage user sessions of online applications
  • alert you about important changes or upgrades in resources or applications

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by