::Free Statistics and Forecasting Software::

v1.1.23-r5
 
  Black&White | Blue Theme | Normal Fontsize | Increase Fontsize | Decrease Fontsize | Toggle underline
Secure website (SSL) | Private
 
 


This software module is powered by R

:: Multiple Regression - Free Statistics Software (Calculator) ::

All rights reserved. The non-commercial (academic) use of this software is free of charge. The only thing that is asked in return is to cite this software when results are used in publications.

This free online software (calculator) computes the multiple regression model based on the Ordinary Least Squares method.

Click here to edit the underlying code of this R Module.

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!

Send output to:
Data X:
Names of X columns:
Sample Range:
(leave blank to include all observations)
From:
To:
Column Number of Endogenous Series (?)
Fixed Seasonal Effects 
Type of Equation 
Chart options
Width:
Height:

Click here to edit the underlying code of this R Module.





Source code of R module
1library(lattice)
2library(lmtest)
3n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
4par1 <- as.numeric(par1)
5x <- t(y)
6k <- length(x[1,])
7n <- length(x[,1])
8x1 <- cbind(x[,par1], x[,1:k!=par1])
9mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
10colnames(x1) <- mycolnames #colnames(x)[par1]
11x <- x1
12if (par3 == "First Differences"){
13x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste("(1-B)",colnames(x),sep="")))
14for (i in 1:n-1) {
15for (j in 1:k) {
16x2[i,j] <- x[i+1,j] - x[i,j]
17}
18}
19x <- x2
20}
21if (par2 == "Include Monthly Dummies"){
22x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste("M", seq(1:11), sep ="")))
23for (i in 1:11){
24x2[seq(i,n,12),i] <- 1
25}
26x <- cbind(x, x2)
27}
28if (par2 == "Include Quarterly Dummies"){
29x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste("Q", seq(1:3), sep ="")))
30for (i in 1:3){
31x2[seq(i,n,4),i] <- 1
32}
33x <- cbind(x, x2)
34}
35k <- length(x[1,])
36if (par3 == "Linear Trend"){
37x <- cbind(x, c(1:n))
38colnames(x)[k+1] <- "t"
39}
40x
41k <- length(x[1,])
42df <- as.data.frame(x)
43(mylm <- lm(df))
44(mysum <- summary(mylm))
45if (n > n25) {
46kp3 <- k + 3
47nmkm3 <- n - k - 3
48gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
49numgqtests <- 0
50numsignificant1 <- 0
51numsignificant5 <- 0
52numsignificant10 <- 0
53for (mypoint in kp3:nmkm3) {
54j <- 0
55numgqtests <- numgqtests + 1
56for (myalt in c("greater", "two.sided", "less")) {
57j <- j + 1
58gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
59}
60if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
61if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
62if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
63}
64gqarr
65}
66bitmap(file="test0.png")
67plot(x[,1], type="l", main="Actuals and Interpolation", ylab="value of Actuals and Interpolation (dots)", xlab="time or index")
68points(x[,1]-mysum$resid)
69grid()
70dev.off()
71bitmap(file="test1.png")
72plot(mysum$resid, type="b", pch=19, main="Residuals", ylab="value of Residuals", xlab="time or index")
73grid()
74dev.off()
75bitmap(file="test2.png")
76hist(mysum$resid, main="Residual Histogram", xlab="values of Residuals")
77grid()
78dev.off()
79bitmap(file="test3.png")
80densityplot(~mysum$resid,col="black",main="Residual Density Plot", xlab="values of Residuals")
81dev.off()
82bitmap(file="test4.png")
83qqnorm(mysum$resid, main="Residual Normal Q-Q Plot")
84qqline(mysum$resid)
85grid()
86dev.off()
87(myerror <- as.ts(mysum$resid))
88bitmap(file='test5.png')
89dum <- cbind(lag(myerror,k=1),myerror)
90dum
91dum1 <- dum[2:length(myerror),]
92dum1
93z <- as.data.frame(dum1)
94z
95plot(z,main=paste("Residual Lag plot, lowess, and regression line"), ylab="values of Residuals", xlab="lagged values of Residuals")
96lines(lowess(z))
97abline(lm(z))
98grid()
99dev.off()
100bitmap(file="test6.png")
101acf(mysum$resid, lag.max=length(mysum$resid)/2, main="Residual Autocorrelation Function")
102grid()
103dev.off()
104bitmap(file="test7.png")
105pacf(mysum$resid, lag.max=length(mysum$resid)/2, main="Residual Partial Autocorrelation Function")
106grid()
107dev.off()
108bitmap(file="test8.png")
109opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
110plot(mylm, las = 1, sub="Residual Diagnostics")
111par(opar)
112dev.off()
113if (n > n25) {
114bitmap(file="test9.png")
115plot(kp3:nmkm3,gqarr[,2], main="Goldfeld-Quandt test",ylab="2-sided p-value",xlab="breakpoint")
116grid()
117dev.off()
118}
119load(file="createtable")
120a<-table.start()
121a<-table.row.start(a)
122a<-table.element(a, "Multiple Linear Regression - Estimated Regression Equation", 1, TRUE)
123a<-table.row.end(a)
124myeq <- colnames(x)[1]
125myeq <- paste(myeq, "[t] = ", sep="")
126for (i in 1:k){
127if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, "+", "")
128myeq <- paste(myeq, mysum$coefficients[i,1], sep=" ")
129if (rownames(mysum$coefficients)[i] != "(Intercept)") {
130myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep="")
131if (rownames(mysum$coefficients)[i] != "t") myeq <- paste(myeq, "[t]", sep="")
132}
133}
134myeq <- paste(myeq, " + e[t]")
135a<-table.row.start(a)
136a<-table.element(a, myeq)
137a<-table.row.end(a)
138a<-table.end(a)
139table.save(a,file="mytable1.tab")
140a<-table.start()
141a<-table.row.start(a)
142a<-table.element(a,hyperlink("http://www.xycoon.com/ols1.htm","Multiple Linear Regression - Ordinary Least Squares",""), 6, TRUE)
143a<-table.row.end(a)
144a<-table.row.start(a)
145a<-table.element(a,"Variable",header=TRUE)
146a<-table.element(a,"Parameter",header=TRUE)
147a<-table.element(a,"S.D.",header=TRUE)
148a<-table.element(a,"T-STAT
H0: parameter = 0",header=TRUE)
149a<-table.element(a,"2-tail p-value",header=TRUE)
150a<-table.element(a,"1-tail p-value",header=TRUE)
151a<-table.row.end(a)
152for (i in 1:k){
153a<-table.row.start(a)
154a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
155a<-table.element(a,mysum$coefficients[i,1])
156a<-table.element(a, round(mysum$coefficients[i,2],6))
157a<-table.element(a, round(mysum$coefficients[i,3],4))
158a<-table.element(a, round(mysum$coefficients[i,4],6))
159a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
160a<-table.row.end(a)
161}
162a<-table.end(a)
163table.save(a,file="mytable2.tab")
164a<-table.start()
165a<-table.row.start(a)
166a<-table.element(a, "Multiple Linear Regression - Regression Statistics", 2, TRUE)
167a<-table.row.end(a)
168a<-table.row.start(a)
169a<-table.element(a, "Multiple R",1,TRUE)
170a<-table.element(a, sqrt(mysum$r.squared))
171a<-table.row.end(a)
172a<-table.row.start(a)
173a<-table.element(a, "R-squared",1,TRUE)
174a<-table.element(a, mysum$r.squared)
175a<-table.row.end(a)
176a<-table.row.start(a)
177a<-table.element(a, "Adjusted R-squared",1,TRUE)
178a<-table.element(a, mysum$adj.r.squared)
179a<-table.row.end(a)
180a<-table.row.start(a)
181a<-table.element(a, "F-TEST (value)",1,TRUE)
182a<-table.element(a, mysum$fstatistic[1])
183a<-table.row.end(a)
184a<-table.row.start(a)
185a<-table.element(a, "F-TEST (DF numerator)",1,TRUE)
186a<-table.element(a, mysum$fstatistic[2])
187a<-table.row.end(a)
188a<-table.row.start(a)
189a<-table.element(a, "F-TEST (DF denominator)",1,TRUE)
190a<-table.element(a, mysum$fstatistic[3])
191a<-table.row.end(a)
192a<-table.row.start(a)
193a<-table.element(a, "p-value",1,TRUE)
194a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
195a<-table.row.end(a)
196a<-table.row.start(a)
197a<-table.element(a, "Multiple Linear Regression - Residual Statistics", 2, TRUE)
198a<-table.row.end(a)
199a<-table.row.start(a)
200a<-table.element(a, "Residual Standard Deviation",1,TRUE)
201a<-table.element(a, mysum$sigma)
202a<-table.row.end(a)
203a<-table.row.start(a)
204a<-table.element(a, "Sum Squared Residuals",1,TRUE)
205a<-table.element(a, sum(myerror*myerror))
206a<-table.row.end(a)
207a<-table.end(a)
208table.save(a,file="mytable3.tab")
209a<-table.start()
210a<-table.row.start(a)
211a<-table.element(a, "Multiple Linear Regression - Actuals, Interpolation, and Residuals", 4, TRUE)
212a<-table.row.end(a)
213a<-table.row.start(a)
214a<-table.element(a, "Time or Index", 1, TRUE)
215a<-table.element(a, "Actuals", 1, TRUE)
216a<-table.element(a, "Interpolation
Forecast", 1, TRUE)
217a<-table.element(a, "Residuals
Prediction Error", 1, TRUE)
218a<-table.row.end(a)
219for (i in 1:n) {
220a<-table.row.start(a)
221a<-table.element(a,i, 1, TRUE)
222a<-table.element(a,x[i])
223a<-table.element(a,x[i]-mysum$resid[i])
224a<-table.element(a,mysum$resid[i])
225a<-table.row.end(a)
226}
227a<-table.end(a)
228table.save(a,file="mytable4.tab")
229if (n > n25) {
230a<-table.start()
231a<-table.row.start(a)
232a<-table.element(a,"Goldfeld-Quandt test for Heteroskedasticity",4,TRUE)
233a<-table.row.end(a)
234a<-table.row.start(a)
235a<-table.element(a,"p-values",header=TRUE)
236a<-table.element(a,"Alternative Hypothesis",3,header=TRUE)
237a<-table.row.end(a)
238a<-table.row.start(a)
239a<-table.element(a,"breakpoint index",header=TRUE)
240a<-table.element(a,"greater",header=TRUE)
241a<-table.element(a,"2-sided",header=TRUE)
242a<-table.element(a,"less",header=TRUE)
243a<-table.row.end(a)
244for (mypoint in kp3:nmkm3) {
245a<-table.row.start(a)
246a<-table.element(a,mypoint,header=TRUE)
247a<-table.element(a,gqarr[mypoint-kp3+1,1])
248a<-table.element(a,gqarr[mypoint-kp3+1,2])
249a<-table.element(a,gqarr[mypoint-kp3+1,3])
250a<-table.row.end(a)
251}
252a<-table.end(a)
253table.save(a,file="mytable5.tab")
254a<-table.start()
255a<-table.row.start(a)
256a<-table.element(a,"Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity",4,TRUE)
257a<-table.row.end(a)
258a<-table.row.start(a)
259a<-table.element(a,"Description",header=TRUE)
260a<-table.element(a,"# significant tests",header=TRUE)
261a<-table.element(a,"% significant tests",header=TRUE)
262a<-table.element(a,"OK/NOK",header=TRUE)
263a<-table.row.end(a)
264a<-table.row.start(a)
265a<-table.element(a,"1% type I error level",header=TRUE)
266a<-table.element(a,numsignificant1)
267a<-table.element(a,numsignificant1/numgqtests)
268if (numsignificant1/numgqtests < 0.01) dum <- "OK" else dum <- "NOK"
269a<-table.element(a,dum)
270a<-table.row.end(a)
271a<-table.row.start(a)
272a<-table.element(a,"5% type I error level",header=TRUE)
273a<-table.element(a,numsignificant5)
274a<-table.element(a,numsignificant5/numgqtests)
275if (numsignificant5/numgqtests < 0.05) dum <- "OK" else dum <- "NOK"
276a<-table.element(a,dum)
277a<-table.row.end(a)
278a<-table.row.start(a)
279a<-table.element(a,"10% type I error level",header=TRUE)
280a<-table.element(a,numsignificant10)
281a<-table.element(a,numsignificant10/numgqtests)
282if (numsignificant10/numgqtests < 0.1) dum <- "OK" else dum <- "NOK"
283a<-table.element(a,dum)
284a<-table.row.end(a)
285a<-table.end(a)
286table.save(a,file="mytable6.tab")
287}
Top | Output | Charts | References | History | Feedback



Cite this software as:
Wessa P., (2008), Multiple Regression (v1.0.26) in Free Statistics Software (v1.1.23-r5), Office for Research Development and Education, URL http://www.wessa.net/rwasp_multipleregression.wasp/
The R code is based on :
Chambers, J. M. (1992), Linear models. (Chapter 4 of Statistical Models in S), eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
Borghers, E, and P. Wessa, Statistics - Econometrics - Forecasting, Office for Research Development and Education, http://www.xycoon.com/
Top | Output | Charts | References | History | Feedback
List of last 5 computationsDelete history
Server DateModuleCommand
Thu, 11 Mar 2010 10:08:26 -0700Multiple RegressionPrint | Word | Excel | Blog this | Delete
Thu, 11 Mar 2010 10:08:14 -0700Auto Correlation FunctionPrint | Word | Excel | Blog this | Delete
Thu, 11 Mar 2010 10:08:10 -0700Spearman Rank CorrelationPrint | Word | Excel | Blog this | Delete
Thu, 11 Mar 2010 10:08:02 -0700Simple RegressionPrint | Word | Excel | Blog this | Delete
Thu, 11 Mar 2010 10:07:28 -0700Start of session-
Top | Output | Charts | References | History | Feedback

Please, send us your feedback!
Overall rating
What do you think about the response time?
Rate the facility with which you interact with our software.
Is the output presented in an understandable (clear) form?
How did you find this website/module?
Do you have any comments or suggestions for our site?
Please enter the code that is displayed in this picture: captcha

To cite Wessa.net in publications use:
Wessa, P. (2010), Free Statistics Software, Office for Research Development and Education,
version 1.1.23-r5, URL http://www.wessa.net/

© Resa R&D, and the 'Office for Research, Development, and Education' - All rights reserved. Academic license for non-commercial use only.
This website is an intellectual and physical property of Resa R&D. This includes: html content, graphical illustrations (gif files), computer software, online or electronic documentation, associated media, and printed materials. The free use of the scientific content, services, and applications in this website is granted for non commercial use only. In any case, the source (url) should always be clearly displayed. Under no circumstances are you allowed to reproduce, copy or redistribute the design, layout, or any content of this website (for commercial use) including any materials contained herein without the express written permission of Resa R&D or the Office for Research, Development, and Education.

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, Resa R&D makes no warranties or representations as to the accuracy or completeness of such information (or software), and it assumes 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 Resa R&D 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.

Software Version : 1.1.23-r5
Algorithms & Software : Prof. dr. P. Wessa
Facilities : Resa R&D - Office for Research, Development, and Education
Server : www.wessa.net

Comments, Feedback & Errors | Privacy Policy | Statistics Resources | Wessa.net Home

 © Wessa.Net 2002-2010  
 
 

Home Page
Equation Plotter
Time Series Analysis (new)
Time Series Analysis (old)
Multiple Regression (new)
Multiple Regression (old)
Descriptive Statistics
Statistical Distributions
Hypothesis Testing
Statistics Education

Academic citations
Computations Archive
Search Computations
R Project
FAQ
About Wessa.net
Powered by Linux

Server status page
History list
Edit R Code
Google
Web wessa.net




Resa R&D provides this service to the internet community free of charge. Support this project with your contribution.