R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(112.1,104.2,102.4,100.3,102.6,101.5,103.4,99.4,97.9,98,90.2,87.1,91.8,94.8,91.8,89.3,91.7,86.2,82.8,82.3,79.8,79.4,85.3,87.5,88.3,88.6,94.9,94.7,92.6,91.8,96.4,96.4,107.1,111.9,107.8,109.2,115.3,119.2,107.8,106.8,104.2,94.8,97.5,98.3,100.6,94.9,93.6,98,104.3,103.9,105.3,102.6,103.3,107.9,107.8,109.8,110.6,110.8,119.3,128.1,127.6,137.9,151.4,143.6,143.4,141.9,135.2,133.1,129.6,134.1,136.8,143.5,162.5,163.1,157.2,158.8,155.4,148.5,154.2,153.3,149.4,147.9,156,163,159.1,159.5,157.3,156.4,156.6,162.4,166.8,162.6,168.1) > x <- c(105.3,103,103.8,103.4,105.8,101.4,97,94.3,96.6,97.1,95.7,96.9,97.4,95.3,93.6,91.5,93.1,91.7,94.3,93.9,90.9,88.3,91.3,91.7,92.4,92,95.6,95.8,96.4,99,107,109.7,116.2,115.9,113.8,112.6,113.7,115.9,110.3,111.3,113.4,108.2,104.8,106,110.9,115,118.4,121.4,128.8,131.7,141.7,142.9,139.4,134.7,125,113.6,111.5,108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131,124.9,120.8,122,122.1,127.4,135.2,137.3,135,136,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156,159.5,168.7,169.9,169.9,185.9) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > n <- length(x) > c <- array(NA,dim=c(401)) > l <- array(NA,dim=c(401)) > mx <- 0 > mxli <- -999 > for (i in 1:401) + { + l[i] <- (i-201)/100 + if (l[i] != 0) + { + x1 <- (x^l[i] - 1) / l[i] + } else { + x1 <- log(x) + } + c[i] <- cor(x1,y) + if (mx < abs(c[i])) + { + mx <- abs(c[i]) + mxli <- l[i] + } + } > c [1] 0.8587690 0.8589052 0.8590409 0.8591760 0.8593105 0.8594446 0.8595781 [8] 0.8597110 0.8598434 0.8599752 0.8601065 0.8602372 0.8603673 0.8604969 [15] 0.8606260 0.8607544 0.8608823 0.8610097 0.8611364 0.8612626 0.8613882 [22] 0.8615133 0.8616377 0.8617616 0.8618849 0.8620076 0.8621297 0.8622513 [29] 0.8623722 0.8624925 0.8626123 0.8627314 0.8628500 0.8629679 0.8630853 [36] 0.8632020 0.8633181 0.8634336 0.8635486 0.8636628 0.8637765 0.8638896 [43] 0.8640020 0.8641138 0.8642250 0.8643356 0.8644455 0.8645548 0.8646635 [50] 0.8647715 0.8648789 0.8649856 0.8650917 0.8651972 0.8653020 0.8654062 [57] 0.8655097 0.8656126 0.8657148 0.8658164 0.8659173 0.8660175 0.8661171 [64] 0.8662161 0.8663143 0.8664119 0.8665088 0.8666051 0.8667006 0.8667955 [71] 0.8668897 0.8669833 0.8670761 0.8671683 0.8672598 0.8673506 0.8674407 [78] 0.8675301 0.8676188 0.8677068 0.8677942 0.8678808 0.8679667 0.8680519 [85] 0.8681364 0.8682202 0.8683033 0.8683857 0.8684674 0.8685483 0.8686286 [92] 0.8687081 0.8687869 0.8688649 0.8689423 0.8690189 0.8690947 0.8691699 [99] 0.8692443 0.8693180 0.8693909 0.8694631 0.8695346 0.8696053 0.8696753 [106] 0.8697445 0.8698130 0.8698807 0.8699476 0.8700139 0.8700793 0.8701440 [113] 0.8702079 0.8702711 0.8703335 0.8703952 0.8704560 0.8705161 0.8705754 [120] 0.8706340 0.8706918 0.8707488 0.8708050 0.8708604 0.8709151 0.8709690 [127] 0.8710220 0.8710743 0.8711258 0.8711765 0.8712265 0.8712756 0.8713239 [134] 0.8713714 0.8714181 0.8714640 0.8715091 0.8715534 0.8715969 0.8716396 [141] 0.8716815 0.8717225 0.8717628 0.8718022 0.8718408 0.8718786 0.8719155 [148] 0.8719517 0.8719870 0.8720214 0.8720551 0.8720879 0.8721199 0.8721510 [155] 0.8721813 0.8722108 0.8722394 0.8722672 0.8722942 0.8723203 0.8723455 [162] 0.8723699 0.8723935 0.8724162 0.8724380 0.8724590 0.8724792 0.8724984 [169] 0.8725169 0.8725344 0.8725511 0.8725669 0.8725819 0.8725960 0.8726092 [176] 0.8726216 0.8726331 0.8726437 0.8726534 0.8726623 0.8726702 0.8726773 [183] 0.8726836 0.8726889 0.8726934 0.8726969 0.8726996 0.8727014 0.8727023 [190] 0.8727023 0.8727014 0.8726996 0.8726969 0.8726934 0.8726889 0.8726835 [197] 0.8726773 0.8726701 0.8726620 0.8726530 0.8726431 0.8726323 0.8726206 [204] 0.8726080 0.8725945 0.8725800 0.8725646 0.8725484 0.8725312 0.8725131 [211] 0.8724940 0.8724741 0.8724532 0.8724314 0.8724087 0.8723850 0.8723604 [218] 0.8723349 0.8723085 0.8722811 0.8722528 0.8722236 0.8721934 0.8721623 [225] 0.8721303 0.8720973 0.8720634 0.8720285 0.8719927 0.8719560 0.8719183 [232] 0.8718797 0.8718401 0.8717996 0.8717581 0.8717157 0.8716723 0.8716280 [239] 0.8715828 0.8715366 0.8714894 0.8714413 0.8713922 0.8713421 0.8712912 [246] 0.8712392 0.8711863 0.8711324 0.8710776 0.8710218 0.8709651 0.8709074 [253] 0.8708487 0.8707890 0.8707284 0.8706668 0.8706043 0.8705408 0.8704763 [260] 0.8704109 0.8703445 0.8702771 0.8702087 0.8701394 0.8700691 0.8699978 [267] 0.8699255 0.8698523 0.8697781 0.8697029 0.8696268 0.8695496 0.8694715 [274] 0.8693924 0.8693123 0.8692313 0.8691493 0.8690663 0.8689823 0.8688973 [281] 0.8688113 0.8687244 0.8686365 0.8685475 0.8684576 0.8683668 0.8682749 [288] 0.8681820 0.8680882 0.8679934 0.8678976 0.8678008 0.8677030 0.8676042 [295] 0.8675044 0.8674037 0.8673020 0.8671992 0.8670955 0.8669908 0.8668851 [302] 0.8667784 0.8666707 0.8665620 0.8664524 0.8663417 0.8662301 0.8661174 [309] 0.8660038 0.8658892 0.8657735 0.8656569 0.8655393 0.8654207 0.8653011 [316] 0.8651806 0.8650590 0.8649364 0.8648129 0.8646883 0.8645628 0.8644362 [323] 0.8643087 0.8641802 0.8640506 0.8639201 0.8637886 0.8636561 0.8635226 [330] 0.8633881 0.8632527 0.8631162 0.8629787 0.8628403 0.8627008 0.8625604 [337] 0.8624190 0.8622765 0.8621331 0.8619887 0.8618433 0.8616969 0.8615495 [344] 0.8614012 0.8612518 0.8611015 0.8609501 0.8607978 0.8606445 0.8604902 [351] 0.8603349 0.8601786 0.8600214 0.8598631 0.8597039 0.8595436 0.8593824 [358] 0.8592202 0.8590571 0.8588929 0.8587278 0.8585616 0.8583945 0.8582264 [365] 0.8580573 0.8578873 0.8577162 0.8575442 0.8573712 0.8571973 0.8570223 [372] 0.8568464 0.8566695 0.8564916 0.8563127 0.8561329 0.8559521 0.8557703 [379] 0.8555875 0.8554038 0.8552191 0.8550335 0.8548468 0.8546592 0.8544706 [386] 0.8542811 0.8540906 0.8538991 0.8537067 0.8535133 0.8533189 0.8531236 [393] 0.8529273 0.8527301 0.8525319 0.8523327 0.8521326 0.8519315 0.8517294 [400] 0.8515265 0.8513225 > mx [1] 0.8727023 > mxli [1] -0.11 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > r<-lm(y~x) > se <- sqrt(var(r$residuals)) > r1 <- lm(y~x1) > se1 <- sqrt(var(r1$residuals)) > postscript(file="/var/www/html/rcomp/tmp/1z5z41197713097.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Linearity Plot',xlab='Lambda',ylab='correlation') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2vh4e1197713097.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,y,main='Linear Fit of Original Data',xlab='x',ylab='y') > abline(r) > grid() > mtext(paste('Residual Standard Deviation = ',se)) > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/38n761197713097.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x1,y,main='Linear Fit of Transformed Data',xlab='x',ylab='y') > abline(r1) > grid() > mtext(paste('Residual Standard Deviation = ',se1)) > dev.off() null device 1 > load(file='/var/www/html/rcomp/createtable') > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Box-Cox Linearity Plot',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'# observations x',header=TRUE) > a<-table.element(a,n) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'maximum correlation',header=TRUE) > a<-table.element(a,mx) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'optimal lambda(x)',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (orginial)',header=TRUE) > a<-table.element(a,se) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (transformed)',header=TRUE) > a<-table.element(a,se1) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/4wzxn1197713097.tab") > > system("convert tmp/1z5z41197713097.ps tmp/1z5z41197713097.png") > system("convert tmp/2vh4e1197713097.ps tmp/2vh4e1197713097.png") > system("convert tmp/38n761197713097.ps tmp/38n761197713097.png") > > > proc.time() user system elapsed 1.030 0.509 1.224