R version 2.7.2 (2008-08-25) 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(148.8,146.7,118.8,99.4,97.6,110.2,146.6,136.4,126.2,154.9,109,128.5,144.9,136.3,134.8,103.4,106.6,119.2,149.3,150.2,142.9,163.6,98.2,138.2,143.7,132.8,149.4,128.8,98.9,106.2,140.7,133,156.4,157.7,107.9,133.6,148.1,205.6,193.1,117.5,116.4,129.5,157.1,157,158.4,161.7,116.9,161.1,155.7,160.8,145.4,111,144.8,149.2,156.6,182.5,171.3,172.7,133,148.1) > x <- c(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,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,97.6) > #'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.7385669 0.7387011 0.7388349 0.7389684 0.7391016 0.7392345 0.7393670 [8] 0.7394991 0.7396309 0.7397624 0.7398935 0.7400243 0.7401548 0.7402849 [15] 0.7404147 0.7405441 0.7406732 0.7408020 0.7409304 0.7410584 0.7411862 [22] 0.7413136 0.7414406 0.7415673 0.7416937 0.7418197 0.7419454 0.7420708 [29] 0.7421958 0.7423204 0.7424448 0.7425688 0.7426924 0.7428157 0.7429387 [36] 0.7430613 0.7431836 0.7433056 0.7434272 0.7435485 0.7436694 0.7437900 [43] 0.7439103 0.7440302 0.7441498 0.7442690 0.7443879 0.7445065 0.7446247 [50] 0.7447426 0.7448601 0.7449773 0.7450942 0.7452107 0.7453269 0.7454428 [57] 0.7455583 0.7456735 0.7457884 0.7459029 0.7460170 0.7461309 0.7462444 [64] 0.7463575 0.7464703 0.7465828 0.7466950 0.7468068 0.7469183 0.7470294 [71] 0.7471402 0.7472507 0.7473608 0.7474706 0.7475801 0.7476892 0.7477980 [78] 0.7479064 0.7480145 0.7481223 0.7482298 0.7483369 0.7484437 0.7485501 [85] 0.7486562 0.7487620 0.7488674 0.7489725 0.7490773 0.7491817 0.7492858 [92] 0.7493896 0.7494931 0.7495962 0.7496989 0.7498014 0.7499035 0.7500052 [99] 0.7501067 0.7502078 0.7503086 0.7504090 0.7505091 0.7506089 0.7507084 [106] 0.7508075 0.7509063 0.7510047 0.7511028 0.7512006 0.7512981 0.7513952 [113] 0.7514920 0.7515885 0.7516847 0.7517805 0.7518760 0.7519711 0.7520659 [120] 0.7521604 0.7522546 0.7523484 0.7524419 0.7525351 0.7526280 0.7527205 [127] 0.7528127 0.7529046 0.7529961 0.7530873 0.7531782 0.7532688 0.7533590 [134] 0.7534489 0.7535385 0.7536278 0.7537167 0.7538053 0.7538936 0.7539816 [141] 0.7540692 0.7541565 0.7542435 0.7543302 0.7544165 0.7545025 0.7545882 [148] 0.7546736 0.7547586 0.7548433 0.7549277 0.7550118 0.7550955 0.7551790 [155] 0.7552621 0.7553448 0.7554273 0.7555094 0.7555913 0.7556728 0.7557539 [162] 0.7558348 0.7559153 0.7559956 0.7560754 0.7561550 0.7562343 0.7563132 [169] 0.7563918 0.7564701 0.7565481 0.7566258 0.7567031 0.7567802 0.7568569 [176] 0.7569333 0.7570094 0.7570851 0.7571606 0.7572357 0.7573105 0.7573850 [183] 0.7574592 0.7575330 0.7576066 0.7576798 0.7577527 0.7578253 0.7578976 [190] 0.7579696 0.7580413 0.7581126 0.7581837 0.7582544 0.7583248 0.7583949 [197] 0.7584647 0.7585342 0.7586033 0.7586722 0.7587407 0.7588090 0.7588769 [204] 0.7589445 0.7590118 0.7590788 0.7591455 0.7592118 0.7592779 0.7593436 [211] 0.7594091 0.7594742 0.7595391 0.7596036 0.7596678 0.7597317 0.7597953 [218] 0.7598586 0.7599216 0.7599842 0.7600466 0.7601087 0.7601705 0.7602319 [225] 0.7602931 0.7603539 0.7604145 0.7604747 0.7605346 0.7605943 0.7606536 [232] 0.7607126 0.7607713 0.7608298 0.7608879 0.7609457 0.7610032 0.7610604 [239] 0.7611173 0.7611740 0.7612303 0.7612863 0.7613420 0.7613974 0.7614525 [246] 0.7615073 0.7615619 0.7616161 0.7616700 0.7617236 0.7617769 0.7618300 [253] 0.7618827 0.7619351 0.7619873 0.7620391 0.7620907 0.7621419 0.7621929 [260] 0.7622435 0.7622939 0.7623440 0.7623937 0.7624432 0.7624924 0.7625413 [267] 0.7625899 0.7626382 0.7626862 0.7627340 0.7627814 0.7628285 0.7628754 [274] 0.7629219 0.7629682 0.7630142 0.7630599 0.7631053 0.7631504 0.7631952 [281] 0.7632398 0.7632840 0.7633280 0.7633716 0.7634150 0.7634581 0.7635009 [288] 0.7635434 0.7635857 0.7636276 0.7636693 0.7637106 0.7637517 0.7637925 [295] 0.7638331 0.7638733 0.7639132 0.7639529 0.7639923 0.7640314 0.7640702 [302] 0.7641088 0.7641470 0.7641850 0.7642227 0.7642601 0.7642972 0.7643341 [309] 0.7643706 0.7644069 0.7644429 0.7644787 0.7645141 0.7645493 0.7645842 [316] 0.7646188 0.7646531 0.7646872 0.7647210 0.7647545 0.7647877 0.7648207 [323] 0.7648534 0.7648858 0.7649179 0.7649497 0.7649813 0.7650126 0.7650437 [330] 0.7650744 0.7651049 0.7651351 0.7651650 0.7651947 0.7652241 0.7652532 [337] 0.7652821 0.7653106 0.7653389 0.7653670 0.7653947 0.7654222 0.7654495 [344] 0.7654764 0.7655031 0.7655295 0.7655557 0.7655815 0.7656072 0.7656325 [351] 0.7656576 0.7656824 0.7657069 0.7657312 0.7657552 0.7657790 0.7658025 [358] 0.7658257 0.7658486 0.7658713 0.7658937 0.7659159 0.7659378 0.7659594 [365] 0.7659808 0.7660019 0.7660228 0.7660433 0.7660637 0.7660837 0.7661035 [372] 0.7661231 0.7661423 0.7661614 0.7661801 0.7661986 0.7662169 0.7662349 [379] 0.7662526 0.7662700 0.7662873 0.7663042 0.7663209 0.7663373 0.7663535 [386] 0.7663695 0.7663851 0.7664005 0.7664157 0.7664306 0.7664453 0.7664597 [393] 0.7664738 0.7664877 0.7665013 0.7665147 0.7665278 0.7665407 0.7665533 [400] 0.7665657 0.7665778 > mx [1] 0.7665778 > 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/1trn61226148689.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/2loep1226148689.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/3dhey1226148689.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/4s1vo1226148689.tab") > > system("convert tmp/1trn61226148689.ps tmp/1trn61226148689.png") > system("convert tmp/2loep1226148689.ps tmp/2loep1226148689.png") > system("convert tmp/3dhey1226148689.ps tmp/3dhey1226148689.png") > > > proc.time() user system elapsed 1.515 0.815 1.768