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(98.4,107.4,117.7,105.7,97.5,99.9,98.2,104.5,100.8,101.5,103.9,99.6,98.4,112.7,118.4,108.1,105.4,114.6,106.9,115.9,109.8,101.8,114.2,110.8,108.4,127.5,128.6,116.6,127.4,105.0,108.3,125.0,111.6,106.5,130.3,115.0,116.1,134.0,126.5,125.8,136.4,114.9,110.9,125.5,116.8,116.8,125.5,104.2,115.1,132.8,123.3,124.8,122.0,117.4,117.9,137.4,114.6,124.7,129.6,109.4,120.9,134.9,136.3,133.2,127.2,122.7,120.5,137.8,119.1,124.3,134.4,121.1,122.2,127.7,137.4,132.2,129.2,124.9,124.8,128.2,134.4,118.6,132.6,123.2,112.3) > x <- c(75.4,105.5,112.3,102.5,93.5,86.7,95.2,103.8,97.0,95.5,101.0,67.5,64.0,106.7,100.6,101.2,93.1,84.2,85.8,91.8,92.4,80.3,79.7,62.5,57.1,100.8,100.7,86.2,83.2,71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91.0,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84.0,54.3,60.0,89.9,77.0,85.3,77.6,69.2,75.5,85.7,72.2,79.9,85.3,52.2,61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69.0,79.2,56.2,63.3,77.8,92.0,78.1,65.1,71.1,70.9,72.0,81.9,70.6,72.5,65.1,61.1) > #'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.0615637582 0.0612488641 0.0609336273 0.0606180492 0.0603021312 [6] 0.0599858749 0.0596692815 0.0593523527 0.0590350897 0.0587174942 [11] 0.0583995675 0.0580813111 0.0577627266 0.0574438153 0.0571245787 [16] 0.0568050185 0.0564851359 0.0561649327 0.0558444102 0.0555235699 [21] 0.0552024135 0.0548809424 0.0545591581 0.0542370622 0.0539146563 [26] 0.0535919418 0.0532689203 0.0529455934 0.0526219626 0.0522980295 [31] 0.0519737956 0.0516492626 0.0513244320 0.0509993055 0.0506738845 [36] 0.0503481707 0.0500221656 0.0496958710 0.0493692884 0.0490424194 [41] 0.0487152656 0.0483878287 0.0480601102 0.0477321119 0.0474038353 [46] 0.0470752822 0.0467464540 0.0464173526 0.0460879795 0.0457583364 [51] 0.0454284250 0.0450982470 0.0447678040 0.0444370976 0.0441061297 [56] 0.0437749018 0.0434434157 0.0431116730 0.0427796755 0.0424474249 [61] 0.0421149228 0.0417821710 0.0414491712 0.0411159252 0.0407824345 [66] 0.0404487011 0.0401147265 0.0397805126 0.0394460611 0.0391113737 [71] 0.0387764522 0.0384412983 0.0381059139 0.0377703005 0.0374344601 [76] 0.0370983944 0.0367621051 0.0364255940 0.0360888630 0.0357519137 [81] 0.0354147480 0.0350773677 0.0347397746 0.0344019704 0.0340639569 [86] 0.0337257361 0.0333873096 0.0330486792 0.0327098469 0.0323708144 [91] 0.0320315835 0.0316921560 0.0313525339 0.0310127188 0.0306727127 [96] 0.0303325174 0.0299921347 0.0296515664 0.0293108145 0.0289698807 [101] 0.0286287669 0.0282874750 0.0279460067 0.0276043641 0.0272625489 [106] 0.0269205630 0.0265784083 0.0262360866 0.0258935998 0.0255509498 [111] 0.0252081385 0.0248651677 0.0245220394 0.0241787553 0.0238353175 [116] 0.0234917278 0.0231479880 0.0228041002 0.0224600661 0.0221158877 [121] 0.0217715669 0.0214271055 0.0210825056 0.0207377689 0.0203928975 [126] 0.0200478932 0.0197027579 0.0193574936 0.0190121021 0.0186665855 [131] 0.0183209455 0.0179751842 0.0176293034 0.0172833052 0.0169371913 [136] 0.0165909638 0.0162446246 0.0158981756 0.0155516187 0.0152049559 [141] 0.0148581891 0.0145113203 0.0141643514 0.0138172844 0.0134701211 [146] 0.0131228636 0.0127755137 0.0124280735 0.0120805449 0.0117329297 [151] 0.0113852301 0.0110374479 0.0106895850 0.0103416435 0.0099936253 [156] 0.0096455323 0.0092973665 0.0089491299 0.0086008244 0.0082524520 [161] 0.0079040146 0.0075555142 0.0072069527 0.0068583322 0.0065096545 [166] 0.0061609217 0.0058121357 0.0054632985 0.0051144120 0.0047654782 [171] 0.0044164990 0.0040674765 0.0037184125 0.0033693092 0.0030201683 [176] 0.0026709919 0.0023217820 0.0019725405 0.0016232694 0.0012739706 [181] 0.0009246462 0.0005752980 0.0002259281 -0.0001234616 -0.0004728691 [186] -0.0008222925 -0.0011717298 -0.0015211789 -0.0018706381 -0.0022201052 [191] -0.0025695784 -0.0029190556 -0.0032685350 -0.0036180145 -0.0039674922 [196] -0.0043169660 -0.0046664342 -0.0050158947 -0.0053653455 -0.0057147846 [201] -0.0060642102 -0.0064136203 -0.0067630129 -0.0071123860 -0.0074617378 [206] -0.0078110662 -0.0081603693 -0.0085096451 -0.0088588917 -0.0092081072 [211] -0.0095572896 -0.0099064369 -0.0102555472 -0.0106046186 -0.0109536491 [216] -0.0113026368 -0.0116515797 -0.0120004759 -0.0123493235 -0.0126981205 [221] -0.0130468650 -0.0133955550 -0.0137441886 -0.0140927640 -0.0144412791 [226] -0.0147897320 -0.0151381209 -0.0154864437 -0.0158346986 -0.0161828836 [231] -0.0165309969 -0.0168790365 -0.0172270004 -0.0175748869 -0.0179226939 [236] -0.0182704195 -0.0186180620 -0.0189656193 -0.0193130895 -0.0196604708 [241] -0.0200077612 -0.0203549588 -0.0207020619 -0.0210490684 -0.0213959764 [246] -0.0217427842 -0.0220894898 -0.0224360912 -0.0227825868 -0.0231289745 [251] -0.0234752524 -0.0238214188 -0.0241674718 -0.0245134094 -0.0248592298 [256] -0.0252049312 -0.0255505117 -0.0258959694 -0.0262413025 -0.0265865091 [261] -0.0269315874 -0.0272765355 -0.0276213517 -0.0279660339 -0.0283105805 [266] -0.0286549896 -0.0289992593 -0.0293433878 -0.0296873733 -0.0300312140 [271] -0.0303749080 -0.0307184535 -0.0310618488 -0.0314050920 -0.0317481813 [276] -0.0320911149 -0.0324338910 -0.0327765078 -0.0331189634 -0.0334612563 [281] -0.0338033844 -0.0341453461 -0.0344871395 -0.0348287629 -0.0351702146 [286] -0.0355114927 -0.0358525954 -0.0361935211 -0.0365342680 -0.0368748342 [291] -0.0372152181 -0.0375554178 -0.0378954318 -0.0382352581 -0.0385748951 [296] -0.0389143410 -0.0392535942 -0.0395926528 -0.0399315152 -0.0402701796 [301] -0.0406086444 -0.0409469078 -0.0412849680 -0.0416228235 -0.0419604725 [306] -0.0422979133 -0.0426351442 -0.0429721635 -0.0433089696 -0.0436455608 [311] -0.0439819353 -0.0443180916 -0.0446540280 -0.0449897427 -0.0453252341 [316] -0.0456605007 -0.0459955407 -0.0463303524 -0.0466649343 -0.0469992847 [321] -0.0473334020 -0.0476672845 -0.0480009307 -0.0483343388 -0.0486675073 [326] -0.0490004347 -0.0493331191 -0.0496655592 -0.0499977532 -0.0503296996 [331] -0.0506613967 -0.0509928431 -0.0513240371 -0.0516549771 -0.0519856617 [336] -0.0523160891 -0.0526462579 -0.0529761664 -0.0533058132 -0.0536351968 [341] -0.0539643154 -0.0542931677 -0.0546217520 -0.0549500670 -0.0552781109 [346] -0.0556058823 -0.0559333798 -0.0562606017 -0.0565875466 -0.0569142130 [351] -0.0572405994 -0.0575667043 -0.0578925262 -0.0582180636 -0.0585433151 [356] -0.0588682791 -0.0591929543 -0.0595173392 -0.0598414323 -0.0601652321 [361] -0.0604887372 -0.0608119462 -0.0611348576 -0.0614574701 -0.0617797821 [366] -0.0621017923 -0.0624234992 -0.0627449015 -0.0630659977 -0.0633867864 [371] -0.0637072663 -0.0640274359 -0.0643472939 -0.0646668388 -0.0649860694 [376] -0.0653049842 -0.0656235819 -0.0659418611 -0.0662598205 -0.0665774586 [381] -0.0668947743 -0.0672117661 -0.0675284327 -0.0678447728 -0.0681607851 [386] -0.0684764682 -0.0687918208 -0.0691068417 -0.0694215294 -0.0697358828 [391] -0.0700499006 -0.0703635814 -0.0706769240 -0.0709899271 -0.0713025894 [396] -0.0716149097 -0.0719268867 -0.0722385192 -0.0725498059 -0.0728607456 [401] -0.0731713370 > mx [1] 0.07317134 > 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/freestat/rcomp/tmp/198q61226502056.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/2yhzj1226502056.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/3kmnq1226502056.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/4lccn1226502056.tab") > > system("convert tmp/198q61226502056.ps tmp/198q61226502056.png") > system("convert tmp/2yhzj1226502056.ps tmp/2yhzj1226502056.png") > system("convert tmp/3kmnq1226502056.ps tmp/3kmnq1226502056.png") > > > proc.time() user system elapsed 1.239 0.817 1.666