Home » date » 2007 » Nov » 16 » attachments

R Software Module: rwasp_multipleregression.wasp (opens new window with default values)
Title produced by software: Multiple Regression
Date of computation: Fri, 16 Nov 2007 06:58:03 -0700
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03.htm/, Retrieved Fri, 16 Nov 2007 14:53:31 +0100
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
102.3 0 105.8 0 106.7 0 109.6 0 111.9 0 113.3 0 114.6 0 115.7 0 117.3 0 119.8 0 120.6 0 121.4 0 123.5 0 125.2 0 126 0 126.8 0 128.1 0 128.2 0 129.3 0 130.6 0 131.4 0 131.1 0 131.2 0 131.2 0 131.5 0 133.5 0 133.7 0 133.5 0 134 0 135.9 0 135.9 0 137.2 0 138.4 0 140.9 0 143 0 144.1 0 146.8 0 149.1 0 149.6 0 151.2 0 153.3 0 156.9 0 157.2 0 158.5 0 160 0 162.5 0 162.9 0 164.7 0 165 0 167.2 0 168.6 0 169.5 0 169.8 0 171.9 0 172 0 173.7 0 173.9 0 175.9 0 175.6 0 176.1 0 176.3 0 179.4 0 179.7 0 179.9 0 180.4 0 182.5 0 183.6 0 183.9 0 184.5 0 187.6 0 188 0 188.5 0 188.6 0 191.9 0 193.5 0 194.9 0 194.9 0 196.2 0 196.2 0 198 0 198.6 0 201.3 0 203.5 0 204.1 0 204.8 1 206.5 1 207.8 1 208.6 1 209.7 1 210 1 211.7 1 212.4 1 213.7 1 214.8 1 216.4 1 217.5 1 218.6 1 220.4 1 221.8 1 222.5 1 223.4 1 225.5 1 226.5 1 227.8 1 228.5 1 229.1 1 229.9 1
 
Text written by user:
 
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 compuational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time6 seconds
R Server'Herman Ole Andreas Wold' @ 193.190.124.10:1001


Multiple Linear Regression - Estimated Regression Equation
Y[t] = + 105.254791526706 -0.184143687937644X[t] + 1.17358473718674t + e[t]


Multiple Linear Regression - Ordinary Least Squares
VariableParameterS.D.T-STAT
H0: parameter = 0
2-tail p-value1-tail p-value
(Intercept)105.2547915267060.47985219.349500
X-0.1841436879376440.735517-0.25040.8028030.401402
t1.173584737186740.009782119.97100


Multiple Linear Regression - Regression Statistics
Multiple R0.998215775607425
R-squared0.996434734671533
Adjusted R-squared0.996366171876754
F-TEST (value)14533.1697445343
F-TEST (DF numerator)2
F-TEST (DF denominator)104
p-value0
Multiple Linear Regression - Residual Statistics
Residual Standard Deviation2.19604117057745
Sum Squared Residuals501.550069578604


Multiple Linear Regression - Actuals, Interpolation, and Residuals
Time or IndexActualsInterpolation
Forecast
Residuals
Prediction Error
1102.3106.428376263893-4.12837626389348
2105.8107.60196100108-1.80196100107999
3106.7108.775545738267-2.07554573826671
4109.6109.949130475453-0.349130475453471
5111.9111.1227152126400.777284787359805
6113.3112.2962999498271.00370005017306
7114.6113.4698846870141.13011531298632
8115.7114.6434694242001.05653057579959
9117.3115.8170541613871.48294583861285
10119.8116.9906388985742.80936110142611
11120.6118.1642236357612.43577636423937
12121.4119.3378083729472.06219162705265
13123.5120.5113931101342.9886068898659
14125.2121.6849778473213.51502215267917
15126122.8585625845083.14143741549243
16126.8124.0321473216942.76785267830569
17128.1125.2057320588812.89426794111895
18128.2126.3793167960681.82068320393220
19129.3127.5529015332551.74709846674549
20130.6128.7264862704411.87351372955874
21131.4129.9000710076281.49992899237201
22131.1131.0736557448150.0263442551852623
23131.2132.247240482001-1.04724048200148
24131.2133.420825219188-2.22082521918822
25131.5134.594409956375-3.09440995637494
26133.5135.767994693562-2.26799469356168
27133.7136.941579430748-3.24157943074843
28133.5138.115164167935-4.61516416793516
29134139.288748905122-5.2887489051219
30135.9140.462333642309-4.56233364230863
31135.9141.635918379495-5.73591837949537
32137.2142.809503116682-5.60950311668212
33138.4143.983087853869-5.58308785386884
34140.9145.156672591056-4.25667259105558
35143146.330257328242-3.33025732824232
36144.1147.503842065429-3.40384206542907
37146.8148.677426802616-1.87742680261579
38149.1149.851011539803-0.751011539802541
39149.6151.024596276989-1.42459627698928
40151.2152.198181014176-0.998181014176022
41153.3153.371765751363-0.071765751362737
42156.9154.5453504885492.35464951145052
43157.2155.7189352257361.48106477426377
44158.5156.8925199629231.60748003707704
45160158.0661047001101.9338952998903
46162.5159.2396894372963.26031056270356
47162.9160.4132741744832.48672582551683
48164.7161.586858911673.11314108833008
49165162.7604436488572.23955635114335
50167.2163.9340283860433.26597161395661
51168.6165.107613123233.49238687676987
52169.5166.2811978604173.21880213958314
53169.8167.4547825976042.34521740239641
54171.9168.6283673347903.27163266520967
55172169.8019520719772.19804792802293
56173.7170.9755368091642.72446319083618
57173.9172.1491215463511.75087845364946
58175.9173.3227062835372.57729371646272
59175.6174.4962910207241.10370897927597
60176.1175.6698757579110.430124242089237
61176.3176.843460495098-0.543460495097485
62179.4178.0170452322841.38295476771577
63179.7179.1906299694710.509370030529018
64179.9180.364214706658-0.464214706657703
65180.4181.537799443844-1.13779944384444
66182.5182.711384181031-0.211384181031187
67183.6183.884968918218-0.284968918217928
68183.9185.058553655405-1.15855365540466
69184.5186.232138392591-1.7321383925914
70187.6187.4057231297780.194276870221859
71188188.579307866965-0.579307866964877
72188.5189.752892604152-1.25289260415161
73188.6190.926477341338-2.32647734133835
74191.9192.100062078525-0.200062078525077
75193.5193.2736468157120.226353184288174
76194.9194.4472315528990.452768447101445
77194.9195.620816290085-0.72081629008529
78196.2196.794401027272-0.59440102727205
79196.2197.967985764459-1.76798576445879
80198199.141570501646-1.14157050164551
81198.6200.315155238832-1.71515523883226
82201.3201.488739976019-0.188739976018975
83203.5202.6623247132060.837675286794278
84204.1203.8359094503920.26409054960753
85204.8204.825350499642-0.0253504996415309
86206.5205.9989352368280.501064763171723
87207.8207.1725199740150.627480025984995
88208.6208.3461047112020.253895288798241
89209.7209.5196894483890.180310551611498
90210210.693274185575-0.693274185575227
91211.7211.866858922762-0.166858922761978
92212.4213.040443659949-0.640443659948698
93213.7214.214028397135-0.514028397135453
94214.8215.387613134322-0.587613134322168
95216.4216.561197871509-0.161197871508911
96217.5217.734782608696-0.234782608695654
97218.6218.908367345882-0.308367345882397
98220.4220.0819520830690.318047916930877
99221.8221.2555368202560.544463179744145
100222.5222.4291215574430.0708784425573961
101223.4223.602706294629-0.202706294629335
102225.5224.7762910318160.723708968183921
103226.5225.9498757690030.550124230997184
104227.8227.1234605061900.676539493810457
105228.5228.2970452433760.202954756623709
106229.1229.470629980563-0.370629980563035
107229.9230.64421471775-0.74421471774976
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/1kxkr1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/1kxkr1195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/2tzpb1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/2tzpb1195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/3h9nn1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/3h9nn1195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/48yjt1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/48yjt1195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/5tlge1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/5tlge1195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/6fzct1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/6fzct1195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/72omx1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/72omx1195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/8kir31195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/8kir31195221473.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/98jle1195221473.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/16/t1195221211uvhit2j3hqxrp03/98jle1195221473.ps (open in new window)


 
Parameters:
par1 = 1 ; par2 = Do not include Seasonal 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:

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