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(93.3,97.3,127,111.7,96.4,133,72.2,95.8,124.1,127.6,110.7,104.6,112.7,115.3,139.4,119,97.4,154,81.5,88.8,127.7,105.1,114.9,106.4,104.5,121.6,141.4,99,126.7,134.1,81.3,88.6,132.7,132.9,134.4,103.7,119.7,115,132.9,108.5,113.9,142,97.7,92.2,128.8,134.9,128.2,114.8,117.9,119.1,120.7,129.1,117.6,129.2,100,87,128,127.7,93.4,84.1,71.7) > x <- c(95.1,97,112.7,102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91) > #'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.8477513 0.8478644 0.8479772 0.8480895 0.8482015 0.8483132 0.8484244 [8] 0.8485353 0.8486457 0.8487558 0.8488656 0.8489749 0.8490839 0.8491924 [15] 0.8493006 0.8494085 0.8495159 0.8496230 0.8497297 0.8498360 0.8499419 [22] 0.8500475 0.8501527 0.8502575 0.8503619 0.8504660 0.8505696 0.8506729 [29] 0.8507759 0.8508784 0.8509806 0.8510824 0.8511838 0.8512848 0.8513855 [36] 0.8514858 0.8515857 0.8516853 0.8517844 0.8518832 0.8519816 0.8520797 [43] 0.8521774 0.8522747 0.8523716 0.8524681 0.8525643 0.8526601 0.8527556 [50] 0.8528506 0.8529453 0.8530396 0.8531336 0.8532272 0.8533204 0.8534132 [57] 0.8535057 0.8535978 0.8536895 0.8537808 0.8538718 0.8539624 0.8540527 [64] 0.8541425 0.8542321 0.8543212 0.8544100 0.8544984 0.8545864 0.8546741 [71] 0.8547614 0.8548483 0.8549348 0.8550210 0.8551069 0.8551923 0.8552774 [78] 0.8553622 0.8554465 0.8555305 0.8556141 0.8556974 0.8557803 0.8558629 [85] 0.8559450 0.8560268 0.8561083 0.8561894 0.8562701 0.8563505 0.8564305 [92] 0.8565101 0.8565894 0.8566683 0.8567468 0.8568250 0.8569028 0.8569803 [99] 0.8570574 0.8571341 0.8572105 0.8572865 0.8573622 0.8574375 0.8575125 [106] 0.8575870 0.8576613 0.8577351 0.8578087 0.8578818 0.8579546 0.8580271 [113] 0.8580991 0.8581709 0.8582422 0.8583133 0.8583839 0.8584542 0.8585242 [120] 0.8585938 0.8586630 0.8587319 0.8588004 0.8588686 0.8589364 0.8590039 [127] 0.8590710 0.8591378 0.8592042 0.8592703 0.8593360 0.8594014 0.8594664 [134] 0.8595310 0.8595953 0.8596593 0.8597229 0.8597862 0.8598491 0.8599116 [141] 0.8599739 0.8600357 0.8600972 0.8601584 0.8602192 0.8602797 0.8603399 [148] 0.8603996 0.8604591 0.8605182 0.8605769 0.8606353 0.8606934 0.8607511 [155] 0.8608085 0.8608655 0.8609222 0.8609785 0.8610345 0.8610902 0.8611455 [162] 0.8612005 0.8612551 0.8613094 0.8613633 0.8614169 0.8614702 0.8615231 [169] 0.8615757 0.8616280 0.8616799 0.8617315 0.8617827 0.8618336 0.8618841 [176] 0.8619344 0.8619842 0.8620338 0.8620830 0.8621319 0.8621804 0.8622286 [183] 0.8622765 0.8623240 0.8623712 0.8624181 0.8624647 0.8625109 0.8625567 [190] 0.8626023 0.8626475 0.8626924 0.8627369 0.8627811 0.8628250 0.8628685 [197] 0.8629118 0.8629547 0.8629972 0.8630395 0.8630814 0.8631229 0.8631642 [204] 0.8632051 0.8632457 0.8632860 0.8633259 0.8633655 0.8634048 0.8634438 [211] 0.8634824 0.8635208 0.8635588 0.8635964 0.8636338 0.8636708 0.8637075 [218] 0.8637439 0.8637799 0.8638157 0.8638511 0.8638862 0.8639209 0.8639554 [225] 0.8639895 0.8640233 0.8640568 0.8640900 0.8641228 0.8641554 0.8641876 [232] 0.8642195 0.8642511 0.8642824 0.8643133 0.8643440 0.8643743 0.8644043 [239] 0.8644340 0.8644633 0.8644924 0.8645212 0.8645496 0.8645777 0.8646055 [246] 0.8646330 0.8646602 0.8646871 0.8647137 0.8647399 0.8647659 0.8647915 [253] 0.8648168 0.8648418 0.8648666 0.8648910 0.8649150 0.8649388 0.8649623 [260] 0.8649855 0.8650083 0.8650309 0.8650532 0.8650751 0.8650967 0.8651181 [267] 0.8651391 0.8651598 0.8651803 0.8652004 0.8652202 0.8652397 0.8652590 [274] 0.8652779 0.8652965 0.8653148 0.8653328 0.8653505 0.8653679 0.8653851 [281] 0.8654019 0.8654184 0.8654346 0.8654505 0.8654662 0.8654815 0.8654965 [288] 0.8655112 0.8655257 0.8655398 0.8655537 0.8655672 0.8655805 0.8655935 [295] 0.8656061 0.8656185 0.8656306 0.8656424 0.8656539 0.8656651 0.8656760 [302] 0.8656867 0.8656970 0.8657071 0.8657168 0.8657263 0.8657355 0.8657444 [309] 0.8657530 0.8657613 0.8657693 0.8657771 0.8657845 0.8657917 0.8657986 [316] 0.8658052 0.8658115 0.8658175 0.8658233 0.8658288 0.8658339 0.8658388 [323] 0.8658435 0.8658478 0.8658518 0.8658556 0.8658591 0.8658623 0.8658652 [330] 0.8658679 0.8658703 0.8658724 0.8658742 0.8658757 0.8658770 0.8658779 [337] 0.8658786 0.8658791 0.8658792 0.8658791 0.8658787 0.8658780 0.8658771 [344] 0.8658758 0.8658743 0.8658726 0.8658705 0.8658682 0.8658656 0.8658627 [351] 0.8658596 0.8658562 0.8658525 0.8658486 0.8658444 0.8658399 0.8658351 [358] 0.8658301 0.8658248 0.8658192 0.8658134 0.8658073 0.8658010 0.8657943 [365] 0.8657874 0.8657803 0.8657728 0.8657651 0.8657572 0.8657490 0.8657405 [372] 0.8657317 0.8657227 0.8657135 0.8657039 0.8656941 0.8656841 0.8656737 [379] 0.8656632 0.8656523 0.8656412 0.8656299 0.8656182 0.8656064 0.8655942 [386] 0.8655818 0.8655692 0.8655563 0.8655431 0.8655297 0.8655160 0.8655021 [393] 0.8654879 0.8654734 0.8654587 0.8654438 0.8654286 0.8654131 0.8653974 [400] 0.8653814 0.8653652 > mx [1] 0.8658792 > mxli [1] 1.38 > 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/1bvgq1258042099.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/22b8f1258042099.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/39f5f1258042099.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/4hhgn1258042099.tab") > > system("convert tmp/1bvgq1258042099.ps tmp/1bvgq1258042099.png") > system("convert tmp/22b8f1258042099.ps tmp/22b8f1258042099.png") > system("convert tmp/39f5f1258042099.ps tmp/39f5f1258042099.png") > > > proc.time() user system elapsed 1.171 0.782 1.368