# ::Free Statistics and Forecasting Software::

v1.1.23-r7
Secure website (SSL) | Donate to wessa.net

### :: Linear Regression Graphical Model Validation - 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 Simple Linear Regression model (Y = a + b X) and various diagnostic tools from the perspective of Explorative Data Analysis. Note that the lagplot of X and the Autocorrelation Function only make sense when working with time series. All other diagnostics (scatterplots, histogram, kernel density, and QQ normality plot) can be used for data series with or without time dimension.

Enter (or paste) your data delimited by hard returns.

 Send output to: Browser Blue - Charts White Browser Black/White CSV MS Excel MS Word Data X (click to load default data) 80 60 10 20 30 10 10 50 80 90 30 Data Y: 50 20 10 50 30 50 70 20 30 10 50 Sample Range:(leave blank to include all observations) From: To: bandwidth of density plot (?) Chart options Width: Height:

 Source code of R module par1 <- as.numeric(par1) library(lattice) z <- as.data.frame(cbind(x,y)) m <- lm(y~x) summary(m) bitmap(file="test1.png") plot(z,main="Scatterplot, lowess, and regression line") lines(lowess(z),col="red") abline(m) grid() dev.off() bitmap(file="test2.png") m2 <- lm(m\$fitted.values ~ x) summary(m2) z2 <- as.data.frame(cbind(x,m\$fitted.values)) names(z2) <- list("x","Fitted") plot(z2,main="Scatterplot, lowess, and regression line") lines(lowess(z2),col="red") abline(m2) grid() dev.off() bitmap(file="test3.png") m3 <- lm(m\$residuals ~ x) summary(m3) z3 <- as.data.frame(cbind(x,m\$residuals)) names(z3) <- list("x","Residuals") plot(z3,main="Scatterplot, lowess, and regression line") lines(lowess(z3),col="red") abline(m3) grid() dev.off() bitmap(file="test4.png") m4 <- lm(m\$fitted.values ~ m\$residuals) summary(m4) z4 <- as.data.frame(cbind(m\$residuals,m\$fitted.values)) names(z4) <- list("Residuals","Fitted") plot(z4,main="Scatterplot, lowess, and regression line") lines(lowess(z4),col="red") abline(m4) grid() dev.off() bitmap(file="test5.png") myr <- as.ts(m\$residuals) z5 <- as.data.frame(cbind(lag(myr,1),myr)) names(z5) <- list("Lagged Residuals","Residuals") plot(z5,main="Lag plot") m5 <- lm(z5) summary(m5) abline(m5) grid() dev.off() bitmap(file="test6.png") hist(m\$residuals,main="Residual Histogram",xlab="Residuals") dev.off() bitmap(file="test7.png") if (par1 > 0) { densityplot(~m\$residuals,col="black",main=paste("Density Plot bw = ",par1),bw=par1) } else { densityplot(~m\$residuals,col="black",main="Density Plot") } dev.off() bitmap(file="test8.png") acf(m\$residuals,main="Residual Autocorrelation Function") dev.off() bitmap(file="test9.png") qqnorm(x) qqline(x) grid() dev.off() load(file="createtable") a<-table.start() a<-table.row.start(a) a<-table.element(a,"Simple Linear Regression",5,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,"Statistics",1,TRUE) a<-table.element(a,"Estimate",1,TRUE) a<-table.element(a,"S.D.",1,TRUE) a<-table.element(a,"T-STAT (H0: coeff=0)",1,TRUE) a<-table.element(a,"P-value (two-sided)",1,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,"constant term",header=TRUE) a<-table.element(a,m\$coefficients[[1]]) sd <- sqrt(vcov(m)[1,1]) a<-table.element(a,sd) tstat <- m\$coefficients[[1]]/sd a<-table.element(a,tstat) pval <- 2*(1-pt(abs(tstat),length(x)-2)) a<-table.element(a,pval) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,"slope",header=TRUE) a<-table.element(a,m\$coefficients[[2]]) sd <- sqrt(vcov(m)[2,2]) a<-table.element(a,sd) tstat <- m\$coefficients[[2]]/sd a<-table.element(a,tstat) pval <- 2*(1-pt(abs(tstat),length(x)-2)) a<-table.element(a,pval) a<-table.row.end(a) a<-table.end(a) table.save(a,file="mytable.tab")
 Top | Output | Charts | References | History | Feedback

 Cite this software as: Wessa P., (2012), Linear Regression Graphical Model Validation (v1.0.7) in Free Statistics Software (v1.1.23-r7), Office for Research Development and Education, URL http://www.wessa.net/rwasp_linear_regression.wasp/ The R code is based on : NIST/SEMATECH e-Handbook of Statistical Methods, http://www.itl.nist.gov/div898/handbook/, 2006-10-03. Deepayan Sarkar (2006). lattice: Lattice Graphics. R package version 0.13-8. Diethelm Wuertz, many others and see the SOURCE file (2006). fExtremes: Rmetrics - Extreme Financial Market Data. R package version 221.10065. http://www.rmetrics.org
 Top | Output | Charts | References | History | Feedback
 Top | Output | Charts | References | History | Feedback