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(104.75,105.01,105.15,105.2,105.77,105.78,106.26,106.13,106.12,106.57,106.44,106.54,107.1,108.1,108.4,108.84,109.62,110.42,110.67,111.66,112.28,112.87,112.18,112.36,112.16,111.49,111.25,111.36,111.74,111.1,111.33,111.25,111.04,110.97,111.31,111.02,111.07,111.36,111.54,112.05,112.52,112.94,113.33,113.78,113.77,113.82,113.89,114.25,114.41,114.55,115,115.66,116.33,116.91,117.2,117.59,117.95,118.09,117.99,118.31,118.49) > x <- c(1.0563,1.0479,1.0386,0.9978,1.0158,1.0389,1.065,1.0679,1.0859,1.0975,1.087,1.1146,1.143,1.2291,1.1829,1.1673,1.186,1.2534,1.2822,1.385,1.4259,1.4199,1.319,1.2823,1.2147,1.1101,0.9891,0.9741,0.9793,0.97,0.9942,0.995,1.0407,1.0296,1.0679,1.0431,1.0461,1.0668,1.0612,1.0958,1.1003,1.1492,1.1995,1.2173,1.2356,1.2084,1.2152,1.2257,1.2294,1.2467,1.2981,1.3397,1.3715,1.4365,1.4564,1.4328,1.4376,1.4515,1.4307,1.4574,1.4789) > 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 -4.463 -2.963 1.443 2.040 3.910 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 90.240 2.652 34.022 < 2e-16 *** x 17.962 2.220 8.092 3.83e-11 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.658 on 59 degrees of freedom Multiple R-squared: 0.526, Adjusted R-squared: 0.518 F-statistic: 65.48 on 1 and 59 DF, p-value: 3.829e-11 > postscript(file="/var/www/rcomp/tmp/1ocxc1321195754.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/2fhsv1321195754.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 -2.377e-14 -2.997e-15 1.468e-16 3.536e-15 6.760e-15 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.024e+01 5.061e-15 1.783e+16 <2e-16 *** x 1.796e+01 4.235e-15 4.241e+15 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.071e-15 on 59 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.799e+31 on 1 and 59 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/3k9xf1321195754.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 -4.463 -2.963 1.443 2.040 3.910 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.149e-16 2.652e+00 0 1 x -4.968e-16 2.220e+00 0 1 Residual standard error: 2.658 on 59 degrees of freedom Multiple R-squared: 4.907e-34, Adjusted R-squared: -0.01695 F-statistic: 2.895e-32 on 1 and 59 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/4sr1k1321195754.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 -3.862 -2.312 -0.318 1.748 5.279 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.115e+02 3.585e-01 311.1 <2e-16 *** m$residuals 2.732e-16 1.371e-01 0.0 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.8 on 59 degrees of freedom Multiple R-squared: 1.223e-29, Adjusted R-squared: -0.01695 F-statistic: 7.215e-28 on 1 and 59 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/526tw1321195754.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 -1.06651 -0.36284 -0.06788 0.25021 1.88685 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.10131 0.06885 1.472 0.147 Residuals 0.95822 0.02622 36.552 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5333 on 58 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9584, Adjusted R-squared: 0.9577 F-statistic: 1336 on 1 and 58 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/6orj41321195754.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/76of01321195754.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/88aiw1321195754.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/9mf911321195754.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/10x1wi1321195754.tab") > > try(system("convert tmp/1ocxc1321195754.ps tmp/1ocxc1321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/2fhsv1321195754.ps tmp/2fhsv1321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/3k9xf1321195754.ps tmp/3k9xf1321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/4sr1k1321195754.ps tmp/4sr1k1321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/526tw1321195754.ps tmp/526tw1321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/6orj41321195754.ps tmp/6orj41321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/76of01321195754.ps tmp/76of01321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/88aiw1321195754.ps tmp/88aiw1321195754.png",intern=TRUE)) character(0) > try(system("convert tmp/9mf911321195754.ps tmp/9mf911321195754.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.970 0.290 4.269