R version 2.5.1 (2007-06-27) 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(4.8,-4.2,1.6,5.2,9.2,4.6,10.6) > x <- c(0.9,0.85,0.83,0.84,0.85,0.83,0.83) > #'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.08664121 -0.08661167 -0.08658212 -0.08655258 -0.08652304 -0.08649350 [7] -0.08646395 -0.08643442 -0.08640488 -0.08637534 -0.08634580 -0.08631627 [13] -0.08628674 -0.08625720 -0.08622767 -0.08619814 -0.08616861 -0.08613908 [19] -0.08610956 -0.08608003 -0.08605050 -0.08602098 -0.08599146 -0.08596194 [25] -0.08593242 -0.08590290 -0.08587338 -0.08584386 -0.08581435 -0.08578483 [31] -0.08575532 -0.08572581 -0.08569630 -0.08566679 -0.08563728 -0.08560777 [37] -0.08557827 -0.08554876 -0.08551926 -0.08548975 -0.08546025 -0.08543075 [43] -0.08540125 -0.08537176 -0.08534226 -0.08531277 -0.08528327 -0.08525378 [49] -0.08522429 -0.08519480 -0.08516531 -0.08513582 -0.08510633 -0.08507685 [55] -0.08504737 -0.08501788 -0.08498840 -0.08495892 -0.08492944 -0.08489997 [61] -0.08487049 -0.08484101 -0.08481154 -0.08478207 -0.08475260 -0.08472313 [67] -0.08469366 -0.08466419 -0.08463473 -0.08460526 -0.08457580 -0.08454634 [73] -0.08451688 -0.08448742 -0.08445796 -0.08442850 -0.08439905 -0.08436959 [79] -0.08434014 -0.08431069 -0.08428124 -0.08425179 -0.08422235 -0.08419290 [85] -0.08416346 -0.08413401 -0.08410457 -0.08407513 -0.08404569 -0.08401626 [91] -0.08398682 -0.08395739 -0.08392795 -0.08389852 -0.08386909 -0.08383966 [97] -0.08381024 -0.08378081 -0.08375138 -0.08372196 -0.08369254 -0.08366312 [103] -0.08363370 -0.08360428 -0.08357487 -0.08354545 -0.08351604 -0.08348663 [109] -0.08345722 -0.08342781 -0.08339840 -0.08336900 -0.08333959 -0.08331019 [115] -0.08328079 -0.08325139 -0.08322199 -0.08319259 -0.08316320 -0.08313381 [121] -0.08310441 -0.08307502 -0.08304563 -0.08301625 -0.08298686 -0.08295747 [127] -0.08292809 -0.08289871 -0.08286933 -0.08283995 -0.08281057 -0.08278120 [133] -0.08275183 -0.08272245 -0.08269308 -0.08266371 -0.08263435 -0.08260498 [139] -0.08257562 -0.08254625 -0.08251689 -0.08248753 -0.08245817 -0.08242882 [145] -0.08239946 -0.08237011 -0.08234076 -0.08231141 -0.08228206 -0.08225271 [151] -0.08222337 -0.08219402 -0.08216468 -0.08213534 -0.08210600 -0.08207666 [157] -0.08204733 -0.08201799 -0.08198866 -0.08195933 -0.08193000 -0.08190068 [163] -0.08187135 -0.08184203 -0.08181270 -0.08178338 -0.08175406 -0.08172475 [169] -0.08169543 -0.08166612 -0.08163680 -0.08160749 -0.08157819 -0.08154888 [175] -0.08151957 -0.08149027 -0.08146097 -0.08143167 -0.08140237 -0.08137307 [181] -0.08134378 -0.08131448 -0.08128519 -0.08125590 -0.08122661 -0.08119733 [187] -0.08116804 -0.08113876 -0.08110948 -0.08108020 -0.08105092 -0.08102164 [193] -0.08099237 -0.08096310 -0.08093383 -0.08090456 -0.08087529 -0.08084603 [199] -0.08081676 -0.08078750 -0.08075824 -0.08072898 -0.08069973 -0.08067047 [205] -0.08064122 -0.08061197 -0.08058272 -0.08055347 -0.08052423 -0.08049498 [211] -0.08046574 -0.08043650 -0.08040726 -0.08037803 -0.08034879 -0.08031956 [217] -0.08029033 -0.08026110 -0.08023187 -0.08020265 -0.08017342 -0.08014420 [223] -0.08011498 -0.08008577 -0.08005655 -0.08002734 -0.07999812 -0.07996891 [229] -0.07993971 -0.07991050 -0.07988130 -0.07985209 -0.07982289 -0.07979369 [235] -0.07976450 -0.07973530 -0.07970611 -0.07967692 -0.07964773 -0.07961854 [241] -0.07958936 -0.07956017 -0.07953099 -0.07950181 -0.07947263 -0.07944346 [247] -0.07941429 -0.07938511 -0.07935594 -0.07932678 -0.07929761 -0.07926845 [253] -0.07923929 -0.07921013 -0.07918097 -0.07915181 -0.07912266 -0.07909351 [259] -0.07906436 -0.07903521 -0.07900606 -0.07897692 -0.07894778 -0.07891864 [265] -0.07888950 -0.07886037 -0.07883123 -0.07880210 -0.07877297 -0.07874384 [271] -0.07871472 -0.07868560 -0.07865647 -0.07862735 -0.07859824 -0.07856912 [277] -0.07854001 -0.07851090 -0.07848179 -0.07845268 -0.07842358 -0.07839447 [283] -0.07836537 -0.07833628 -0.07830718 -0.07827808 -0.07824899 -0.07821990 [289] -0.07819081 -0.07816173 -0.07813264 -0.07810356 -0.07807448 -0.07804540 [295] -0.07801633 -0.07798726 -0.07795819 -0.07792912 -0.07790005 -0.07787098 [301] -0.07784192 -0.07781286 -0.07778380 -0.07775475 -0.07772569 -0.07769664 [307] -0.07766759 -0.07763854 -0.07760950 -0.07758046 -0.07755142 -0.07752238 [313] -0.07749334 -0.07746431 -0.07743527 -0.07740624 -0.07737722 -0.07734819 [319] -0.07731917 -0.07729015 -0.07726113 -0.07723211 -0.07720310 -0.07717408 [325] -0.07714507 -0.07711607 -0.07708706 -0.07705806 -0.07702906 -0.07700006 [331] -0.07697106 -0.07694207 -0.07691307 -0.07688408 -0.07685510 -0.07682611 [337] -0.07679713 -0.07676815 -0.07673917 -0.07671019 -0.07668122 -0.07665225 [343] -0.07662328 -0.07659431 -0.07656535 -0.07653638 -0.07650742 -0.07647847 [349] -0.07644951 -0.07642056 -0.07639161 -0.07636266 -0.07633371 -0.07630477 [355] -0.07627583 -0.07624689 -0.07621795 -0.07618902 -0.07616008 -0.07613115 [361] -0.07610223 -0.07607330 -0.07604438 -0.07601546 -0.07598654 -0.07595762 [367] -0.07592871 -0.07589980 -0.07587089 -0.07584199 -0.07581308 -0.07578418 [373] -0.07575528 -0.07572639 -0.07569749 -0.07566860 -0.07563971 -0.07561082 [379] -0.07558194 -0.07555306 -0.07552418 -0.07549530 -0.07546642 -0.07543755 [385] -0.07540868 -0.07537981 -0.07535095 -0.07532209 -0.07529323 -0.07526437 [391] -0.07523551 -0.07520666 -0.07517781 -0.07514896 -0.07512012 -0.07509127 [397] -0.07506243 -0.07503359 -0.07500476 -0.07497593 -0.07494710 > mx [1] 0.08664121 > 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/1hiu81193407478.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/2vj8y1193407478.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/3hgoh1193407478.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/4tv4b1193407478.tab") > > system("convert tmp/1hiu81193407478.ps tmp/1hiu81193407478.png") > system("convert tmp/2vj8y1193407478.ps tmp/2vj8y1193407478.png") > system("convert tmp/3hgoh1193407478.ps tmp/3hgoh1193407478.png") > > > proc.time() user system elapsed 1.046 0.497 1.181