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(125,121.7,134.3,124.3,119.1,137.8,120.5,122.7,127.2,133.2,136.3,134.9,120.9,109.4,129.6,124.7,114.6,137.4,117.9,117.4,122,124.8,123.3,132.8,115.1,104.2,125.5,116.8,116.8,125.5,110.9,114.9,136.4,125.8,126.5,134,116.1,115,130.3,106.5,111.6,125,108.3,105,127.4,116.6,128.6,127.5,108.4,110.8,114.2,101.8,109.8,115.9,106.9,114.6,105.4,108.1,118.4,112.7,98.4,99.6,103.9,101.5,100.8,104.5,98.2,99.9,97.5,105.7,117.7,107.4,98.4,92,107.7,100.2,96.7,106.8,98,98.6) > x <- c(59.7,58.2,75.3,69,66.1,77.5,69.3,70.2,70.2,78.2,85.4,82.4,61.2,52.2,85.3,79.9,72.2,85.7,75.5,69.2,77.6,85.3,77,89.9,60,54.3,84,69.9,75.1,81.7,69.9,68.3,77.3,77.4,85.3,91,60.6,57.6,93.8,78.7,80.3,89.8,77.5,71.7,83.2,86.2,100.7,100.8,57.1,62.5,79.7,80.3,92.4,91.8,85.8,84.2,93.1,101.2,100.6,106.7,64,67.5,101,95.5,97,103.8,95.2,86.7,93.5,102.5,112.3,105.5,75.4,70.4,108,100,93.3,111.1,101.1,98.1) > #'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.03879285 -0.03909802 -0.03940341 -0.03970902 -0.04001486 -0.04032093 [7] -0.04062721 -0.04093371 -0.04124042 -0.04154736 -0.04185450 -0.04216186 [13] -0.04246942 -0.04277720 -0.04308518 -0.04339337 -0.04370176 -0.04401035 [19] -0.04431914 -0.04462814 -0.04493732 -0.04524671 -0.04555628 -0.04586605 [25] -0.04617601 -0.04648616 -0.04679649 -0.04710701 -0.04741771 -0.04772860 [31] -0.04803966 -0.04835090 -0.04866232 -0.04897391 -0.04928568 -0.04959762 [37] -0.04990972 -0.05022200 -0.05053443 -0.05084704 -0.05115981 -0.05147273 [43] -0.05178582 -0.05209906 -0.05241246 -0.05272601 -0.05303971 -0.05335357 [49] -0.05366757 -0.05398172 -0.05429601 -0.05461044 -0.05492502 -0.05523973 [55] -0.05555459 -0.05586958 -0.05618470 -0.05649995 -0.05681533 -0.05713085 [61] -0.05744648 -0.05776225 -0.05807813 -0.05839414 -0.05871027 -0.05902651 [67] -0.05934287 -0.05965934 -0.05997592 -0.06029261 -0.06060941 -0.06092632 [73] -0.06124333 -0.06156044 -0.06187766 -0.06219497 -0.06251238 -0.06282988 [79] -0.06314748 -0.06346517 -0.06378294 -0.06410081 -0.06441876 -0.06473679 [85] -0.06505490 -0.06537310 -0.06569137 -0.06600972 -0.06632814 -0.06664663 [91] -0.06696519 -0.06728383 -0.06760252 -0.06792129 -0.06824011 -0.06855900 [97] -0.06887794 -0.06919694 -0.06951600 -0.06983510 -0.07015426 -0.07047347 [103] -0.07079273 -0.07111203 -0.07143137 -0.07175076 -0.07207018 -0.07238964 [109] -0.07270914 -0.07302867 -0.07334823 -0.07366782 -0.07398744 -0.07430709 [115] -0.07462676 -0.07494645 -0.07526616 -0.07558589 -0.07590563 -0.07622539 [121] -0.07654516 -0.07686494 -0.07718473 -0.07750453 -0.07782433 -0.07814413 [127] -0.07846393 -0.07878373 -0.07910353 -0.07942332 -0.07974310 -0.08006288 [133] -0.08038264 -0.08070239 -0.08102213 -0.08134184 -0.08166154 -0.08198122 [139] -0.08230087 -0.08262050 -0.08294011 -0.08325968 -0.08357922 -0.08389873 [145] -0.08421821 -0.08453764 -0.08485704 -0.08517640 -0.08549572 -0.08581499 [151] -0.08613421 -0.08645339 -0.08677252 -0.08709159 -0.08741061 -0.08772957 [157] -0.08804847 -0.08836732 -0.08868610 -0.08900482 -0.08932347 -0.08964205 [163] -0.08996057 -0.09027901 -0.09059738 -0.09091567 -0.09123389 -0.09155202 [169] -0.09187007 -0.09218804 -0.09250593 -0.09282373 -0.09314143 -0.09345905 [175] -0.09377657 -0.09409400 -0.09441133 -0.09472857 -0.09504570 -0.09536273 [181] -0.09567965 -0.09599647 -0.09631318 -0.09662978 -0.09694626 -0.09726263 [187] -0.09757889 -0.09789503 -0.09821105 -0.09852694 -0.09884271 -0.09915836 [193] -0.09947388 -0.09978927 -0.10010453 -0.10041965 -0.10073464 -0.10104949 [199] -0.10136421 -0.10167878 -0.10199321 -0.10230750 -0.10262163 -0.10293563 [205] -0.10324947 -0.10356316 -0.10387669 -0.10419007 -0.10450329 -0.10481635 [211] -0.10512926 -0.10544199 -0.10575457 -0.10606697 -0.10637921 -0.10669128 [217] -0.10700317 -0.10731489 -0.10762644 -0.10793781 -0.10824899 -0.10856000 [223] -0.10887082 -0.10918146 -0.10949191 -0.10980218 -0.11011225 -0.11042213 [229] -0.11073181 -0.11104130 -0.11135060 -0.11165969 -0.11196858 -0.11227727 [235] -0.11258576 -0.11289403 -0.11320210 -0.11350996 -0.11381761 -0.11412505 [241] -0.11443227 -0.11473927 -0.11504605 -0.11535262 -0.11565896 -0.11596508 [247] -0.11627097 -0.11657663 -0.11688207 -0.11718727 -0.11749225 -0.11779698 [253] -0.11810149 -0.11840575 -0.11870978 -0.11901356 -0.11931710 -0.11962040 [259] -0.11992345 -0.12022626 -0.12052881 -0.12083112 -0.12113317 -0.12143497 [265] -0.12173651 -0.12203779 -0.12233881 -0.12263958 -0.12294008 -0.12324032 [271] -0.12354029 -0.12383999 -0.12413943 -0.12443859 -0.12473749 -0.12503611 [277] -0.12533445 -0.12563252 -0.12593030 -0.12622781 -0.12652504 -0.12682198 [283] -0.12711864 -0.12741502 -0.12771110 -0.12800690 -0.12830240 -0.12859761 [289] -0.12889253 -0.12918715 -0.12948148 -0.12977551 -0.13006923 -0.13036266 [295] -0.13065578 -0.13094860 -0.13124111 -0.13153332 -0.13182521 -0.13211680 [301] -0.13240807 -0.13269903 -0.13298968 -0.13328001 -0.13357002 -0.13385971 [307] -0.13414908 -0.13443813 -0.13472686 -0.13501526 -0.13530333 -0.13559108 [313] -0.13587850 -0.13616558 -0.13645234 -0.13673876 -0.13702485 -0.13731060 [319] -0.13759601 -0.13788109 -0.13816582 -0.13845022 -0.13873427 -0.13901798 [325] -0.13930134 -0.13958435 -0.13986702 -0.14014933 -0.14043130 -0.14071291 [331] -0.14099417 -0.14127508 -0.14155563 -0.14183582 -0.14211566 -0.14239513 [337] -0.14267425 -0.14295300 -0.14323138 -0.14350941 -0.14378706 -0.14406435 [343] -0.14434127 -0.14461782 -0.14489400 -0.14516981 -0.14544525 -0.14572031 [349] -0.14599499 -0.14626930 -0.14654323 -0.14681678 -0.14708995 -0.14736273 [355] -0.14763514 -0.14790716 -0.14817879 -0.14845004 -0.14872090 -0.14899138 [361] -0.14926146 -0.14953115 -0.14980046 -0.15006936 -0.15033788 -0.15060600 [367] -0.15087372 -0.15114104 -0.15140797 -0.15167450 -0.15194062 -0.15220635 [373] -0.15247167 -0.15273659 -0.15300110 -0.15326521 -0.15352891 -0.15379221 [379] -0.15405509 -0.15431757 -0.15457963 -0.15484128 -0.15510252 -0.15536335 [385] -0.15562376 -0.15588375 -0.15614333 -0.15640249 -0.15666124 -0.15691956 [391] -0.15717746 -0.15743494 -0.15769200 -0.15794863 -0.15820484 -0.15846063 [397] -0.15871599 -0.15897092 -0.15922542 -0.15947950 -0.15973315 > mx [1] 0.1597331 > mxli [1] 2 > 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/1wpp01196195294.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/2kef01196195294.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/3yfn81196195294.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/45y1n1196195294.tab") > > system("convert tmp/1wpp01196195294.ps tmp/1wpp01196195294.png") > system("convert tmp/2kef01196195294.ps tmp/2kef01196195294.png") > system("convert tmp/3yfn81196195294.ps tmp/3yfn81196195294.png") > > > proc.time() user system elapsed 1.040 0.499 1.165