R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(1687,1508,1507,1385,1632,1511,1559,1630,1579,1653,2152,2148,1752,1765,1717,1558,1575,1520,1805,1800,1719,2008,2242,2478,2030,1655,1693,1623,1805,1746,1795,1926,1619,1992,2233,2192,2080,1768,1835,1569,1976,1853,1965,1689,1778,1976,2397,2654,2097,1963,1677,1941,2003,1813,2012,1912,2084,2080,2118,2150,1608,1503,1548,1382,1731,1798,1779,1887,2004,2077,2092,2051,1577,1356,1652,1382,1519,1421,1442,1543,1656,1561,1905,2199,1473,1655,1407,1395,1530,1309,1526,1327,1627,1748,1958,2274,1648,1401,1411,1403,1394,1520,1528,1643,1515,1685,2000,2215,1956,1462,1563,1459,1446,1622,1657,1638,1643,1683,2050,2262,1813,1445,1762,1461,1556,1431,1427,1554,1645,1653,2016,2207,1665,1361,1506,1360,1453,1522,1460,1552,1548,1827,1737,1941,1474,1458,1542,1404,1522,1385,1641,1510,1681,1938,1868,1726,1456,1445,1456,1365,1487,1558,1488,1684,1594,1850,1998,2079,1494,1057,1218,1168,1236,1076,1174,1139,1427,1487,1483,1513,1357,1165,1282,1110,1297,1185,1222,1284,1444,1575,1737,1763) > x <- c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) > 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 -408.75 -198.00 -63.75 188.26 936.25 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1717.75 20.00 85.886 < 2e-16 *** x -396.06 57.79 -6.854 9.76e-11 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 260 on 190 degrees of freedom Multiple R-squared: 0.1982, Adjusted R-squared: 0.194 F-statistic: 46.97 on 1 and 190 DF, p-value: 9.763e-11 > postscript(file="/var/www/html/rcomp/tmp/1z2nr1290717542.ps",horizontal=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/html/rcomp/tmp/2rtmu1290717542.ps",horizontal=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 -6.529e-11 3.931e-13 3.931e-13 3.931e-13 3.931e-13 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.718e+03 3.654e-13 4.701e+15 <2e-16 *** x -3.961e+02 1.056e-12 -3.751e+14 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.751e-12 on 190 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.407e+29 on 1 and 190 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/html/rcomp/tmp/3233f1290717542.ps",horizontal=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 -408.75 -198.00 -63.75 188.26 936.25 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -6.128e-15 2.000e+01 -3.06e-16 1 x 1.263e-14 5.779e+01 2.19e-16 1 Residual standard error: 260 on 190 degrees of freedom Multiple R-squared: 4.24e-34, Adjusted R-squared: -0.005263 F-statistic: 8.056e-32 on 1 and 190 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/html/rcomp/tmp/4233f1290717542.ps",horizontal=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 -348.61 47.44 47.44 47.44 47.44 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.670e+03 9.330e+00 179.0 <2e-16 *** m$residuals 1.348e-16 3.607e-02 3.74e-15 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 129.3 on 190 degrees of freedom Multiple R-squared: 5.903e-28, Adjusted R-squared: -0.005263 F-statistic: 1.122e-25 on 1 and 190 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/html/rcomp/tmp/5vuk01290717542.ps",horizontal=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 -557.916 -125.632 2.128 139.569 510.430 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.65656 14.45663 0.115 0.909 Residuals 0.64729 0.05618 11.523 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 199.8 on 189 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.4126, Adjusted R-squared: 0.4095 F-statistic: 132.8 on 1 and 189 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/663131290717542.ps",horizontal=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/html/rcomp/tmp/763131290717542.ps",horizontal=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/html/rcomp/tmp/8guj51290717542.ps",horizontal=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/html/rcomp/tmp/9guj51290717542.ps",horizontal=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/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/html/rcomp/tmp/105ejr1290717543.tab") > > try(system("convert tmp/1z2nr1290717542.ps tmp/1z2nr1290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/2rtmu1290717542.ps tmp/2rtmu1290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/3233f1290717542.ps tmp/3233f1290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/4233f1290717542.ps tmp/4233f1290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/5vuk01290717542.ps tmp/5vuk01290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/663131290717542.ps tmp/663131290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/763131290717542.ps tmp/763131290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/8guj51290717542.ps tmp/8guj51290717542.png",intern=TRUE)) character(0) > try(system("convert tmp/9guj51290717542.ps tmp/9guj51290717542.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.923 1.471 5.680