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.5,98.8,106.2,98.3,102.1,117.1,101.5,80.5,105.9,109.5,97.2,114.5,93.5,100.9,121.1,116.5,109.3,118.1,108.3,105.4,116.2,111.2,105.8,122.7,99.5,107.9,124.6,115,110.3,132.7,99.7,96.5,118.7,112.9,130.5,137.9,115,116.8,140.9,120.7,134.2,147.3,112.4,107.1,128.4,137.7,135,151,137.4,132.4,161.3,139.8,146,166.5,143.3,121,152.6,154.4,154.6,158) > x <- c(103.3,101.2,107.7,110.4,101.9,115.9,89.9,88.6,117.2,123.9,100,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97,121.6,118.8,114,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,151.1,105,119,140.4,156.6,137.1,122.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.7608015 0.7610957 0.7613892 0.7616822 0.7619745 0.7622662 0.7625572 [8] 0.7628476 0.7631374 0.7634266 0.7637151 0.7640030 0.7642902 0.7645768 [15] 0.7648628 0.7651481 0.7654328 0.7657168 0.7660002 0.7662829 0.7665650 [22] 0.7668465 0.7671273 0.7674074 0.7676869 0.7679658 0.7682440 0.7685215 [29] 0.7687984 0.7690746 0.7693502 0.7696251 0.7698993 0.7701729 0.7704458 [36] 0.7707180 0.7709896 0.7712605 0.7715308 0.7718004 0.7720693 0.7723375 [43] 0.7726051 0.7728720 0.7731382 0.7734037 0.7736686 0.7739328 0.7741963 [50] 0.7744591 0.7747212 0.7749827 0.7752435 0.7755036 0.7757630 0.7760217 [57] 0.7762797 0.7765371 0.7767937 0.7770497 0.7773049 0.7775595 0.7778134 [64] 0.7780666 0.7783191 0.7785709 0.7788219 0.7790723 0.7793220 0.7795710 [71] 0.7798193 0.7800669 0.7803137 0.7805599 0.7808054 0.7810501 0.7812942 [78] 0.7815375 0.7817801 0.7820220 0.7822632 0.7825037 0.7827435 0.7829825 [85] 0.7832209 0.7834585 0.7836954 0.7839316 0.7841670 0.7844018 0.7846358 [92] 0.7848690 0.7851016 0.7853334 0.7855645 0.7857949 0.7860246 0.7862535 [99] 0.7864817 0.7867091 0.7869359 0.7871619 0.7873871 0.7876116 0.7878354 [106] 0.7880585 0.7882808 0.7885023 0.7887232 0.7889433 0.7891626 0.7893812 [113] 0.7895991 0.7898162 0.7900326 0.7902482 0.7904631 0.7906772 0.7908906 [120] 0.7911032 0.7913151 0.7915262 0.7917366 0.7919462 0.7921550 0.7923631 [127] 0.7925705 0.7927771 0.7929829 0.7931880 0.7933923 0.7935959 0.7937987 [134] 0.7940007 0.7942020 0.7944025 0.7946023 0.7948012 0.7949995 0.7951969 [141] 0.7953936 0.7955895 0.7957846 0.7959790 0.7961726 0.7963654 0.7965575 [148] 0.7967488 0.7969393 0.7971290 0.7973180 0.7975062 0.7976936 0.7978802 [155] 0.7980661 0.7982511 0.7984354 0.7986189 0.7988017 0.7989836 0.7991648 [162] 0.7993452 0.7995248 0.7997036 0.7998816 0.8000589 0.8002353 0.8004110 [169] 0.8005858 0.8007599 0.8009332 0.8011057 0.8012775 0.8014484 0.8016185 [176] 0.8017879 0.8019564 0.8021242 0.8022911 0.8024573 0.8026226 0.8027872 [183] 0.8029510 0.8031139 0.8032761 0.8034375 0.8035980 0.8037578 0.8039168 [190] 0.8040750 0.8042323 0.8043889 0.8045446 0.8046996 0.8048537 0.8050071 [197] 0.8051596 0.8053113 0.8054623 0.8056124 0.8057617 0.8059102 0.8060579 [204] 0.8062047 0.8063508 0.8064961 0.8066405 0.8067841 0.8069270 0.8070690 [211] 0.8072102 0.8073505 0.8074901 0.8076288 0.8077668 0.8079039 0.8080402 [218] 0.8081757 0.8083103 0.8084442 0.8085772 0.8087094 0.8088408 0.8089714 [225] 0.8091011 0.8092300 0.8093581 0.8094854 0.8096119 0.8097375 0.8098623 [232] 0.8099863 0.8101095 0.8102318 0.8103533 0.8104740 0.8105939 0.8107129 [239] 0.8108311 0.8109485 0.8110651 0.8111808 0.8112957 0.8114098 0.8115230 [246] 0.8116355 0.8117470 0.8118578 0.8119677 0.8120768 0.8121851 0.8122925 [253] 0.8123991 0.8125049 0.8126098 0.8127139 0.8128172 0.8129196 0.8130212 [260] 0.8131220 0.8132220 0.8133211 0.8134193 0.8135168 0.8136134 0.8137091 [267] 0.8138041 0.8138981 0.8139914 0.8140838 0.8141754 0.8142661 0.8143561 [274] 0.8144451 0.8145334 0.8146208 0.8147073 0.8147930 0.8148779 0.8149619 [281] 0.8150452 0.8151275 0.8152090 0.8152897 0.8153696 0.8154486 0.8155267 [288] 0.8156041 0.8156805 0.8157562 0.8158310 0.8159050 0.8159781 0.8160504 [295] 0.8161218 0.8161924 0.8162622 0.8163311 0.8163991 0.8164664 0.8165328 [302] 0.8165983 0.8166630 0.8167269 0.8167899 0.8168521 0.8169134 0.8169739 [309] 0.8170336 0.8170924 0.8171503 0.8172074 0.8172637 0.8173192 0.8173738 [316] 0.8174275 0.8174804 0.8175325 0.8175837 0.8176341 0.8176836 0.8177323 [323] 0.8177802 0.8178272 0.8178733 0.8179187 0.8179631 0.8180068 0.8180496 [330] 0.8180915 0.8181326 0.8181729 0.8182123 0.8182509 0.8182886 0.8183255 [337] 0.8183616 0.8183968 0.8184312 0.8184647 0.8184974 0.8185292 0.8185602 [344] 0.8185904 0.8186197 0.8186482 0.8186758 0.8187026 0.8187285 0.8187536 [351] 0.8187779 0.8188013 0.8188239 0.8188457 0.8188666 0.8188866 0.8189059 [358] 0.8189243 0.8189418 0.8189585 0.8189744 0.8189894 0.8190036 0.8190170 [365] 0.8190295 0.8190412 0.8190520 0.8190620 0.8190712 0.8190795 0.8190870 [372] 0.8190936 0.8190995 0.8191044 0.8191086 0.8191119 0.8191144 0.8191160 [379] 0.8191168 0.8191168 0.8191159 0.8191142 0.8191117 0.8191083 0.8191041 [386] 0.8190991 0.8190932 0.8190865 0.8190790 0.8190707 0.8190615 0.8190514 [393] 0.8190406 0.8190289 0.8190164 0.8190031 0.8189889 0.8189739 0.8189581 [400] 0.8189414 0.8189240 > mx [1] 0.8191168 > mxli [1] 1.78 > 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/1t8n01226414379.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/2adf71226414379.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/3l0gf1226414379.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/4hn0n1226414379.tab") > > system("convert tmp/1t8n01226414379.ps tmp/1t8n01226414379.png") > system("convert tmp/2adf71226414379.ps tmp/2adf71226414379.png") > system("convert tmp/3l0gf1226414379.ps tmp/3l0gf1226414379.png") > > > proc.time() user system elapsed 1.233 0.823 1.794