R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(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) > x <- 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) > 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 -0.21199 -0.07723 0.03361 0.07285 0.21879 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.080953 0.403852 -5.153 3.12e-06 *** x 0.029284 0.003619 8.092 3.83e-11 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.1073 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/wessaorg/rcomp/tmp/19seb1321206657.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/wessaorg/rcomp/tmp/28k9t1321206657.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 -1.445e-16 -5.710e-17 -5.270e-18 4.287e-17 3.205e-16 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.081e+00 2.937e-16 -7.085e+15 <2e-16 *** x 2.928e-02 2.632e-18 1.113e+16 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 7.804e-17 on 59 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 1.238e+32 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/wessaorg/rcomp/tmp/3wiyt1321206657.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 -0.21199 -0.07723 0.03361 0.07285 0.21879 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.221e-18 4.039e-01 0 1 x -5.371e-21 3.619e-03 0 1 Residual standard error: 0.1073 on 59 degrees of freedom Multiple R-squared: 4.517e-35, Adjusted R-squared: -0.01695 F-statistic: 2.665e-33 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/wessaorg/rcomp/tmp/4n87k1321206657.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 -0.198409 -0.078636 -0.001032 0.067201 0.203959 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.185e+00 1.447e-02 81.88 <2e-16 *** m$residuals 1.895e-16 1.371e-01 0.00 1 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.113 on 59 degrees of freedom Multiple R-squared: 0, Adjusted R-squared: -0.01695 F-statistic: 0 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/wessaorg/rcomp/tmp/5dmjk1321206657.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 -0.117837 -0.014883 0.001697 0.019865 0.079503 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.0002641 0.0043920 0.06 0.952 Residuals 0.9512565 0.0415235 22.91 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.03402 on 58 degrees of freedom (2 observations deleted due to missingness) Multiple R-squared: 0.9005, Adjusted R-squared: 0.8988 F-statistic: 524.8 on 1 and 58 DF, p-value: < 2.2e-16 > abline(m5) > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/6dxxf1321206657.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/wessaorg/rcomp/tmp/7lks01321206657.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/wessaorg/rcomp/tmp/8x9071321206657.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/wessaorg/rcomp/tmp/92fia1321206657.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/10zs4v1321206657.tab") > > try(system("convert tmp/19seb1321206657.ps tmp/19seb1321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/28k9t1321206657.ps tmp/28k9t1321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/3wiyt1321206657.ps tmp/3wiyt1321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/4n87k1321206657.ps tmp/4n87k1321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/5dmjk1321206657.ps tmp/5dmjk1321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/6dxxf1321206657.ps tmp/6dxxf1321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/7lks01321206657.ps tmp/7lks01321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/8x9071321206657.ps tmp/8x9071321206657.png",intern=TRUE)) character(0) > try(system("convert tmp/92fia1321206657.ps tmp/92fia1321206657.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.692 0.478 3.212