R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(88.3,88.6,91,91.5,95.4,98.7,99.9,98.6,100.3,100.2,100.4,101.4,103,109.1,111.4,114.1,121.8,127.6,129.9,128,123.5,124,127.4,127.6,128.4,131.4,135.1,134,144.5,147.3,150.9,148.7,141.4,138.9,139.8,145.6,147.9,148.5,151.1,157.5,167.5,172.3,173.5,187.5,205.5,195.1,204.5,204.5,201.7,207,206.6,210.6,211.1,215,223.9,238.2,238.9,229.6,232.2,222.1,221.6,227.3,221,213.6,243.4,253.8,265.3,268.2,268.5,266.9) > x <- c(109.1,113.8,97.4,72.5,82.7,88.9,105.9,100.8,94,105,58.5,87.6,113.1,112.5,89.6,74.5,82.7,90.1,109.4,96,89.2,109.1,49.1,92.9,107.7,103.5,91.1,79.8,71.9,82.9,90.1,100.7,90.7,108.8,44.1,93.6,107.4,96.5,93.6,76.5,76.7,84,103.3,88.5,99,105.9,44.7,94,107.1,104.8,102.5,77.7,85.2,91.3,106.5,92.4,97.5,107,51.1,98.6,102.2,114.3,99.4,72.5,92.3,99.4,85.9,109.4,97.6,104.7) > #'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!) > 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.02512581 0.02524154 0.02535728 0.02547301 0.02558873 0.02570444 [7] 0.02582015 0.02593584 0.02605152 0.02616718 0.02628283 0.02639845 [13] 0.02651405 0.02662963 0.02674517 0.02686069 0.02697618 0.02709163 [19] 0.02720704 0.02732242 0.02743775 0.02755304 0.02766829 0.02778349 [25] 0.02789863 0.02801373 0.02812877 0.02824375 0.02835868 0.02847354 [31] 0.02858833 0.02870306 0.02881773 0.02893232 0.02904683 0.02916128 [37] 0.02927564 0.02938992 0.02950412 0.02961823 0.02973226 0.02984620 [43] 0.02996004 0.03007379 0.03018744 0.03030099 0.03041444 0.03052778 [49] 0.03064102 0.03075414 0.03086716 0.03098006 0.03109285 0.03120551 [55] 0.03131805 0.03143047 0.03154277 0.03165493 0.03176696 0.03187886 [61] 0.03199063 0.03210225 0.03221373 0.03232507 0.03243626 0.03254731 [67] 0.03265820 0.03276894 0.03287952 0.03298995 0.03310021 0.03321031 [73] 0.03332025 0.03343002 0.03353961 0.03364903 0.03375828 0.03386735 [79] 0.03397624 0.03408494 0.03419346 0.03430180 0.03440994 0.03451789 [85] 0.03462564 0.03473319 0.03484055 0.03494770 0.03505465 0.03516139 [91] 0.03526792 0.03537424 0.03548034 0.03558622 0.03569189 0.03579733 [97] 0.03590255 0.03600754 0.03611230 0.03621683 0.03632113 0.03642518 [103] 0.03652900 0.03663258 0.03673591 0.03683900 0.03694184 0.03704443 [109] 0.03714676 0.03724884 0.03735066 0.03745222 0.03755352 0.03765455 [115] 0.03775531 0.03785580 0.03795603 0.03805597 0.03815564 0.03825503 [121] 0.03835414 0.03845296 0.03855150 0.03864975 0.03874771 0.03884538 [127] 0.03894275 0.03903982 0.03913660 0.03923307 0.03932924 0.03942510 [133] 0.03952065 0.03961589 0.03971082 0.03980543 0.03989973 0.03999370 [139] 0.04008736 0.04018069 0.04027369 0.04036637 0.04045871 0.04055073 [145] 0.04064240 0.04073375 0.04082475 0.04091541 0.04100573 0.04109570 [151] 0.04118533 0.04127461 0.04136354 0.04145211 0.04154033 0.04162819 [157] 0.04171570 0.04180284 0.04188962 0.04197603 0.04206208 0.04214776 [163] 0.04223307 0.04231800 0.04240256 0.04248675 0.04257056 0.04265398 [169] 0.04273703 0.04281969 0.04290197 0.04298386 0.04306536 0.04314647 [175] 0.04322719 0.04330751 0.04338744 0.04346697 0.04354610 0.04362483 [181] 0.04370315 0.04378108 0.04385859 0.04393570 0.04401240 0.04408869 [187] 0.04416457 0.04424003 0.04431508 0.04438971 0.04446392 0.04453771 [193] 0.04461108 0.04468403 0.04475655 0.04482865 0.04490032 0.04497156 [199] 0.04504237 0.04511275 0.04518270 0.04525221 0.04532129 0.04538993 [205] 0.04545813 0.04552589 0.04559321 0.04566009 0.04572652 0.04579252 [211] 0.04585806 0.04592316 0.04598781 0.04605201 0.04611576 0.04617906 [217] 0.04624190 0.04630430 0.04636623 0.04642771 0.04648874 0.04654930 [223] 0.04660941 0.04666906 0.04672824 0.04678697 0.04684523 0.04690302 [229] 0.04696035 0.04701722 0.04707362 0.04712955 0.04718501 0.04724001 [235] 0.04729453 0.04734858 0.04740216 0.04745527 0.04750790 0.04756007 [241] 0.04761175 0.04766296 0.04771370 0.04776395 0.04781373 0.04786304 [247] 0.04791186 0.04796020 0.04800807 0.04805545 0.04810235 0.04814877 [253] 0.04819471 0.04824017 0.04828514 0.04832963 0.04837363 0.04841715 [259] 0.04846019 0.04850273 0.04854480 0.04858637 0.04862746 0.04866807 [265] 0.04870818 0.04874781 0.04878695 0.04882560 0.04886376 0.04890144 [271] 0.04893862 0.04897532 0.04901152 0.04904724 0.04908247 0.04911720 [277] 0.04915145 0.04918520 0.04921847 0.04925124 0.04928353 0.04931532 [283] 0.04934662 0.04937743 0.04940775 0.04943758 0.04946692 0.04949576 [289] 0.04952412 0.04955198 0.04957936 0.04960624 0.04963263 0.04965853 [295] 0.04968394 0.04970886 0.04973329 0.04975723 0.04978068 0.04980364 [301] 0.04982612 0.04984810 0.04986959 0.04989059 0.04991110 0.04993113 [307] 0.04995067 0.04996972 0.04998828 0.05000635 0.05002394 0.05004104 [313] 0.05005766 0.05007379 0.05008943 0.05010459 0.05011926 0.05013345 [319] 0.05014715 0.05016037 0.05017311 0.05018537 0.05019714 0.05020843 [325] 0.05021924 0.05022957 0.05023942 0.05024879 0.05025769 0.05026610 [331] 0.05027403 0.05028149 0.05028847 0.05029498 0.05030100 0.05030656 [337] 0.05031164 0.05031624 0.05032038 0.05032404 0.05032723 0.05032994 [343] 0.05033219 0.05033397 0.05033528 0.05033612 0.05033649 0.05033640 [349] 0.05033584 0.05033481 0.05033332 0.05033137 0.05032895 0.05032607 [355] 0.05032273 0.05031893 0.05031467 0.05030995 0.05030478 0.05029914 [361] 0.05029305 0.05028651 0.05027951 0.05027205 0.05026415 0.05025579 [367] 0.05024698 0.05023772 0.05022801 0.05021785 0.05020725 0.05019620 [373] 0.05018470 0.05017276 0.05016038 0.05014755 0.05013428 0.05012057 [379] 0.05010642 0.05009183 0.05007681 0.05006135 0.05004545 0.05002912 [385] 0.05001235 0.04999516 0.04997753 0.04995947 0.04994098 0.04992206 [391] 0.04990272 0.04988295 0.04986275 0.04984213 0.04982109 0.04979962 [397] 0.04977774 0.04975543 0.04973271 0.04970957 0.04968601 > mx [1] 0.05033649 > mxli [1] 1.46 > 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/freestat/rcomp/tmp/1l8yq1228485636.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/freestat/rcomp/tmp/29cm91228485636.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/freestat/rcomp/tmp/30qpq1228485636.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 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/4orhk1228485636.tab") > > system("convert tmp/1l8yq1228485636.ps tmp/1l8yq1228485636.png") > system("convert tmp/29cm91228485636.ps tmp/29cm91228485636.png") > system("convert tmp/30qpq1228485636.ps tmp/30qpq1228485636.png") > > > proc.time() user system elapsed 1.222 0.813 1.462