R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(112.6,113.8,107.8,103.2,103.3,101.2,107.7,110.4,101.9,115.9,89.9,88.6,117.2,123.9,100.0,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97.0,121.6,118.8,114.0,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80.0,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89.0,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,146.6,103.4,117.2) > x <- c(106.8,113.7,102.5,96.6,92.1,95.6,102.3,98.6,98.2,104.5,84.0,73.8,103.9,106.0,97.2,102.6,89.0,93.8,116.7,106.8,98.5,118.7,90.0,91.9,113.3,113.1,104.1,108.7,96.7,101.0,116.9,105.8,99.0,129.4,83.0,88.9,115.9,104.2,113.4,112.2,100.8,107.3,126.6,102.9,117.9,128.8,87.5,93.8,122.7,126.2,124.6,116.7,115.2,111.1,129.9,113.3,118.5,133.5,102.1,102.4) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.8917639 0.8920113 0.8922578 0.8925035 0.8927483 0.8929923 0.8932354 [8] 0.8934777 0.8937191 0.8939597 0.8941994 0.8944383 0.8946763 0.8949134 [15] 0.8951497 0.8953852 0.8956198 0.8958536 0.8960865 0.8963185 0.8965498 [22] 0.8967801 0.8970096 0.8972383 0.8974661 0.8976931 0.8979192 0.8981444 [29] 0.8983688 0.8985924 0.8988151 0.8990370 0.8992580 0.8994781 0.8996975 [36] 0.8999159 0.9001336 0.9003503 0.9005662 0.9007813 0.9009956 0.9012089 [43] 0.9014215 0.9016332 0.9018440 0.9020540 0.9022631 0.9024715 0.9026789 [50] 0.9028855 0.9030913 0.9032962 0.9035003 0.9037035 0.9039059 0.9041075 [57] 0.9043082 0.9045080 0.9047071 0.9049052 0.9051026 0.9052991 0.9054947 [64] 0.9056895 0.9058835 0.9060766 0.9062689 0.9064604 0.9066510 0.9068408 [71] 0.9070297 0.9072178 0.9074051 0.9075915 0.9077771 0.9079619 0.9081458 [78] 0.9083289 0.9085112 0.9086926 0.9088732 0.9090529 0.9092318 0.9094099 [85] 0.9095872 0.9097636 0.9099392 0.9101140 0.9102879 0.9104610 0.9106333 [92] 0.9108048 0.9109754 0.9111452 0.9113142 0.9114823 0.9116496 0.9118161 [99] 0.9119818 0.9121466 0.9123107 0.9124739 0.9126363 0.9127978 0.9129586 [106] 0.9131185 0.9132776 0.9134359 0.9135933 0.9137500 0.9139058 0.9140609 [113] 0.9142151 0.9143684 0.9145210 0.9146728 0.9148237 0.9149739 0.9151232 [120] 0.9152717 0.9154194 0.9155663 0.9157124 0.9158577 0.9160021 0.9161458 [127] 0.9162887 0.9164307 0.9165720 0.9167124 0.9168521 0.9169909 0.9171290 [134] 0.9172662 0.9174026 0.9175383 0.9176731 0.9178072 0.9179404 0.9180729 [141] 0.9182046 0.9183354 0.9184655 0.9185948 0.9187233 0.9188510 0.9189779 [148] 0.9191040 0.9192293 0.9193539 0.9194776 0.9196006 0.9197228 0.9198442 [155] 0.9199648 0.9200846 0.9202037 0.9203219 0.9204394 0.9205561 0.9206721 [162] 0.9207872 0.9209016 0.9210152 0.9211280 0.9212401 0.9213513 0.9214618 [169] 0.9215716 0.9216805 0.9217887 0.9218962 0.9220028 0.9221087 0.9222138 [176] 0.9223182 0.9224218 0.9225246 0.9226267 0.9227280 0.9228286 0.9229284 [183] 0.9230274 0.9231257 0.9232232 0.9233199 0.9234160 0.9235112 0.9236057 [190] 0.9236995 0.9237925 0.9238847 0.9239762 0.9240670 0.9241570 0.9242462 [197] 0.9243347 0.9244225 0.9245095 0.9245958 0.9246814 0.9247662 0.9248502 [204] 0.9249336 0.9250162 0.9250980 0.9251791 0.9252595 0.9253392 0.9254181 [211] 0.9254963 0.9255738 0.9256505 0.9257265 0.9258018 0.9258763 0.9259502 [218] 0.9260233 0.9260956 0.9261673 0.9262382 0.9263085 0.9263780 0.9264468 [225] 0.9265148 0.9265822 0.9266488 0.9267148 0.9267800 0.9268445 0.9269083 [232] 0.9269714 0.9270338 0.9270954 0.9271564 0.9272167 0.9272762 0.9273351 [239] 0.9273933 0.9274507 0.9275075 0.9275636 0.9276189 0.9276736 0.9277276 [246] 0.9277809 0.9278335 0.9278854 0.9279366 0.9279871 0.9280369 0.9280861 [253] 0.9281346 0.9281823 0.9282294 0.9282759 0.9283216 0.9283666 0.9284110 [260] 0.9284547 0.9284978 0.9285401 0.9285818 0.9286228 0.9286631 0.9287028 [267] 0.9287418 0.9287801 0.9288177 0.9288547 0.9288910 0.9289267 0.9289617 [274] 0.9289960 0.9290297 0.9290627 0.9290951 0.9291268 0.9291578 0.9291882 [281] 0.9292180 0.9292471 0.9292755 0.9293033 0.9293304 0.9293569 0.9293828 [288] 0.9294080 0.9294325 0.9294564 0.9294797 0.9295023 0.9295243 0.9295457 [295] 0.9295664 0.9295865 0.9296059 0.9296247 0.9296429 0.9296605 0.9296774 [302] 0.9296937 0.9297094 0.9297244 0.9297388 0.9297526 0.9297658 0.9297783 [309] 0.9297902 0.9298015 0.9298122 0.9298223 0.9298318 0.9298406 0.9298488 [316] 0.9298564 0.9298634 0.9298698 0.9298756 0.9298808 0.9298854 0.9298894 [323] 0.9298927 0.9298955 0.9298977 0.9298992 0.9299002 0.9299005 0.9299003 [330] 0.9298995 0.9298981 0.9298961 0.9298935 0.9298903 0.9298865 0.9298821 [337] 0.9298772 0.9298716 0.9298655 0.9298588 0.9298515 0.9298436 0.9298352 [344] 0.9298261 0.9298165 0.9298063 0.9297956 0.9297842 0.9297723 0.9297599 [351] 0.9297468 0.9297332 0.9297190 0.9297043 0.9296890 0.9296731 0.9296566 [358] 0.9296396 0.9296221 0.9296039 0.9295853 0.9295660 0.9295462 0.9295259 [365] 0.9295050 0.9294835 0.9294615 0.9294390 0.9294159 0.9293922 0.9293681 [372] 0.9293433 0.9293180 0.9292922 0.9292658 0.9292389 0.9292115 0.9291835 [379] 0.9291550 0.9291260 0.9290964 0.9290663 0.9290356 0.9290044 0.9289727 [386] 0.9289405 0.9289077 0.9288744 0.9288406 0.9288063 0.9287714 0.9287360 [393] 0.9287001 0.9286637 0.9286268 0.9285893 0.9285514 0.9285129 0.9284739 [400] 0.9284344 0.9283944 > mx [1] 0.9299005 > mxli [1] 1.27 > 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/1sse41194295777.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/242vb1194295777.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/3kbkk1194295777.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 > 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/4falo1194295777.tab") > > system("convert tmp/1sse41194295777.ps tmp/1sse41194295777.png") > system("convert tmp/242vb1194295777.ps tmp/242vb1194295777.png") > system("convert tmp/3kbkk1194295777.ps tmp/3kbkk1194295777.png") > > > proc.time() user system elapsed 1.083 0.509 1.240