R version 2.9.0 (2009-04-17) Copyright (C) 2009 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.8,100.5,110.4,96.4,101.9,106.2,81,94.7,101,109.4,102.3,90.7,96.2,96.1,106,103.1,102,104.7,86,92.1,106.9,112.6,101.7,92,97.4,97,105.4,102.7,98.1,104.5,87.4,89.9,109.8,111.7,98.6,96.9,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) > x <- c(467,460,448,443,436,431,484,510,513,503,471,471,476,475,470,461,455,456,517,525,523,519,509,512,519,517,510,509,501,507,569,580,578,565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597) > #'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.02079002 0.02084695 0.02090383 0.02096068 0.02101748 0.02107424 [7] 0.02113096 0.02118764 0.02124427 0.02130087 0.02135742 0.02141393 [13] 0.02147040 0.02152683 0.02158322 0.02163956 0.02169586 0.02175212 [19] 0.02180834 0.02186452 0.02192065 0.02197674 0.02203279 0.02208879 [25] 0.02214475 0.02220067 0.02225655 0.02231238 0.02236817 0.02242392 [31] 0.02247962 0.02253529 0.02259090 0.02264648 0.02270201 0.02275750 [37] 0.02281294 0.02286834 0.02292370 0.02297901 0.02303428 0.02308951 [43] 0.02314469 0.02319983 0.02325492 0.02330997 0.02336497 0.02341993 [49] 0.02347485 0.02352972 0.02358455 0.02363933 0.02369407 0.02374876 [55] 0.02380341 0.02385801 0.02391257 0.02396709 0.02402155 0.02407598 [61] 0.02413036 0.02418469 0.02423898 0.02429322 0.02434742 0.02440157 [67] 0.02445567 0.02450973 0.02456375 0.02461772 0.02467164 0.02472551 [73] 0.02477935 0.02483313 0.02488687 0.02494056 0.02499421 0.02504781 [79] 0.02510136 0.02515487 0.02520833 0.02526174 0.02531511 0.02536843 [85] 0.02542171 0.02547493 0.02552811 0.02558125 0.02563433 0.02568737 [91] 0.02574037 0.02579331 0.02584621 0.02589906 0.02595186 0.02600462 [97] 0.02605733 0.02610999 0.02616260 0.02621517 0.02626769 0.02632016 [103] 0.02637258 0.02642495 0.02647728 0.02652956 0.02658179 0.02663397 [109] 0.02668610 0.02673819 0.02679023 0.02684222 0.02689416 0.02694605 [115] 0.02699789 0.02704969 0.02710143 0.02715313 0.02720478 0.02725638 [121] 0.02730793 0.02735943 0.02741089 0.02746229 0.02751365 0.02756495 [127] 0.02761621 0.02766742 0.02771858 0.02776968 0.02782074 0.02787175 [133] 0.02792271 0.02797362 0.02802449 0.02807530 0.02812606 0.02817677 [139] 0.02822743 0.02827804 0.02832861 0.02837912 0.02842958 0.02847999 [145] 0.02853035 0.02858066 0.02863093 0.02868114 0.02873130 0.02878141 [151] 0.02883147 0.02888147 0.02893143 0.02898134 0.02903120 0.02908100 [157] 0.02913076 0.02918046 0.02923012 0.02927972 0.02932927 0.02937877 [163] 0.02942822 0.02947762 0.02952697 0.02957626 0.02962551 0.02967470 [169] 0.02972384 0.02977293 0.02982197 0.02987096 0.02991990 0.02996878 [175] 0.03001761 0.03006639 0.03011512 0.03016380 0.03021243 0.03026100 [181] 0.03030952 0.03035799 0.03040641 0.03045477 0.03050309 0.03055135 [187] 0.03059956 0.03064772 0.03069582 0.03074387 0.03079187 0.03083982 [193] 0.03088771 0.03093556 0.03098335 0.03103108 0.03107877 0.03112640 [199] 0.03117398 0.03122151 0.03126898 0.03131640 0.03136377 0.03141108 [205] 0.03145835 0.03150555 0.03155271 0.03159981 0.03164686 0.03169386 [211] 0.03174080 0.03178769 0.03183453 0.03188131 0.03192804 0.03197472 [217] 0.03202134 0.03206791 0.03211443 0.03216089 0.03220730 0.03225365 [223] 0.03229995 0.03234620 0.03239240 0.03243854 0.03248462 0.03253066 [229] 0.03257663 0.03262256 0.03266843 0.03271425 0.03276001 0.03280572 [235] 0.03285137 0.03289697 0.03294252 0.03298801 0.03303345 0.03307883 [241] 0.03312416 0.03316943 0.03321465 0.03325982 0.03330493 0.03334999 [247] 0.03339499 0.03343994 0.03348483 0.03352967 0.03357445 0.03361918 [253] 0.03366386 0.03370848 0.03375304 0.03379755 0.03384201 0.03388641 [259] 0.03393075 0.03397504 0.03401928 0.03406346 0.03410758 0.03415166 [265] 0.03419567 0.03423963 0.03428354 0.03432739 0.03437118 0.03441492 [271] 0.03445860 0.03450223 0.03454581 0.03458933 0.03463279 0.03467620 [277] 0.03471955 0.03476285 0.03480609 0.03484927 0.03489240 0.03493548 [283] 0.03497850 0.03502146 0.03506437 0.03510722 0.03515002 0.03519276 [289] 0.03523544 0.03527807 0.03532064 0.03536316 0.03540562 0.03544803 [295] 0.03549038 0.03553267 0.03557491 0.03561710 0.03565922 0.03570129 [301] 0.03574331 0.03578527 0.03582717 0.03586901 0.03591080 0.03595254 [307] 0.03599422 0.03603584 0.03607740 0.03611891 0.03616037 0.03620176 [313] 0.03624310 0.03628439 0.03632562 0.03636679 0.03640790 0.03644896 [319] 0.03648996 0.03653091 0.03657180 0.03661263 0.03665341 0.03669413 [325] 0.03673480 0.03677540 0.03681595 0.03685645 0.03689689 0.03693727 [331] 0.03697759 0.03701786 0.03705807 0.03709823 0.03713833 0.03717837 [337] 0.03721835 0.03725828 0.03729815 0.03733797 0.03737772 0.03741743 [343] 0.03745707 0.03749666 0.03753619 0.03757566 0.03761508 0.03765444 [349] 0.03769374 0.03773299 0.03777218 0.03781131 0.03785039 0.03788941 [355] 0.03792837 0.03796728 0.03800612 0.03804492 0.03808365 0.03812233 [361] 0.03816095 0.03819951 0.03823802 0.03827647 0.03831486 0.03835320 [367] 0.03839147 0.03842970 0.03846786 0.03850597 0.03854402 0.03858201 [373] 0.03861995 0.03865782 0.03869565 0.03873341 0.03877112 0.03880877 [379] 0.03884636 0.03888390 0.03892138 0.03895880 0.03899616 0.03903347 [385] 0.03907072 0.03910791 0.03914505 0.03918213 0.03921915 0.03925611 [391] 0.03929302 0.03932987 0.03936666 0.03940340 0.03944007 0.03947670 [397] 0.03951326 0.03954976 0.03958621 0.03962261 0.03965894 > mx [1] 0.03965894 > 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/1zmdw1258140067.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/2aouh1258140067.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/3hqdo1258140067.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/4mcp21258140067.tab") > > system("convert tmp/1zmdw1258140067.ps tmp/1zmdw1258140067.png") > system("convert tmp/2aouh1258140067.ps tmp/2aouh1258140067.png") > system("convert tmp/3hqdo1258140067.ps tmp/3hqdo1258140067.png") > > > proc.time() user system elapsed 0.808 0.527 0.997