R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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. > y <- c(63.152,60.106,72.616,73.159,68.848,77.056,62.246,60.777,64.513,58.353,56.511,44.554,71.414,65.719,80.997,69.826,65.386,75.589,65.520,59.003,63.961,59.716,57.520,42.886,69.805,64.656,80.353,71.321,76.577,81.580,71.127,63.478,48.152,69.236,57.038,43.621,69.551,72.009,72.140,81.519,73.310,80.406,70.697,59.328,68.281,70.041,51.244,46.538,61.443,62.256,73.117,74.155,65.191,77.889,68.688,59.983,65.470,65.089,54.795,47.123) > x <- c(62.027,56.493,65.566,62.653,53.470,59.600,42.542,42.018,44.038,44.988,43.309,26.843,69.770,64.886,79.354,63.025,54.003,55.926,45.629,40.361,43.039,44.570,43.269,25.563,68.707,60.223,74.283,61.232,61.531,65.305,51.699,44.599,35.221,55.066,45.335,28.702,69.517,69.240,71.525,77.740,62.107,65.450,51.493,43.067,49.172,54.483,38.158,27.898,58.648,56.000,62.381,59.849,48.345,55.376,45.400,38.389,44.098,48.290,41.267,31.238) > par1 = '0' > #'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!) > par1 <- as.numeric(par1) > library(lattice) > z <- as.data.frame(cbind(x,y)) > m <- lm(y~x) > summary(m) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -8.4217 -4.3041 0.1506 3.7917 10.6246 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 31.38505 2.68554 11.69 <2e-16 *** x 0.64792 0.04962 13.06 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.952 on 58 degrees of freedom Multiple R-squared: 0.7462, Adjusted R-squared: 0.7418 F-statistic: 170.5 on 1 and 58 DF, p-value: < 2.2e-16 > postscript(file="/var/www/rcomp/tmp/1u9l81292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(z,main='Scatterplot, lowess, and regression line') > lines(lowess(z),col='red') > abline(m) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/2u9l81292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > m2 <- lm(m$fitted.values ~ x) > summary(m2) Call: lm(formula = m$fitted.values ~ x) Residuals: Min 1Q Median 3Q Max -7.932e-15 -4.110e-15 -1.351e-15 9.380e-16 7.167e-14 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.139e+01 5.474e-15 5.733e+15 <2e-16 *** x 6.479e-01 1.011e-16 6.406e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.009e-14 on 58 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 4.104e+31 on 1 and 58 DF, p-value: < 2.2e-16 > 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() null device 1 > postscript(file="/var/www/rcomp/tmp/35ikt1292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > m3 <- lm(m$residuals ~ x) > summary(m3) Call: lm(formula = m$residuals ~ x) Residuals: Min 1Q Median 3Q Max -8.4217 -4.3041 0.1506 3.7917 10.6246 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.235e-16 2.686e+00 0 1 x 8.152e-18 4.962e-02 0 1 Residual standard error: 4.952 on 58 degrees of freedom Multiple R-squared: 3.519e-33, Adjusted R-squared: -0.01724 F-statistic: 2.041e-31 on 1 and 58 DF, p-value: 1 > 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() null device 1 > postscript(file="/var/www/rcomp/tmp/4g91w1292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > m4 <- lm(m$fitted.values ~ m$residuals) > summary(m4) Call: lm(formula = m$fitted.values ~ m$residuals) Residuals: Min 1Q Median 3Q Max -17.4960 -6.0045 0.7582 6.2260 17.3564 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.544e+01 1.096e+00 59.71 <2e-16 *** m$residuals -4.604e-16 2.251e-01 0.00 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 8.49 on 58 degrees of freedom Multiple R-squared: 1.932e-31, Adjusted R-squared: -0.01724 F-statistic: 1.121e-29 on 1 and 58 DF, p-value: 1 > 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() null device 1 > postscript(file="/var/www/rcomp/tmp/58jiz1292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > 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) Call: lm(formula = z5) Residuals: Min 1Q Median 3Q Max -8.0967 -2.7745 -0.3445 3.0838 9.0164 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.09626 0.49688 0.194 0.847 Residuals 0.60912 0.10193 5.976 1.58e-07 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.816 on 57 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.3852, Adjusted R-squared: 0.3744 F-statistic: 35.71 on 1 and 57 DF, p-value: 1.576e-07 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/68jiz1292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(m$residuals,main='Residual Histogram',xlab='Residuals') > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/71ah21292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > 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() null device 1 > postscript(file="/var/www/rcomp/tmp/81ah21292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(m$residuals,main='Residual Autocorrelation Function') > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/91ah21292675946.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > dev.off() null device 1 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/rcomp/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="/var/www/rcomp/tmp/10qbew1292675946.tab") > > try(system("convert tmp/1u9l81292675946.ps tmp/1u9l81292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/2u9l81292675946.ps tmp/2u9l81292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/35ikt1292675946.ps tmp/35ikt1292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/4g91w1292675946.ps tmp/4g91w1292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/58jiz1292675946.ps tmp/58jiz1292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/68jiz1292675946.ps tmp/68jiz1292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/71ah21292675946.ps tmp/71ah21292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/81ah21292675946.ps tmp/81ah21292675946.png",intern=TRUE)) character(0) > try(system("convert tmp/91ah21292675946.ps tmp/91ah21292675946.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.310 1.540 3.819