R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-bit) 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(1024,768,700,768,800,1024,800,768,800,1024,800,800,1024,949,900,1200,800,800,768,735,800,845,900,768,768,768,800,1440,768,768,1024,800,900,800,900,768,900,857,800,900,800,768,768,880,768,735,1200,785,800,800,900,1050,900,768,641,1024,800,800,800,800,900,800,864,1024,800,900,800,1024,900,800,800,900,800,1024,900,768,768,800,800,900,768,800,768,800,900,800,800,880,800,900,900,1050,900,900,550,800,990,800,800,800,768,768,900,800,1024,1080,768,768,900,698,900,737,768,640,800,900,800,800,800,900,800,768,768,864,768,768,768,1050,1050,800,768,768,900,768,800,800,800,768,800) > x <- c(1280,1024,1120,1024,1280,1280,1280,1024,1280,1280,1280,1280,1280,1688,1440,1600,1280,1280,1280,1176,1280,1503,1440,1366,1280,1024,1280,2560,1280,1024,1280,1280,1440,1280,1440,1024,1440,1143,1280,1440,1280,1366,1024,1408,1366,1176,1920,1257,1280,1280,1440,1680,1440,1024,1140,1280,1280,1280,1280,1280,1440,1280,1152,1280,1280,1440,1280,1280,1440,1280,1280,1440,1280,1280,1600,1024,1366,1280,1280,1440,1366,1280,1024,1280,1440,1280,1280,1408,1280,1600,1600,1680,1440,1440,917,1280,1760,1280,1280,1280,1024,1366,1440,1280,1280,1920,1024,1024,1600,1117,1440,983,1024,1024,1280,1440,1280,1280,1280,1440,1280,1024,1024,1152,1280,1024,1366,1680,1680,1280,1366,1024,1440,1024,1280,1280,1280,1024,1280) > ylab = 'y' > xlab = 'x' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), Box-Cox Linearity Plot (v1.0.5) 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 > # > 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.6575490 0.6579562 0.6583638 0.6587716 0.6591797 0.6595881 0.6599967 [8] 0.6604056 0.6608148 0.6612242 0.6616339 0.6620438 0.6624540 0.6628644 [15] 0.6632750 0.6636859 0.6640970 0.6645083 0.6649199 0.6653317 0.6657437 [22] 0.6661560 0.6665684 0.6669811 0.6673939 0.6678070 0.6682203 0.6686338 [29] 0.6690474 0.6694613 0.6698753 0.6702895 0.6707039 0.6711185 0.6715332 [36] 0.6719481 0.6723632 0.6727784 0.6731938 0.6736093 0.6740250 0.6744408 [43] 0.6748568 0.6752729 0.6756891 0.6761055 0.6765219 0.6769385 0.6773552 [50] 0.6777721 0.6781890 0.6786060 0.6790231 0.6794403 0.6798576 0.6802750 [57] 0.6806925 0.6811100 0.6815276 0.6819453 0.6823631 0.6827808 0.6831987 [64] 0.6836166 0.6840345 0.6844525 0.6848705 0.6852885 0.6857065 0.6861246 [71] 0.6865426 0.6869607 0.6873788 0.6877969 0.6882149 0.6886330 0.6890510 [78] 0.6894690 0.6898870 0.6903049 0.6907228 0.6911407 0.6915585 0.6919762 [85] 0.6923939 0.6928115 0.6932291 0.6936465 0.6940639 0.6944812 0.6948983 [92] 0.6953154 0.6957324 0.6961492 0.6965659 0.6969825 0.6973990 0.6978153 [99] 0.6982315 0.6986475 0.6990634 0.6994791 0.6998946 0.7003100 0.7007252 [106] 0.7011401 0.7015549 0.7019695 0.7023839 0.7027980 0.7032119 0.7036256 [113] 0.7040391 0.7044523 0.7048653 0.7052780 0.7056904 0.7061026 0.7065144 [120] 0.7069260 0.7073374 0.7077484 0.7081591 0.7085694 0.7089795 0.7093892 [127] 0.7097986 0.7102077 0.7106164 0.7110247 0.7114327 0.7118403 0.7122475 [134] 0.7126543 0.7130607 0.7134667 0.7138723 0.7142775 0.7146823 0.7150866 [141] 0.7154904 0.7158939 0.7162968 0.7166993 0.7171013 0.7175028 0.7179038 [148] 0.7183043 0.7187043 0.7191038 0.7195027 0.7199012 0.7202990 0.7206963 [155] 0.7210931 0.7214893 0.7218849 0.7222799 0.7226743 0.7230681 0.7234612 [162] 0.7238538 0.7242457 0.7246370 0.7250276 0.7254175 0.7258068 0.7261954 [169] 0.7265833 0.7269706 0.7273571 0.7277428 0.7281279 0.7285122 0.7288958 [176] 0.7292786 0.7296606 0.7300419 0.7304224 0.7308021 0.7311810 0.7315590 [183] 0.7319363 0.7323127 0.7326882 0.7330629 0.7334368 0.7338097 0.7341818 [190] 0.7345529 0.7349232 0.7352926 0.7356610 0.7360285 0.7363950 0.7367606 [197] 0.7371252 0.7374888 0.7378514 0.7382130 0.7385737 0.7389332 0.7392918 [204] 0.7396493 0.7400058 0.7403612 0.7407155 0.7410687 0.7414208 0.7417719 [211] 0.7421217 0.7424705 0.7428181 0.7431646 0.7435099 0.7438540 0.7441969 [218] 0.7445387 0.7448792 0.7452185 0.7455566 0.7458934 0.7462289 0.7465632 [225] 0.7468962 0.7472280 0.7475584 0.7478875 0.7482153 0.7485417 0.7488668 [232] 0.7491905 0.7495129 0.7498339 0.7501535 0.7504716 0.7507884 0.7511037 [239] 0.7514176 0.7517300 0.7520410 0.7523504 0.7526584 0.7529649 0.7532699 [246] 0.7535733 0.7538752 0.7541756 0.7544743 0.7547716 0.7550672 0.7553612 [253] 0.7556536 0.7559444 0.7562336 0.7565211 0.7568070 0.7570911 0.7573736 [260] 0.7576545 0.7579336 0.7582109 0.7584866 0.7587605 0.7590326 0.7593030 [267] 0.7595716 0.7598384 0.7601034 0.7603666 0.7606280 0.7608875 0.7611451 [274] 0.7614009 0.7616549 0.7619069 0.7621570 0.7624053 0.7626516 0.7628959 [281] 0.7631383 0.7633788 0.7636172 0.7638537 0.7640882 0.7643207 0.7645512 [288] 0.7647796 0.7650060 0.7652303 0.7654526 0.7656728 0.7658909 0.7661069 [295] 0.7663207 0.7665325 0.7667421 0.7669495 0.7671548 0.7673580 0.7675589 [302] 0.7677576 0.7679542 0.7681485 0.7683406 0.7685304 0.7687180 0.7689034 [309] 0.7690864 0.7692672 0.7694456 0.7696218 0.7697956 0.7699672 0.7701363 [316] 0.7703032 0.7704676 0.7706297 0.7707894 0.7709467 0.7711016 0.7712541 [323] 0.7714041 0.7715518 0.7716969 0.7718396 0.7719799 0.7721177 0.7722529 [330] 0.7723857 0.7725160 0.7726438 0.7727690 0.7728917 0.7730119 0.7731295 [337] 0.7732445 0.7733569 0.7734668 0.7735741 0.7736788 0.7737808 0.7738803 [344] 0.7739771 0.7740713 0.7741628 0.7742517 0.7743379 0.7744214 0.7745023 [351] 0.7745805 0.7746560 0.7747287 0.7747988 0.7748661 0.7749307 0.7749926 [358] 0.7750517 0.7751081 0.7751617 0.7752126 0.7752607 0.7753060 0.7753485 [365] 0.7753882 0.7754251 0.7754592 0.7754905 0.7755190 0.7755447 0.7755675 [372] 0.7755875 0.7756046 0.7756189 0.7756304 0.7756390 0.7756447 0.7756475 [379] 0.7756475 0.7756446 0.7756388 0.7756301 0.7756185 0.7756040 0.7755866 [386] 0.7755663 0.7755431 0.7755170 0.7754879 0.7754559 0.7754210 0.7753832 [393] 0.7753424 0.7752987 0.7752521 0.7752025 0.7751499 0.7750944 0.7750360 [400] 0.7749746 0.7749102 > mx [1] 0.7756475 > mxli [1] 1.77 > 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/wessaorg/rcomp/tmp/15rv91380899625.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/27bl71380899625.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3h9bm1380899625.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/46zto1380899625.tab") > > try(system("convert tmp/15rv91380899625.ps tmp/15rv91380899625.png",intern=TRUE)) character(0) > try(system("convert tmp/27bl71380899625.ps tmp/27bl71380899625.png",intern=TRUE)) character(0) > try(system("convert tmp/3h9bm1380899625.ps tmp/3h9bm1380899625.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.866 0.359 2.206