R version 2.8.1 (2008-12-22) 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(10.9,10.6,10.3,10.3,10.3,10.4,10.5,10.4,10.6,10.5,10.5,10.5,10.5,10.5,10.5,10.5,10.5,10.5,10.5,10.5,10.6,10.4,10.1,10,10,10,10,9.9,9.8,9.8,9.9,10.1,10,9.6,9.3,9,8.8,9,9.1,9.2,9.1,8.9,8.7,8.7,8.6,8.9,9.3,9.5,9.3,9.1,8.9,9.1,9.5,9.7,9.8,9.8,9.7,9.7,9.8,9.9) > x <- c(4.86,4.55,4.27,4.26,4.57,5.07,4.76,4.51,4.87,5.14,5.11,5.16,4.47,4.57,4.89,4.63,4.38,3.69,3.96,4.19,3.87,3.6,3.63,3.22,3.21,3.49,3.64,3.66,3.77,3.82,3.78,3.28,3.29,3.37,3.12,3.51,4.24,4.94,5.09,5.46,5.64,6.39,6.15,7.21,7.8,7.91,7.39,7.46,6.72,5.14,4.63,4.32,3.93,2.62,2.6,1.63,0.9,0.32,1.22,0.81) > #'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] 2.691713e-02 2.682863e-02 2.673783e-02 2.664467e-02 2.654911e-02 [6] 2.645109e-02 2.635056e-02 2.624746e-02 2.614174e-02 2.603334e-02 [11] 2.592221e-02 2.580828e-02 2.569151e-02 2.557182e-02 2.544916e-02 [16] 2.532347e-02 2.519468e-02 2.506272e-02 2.492754e-02 2.478907e-02 [21] 2.464724e-02 2.450198e-02 2.435322e-02 2.420090e-02 2.404494e-02 [26] 2.388527e-02 2.372181e-02 2.355450e-02 2.338325e-02 2.320799e-02 [31] 2.302865e-02 2.284513e-02 2.265737e-02 2.246529e-02 2.226879e-02 [36] 2.206781e-02 2.186224e-02 2.165202e-02 2.143705e-02 2.121725e-02 [41] 2.099252e-02 2.076279e-02 2.052795e-02 2.028792e-02 2.004261e-02 [46] 1.979192e-02 1.953576e-02 1.927403e-02 1.900664e-02 1.873349e-02 [51] 1.845449e-02 1.816953e-02 1.787851e-02 1.758134e-02 1.727791e-02 [56] 1.696813e-02 1.665188e-02 1.632907e-02 1.599959e-02 1.566333e-02 [61] 1.532020e-02 1.497008e-02 1.461286e-02 1.424845e-02 1.387673e-02 [66] 1.349759e-02 1.311092e-02 1.271662e-02 1.231458e-02 1.190468e-02 [71] 1.148681e-02 1.106087e-02 1.062674e-02 1.018431e-02 9.733471e-03 [76] 9.274112e-03 8.806121e-03 8.329386e-03 7.843797e-03 7.349243e-03 [81] 6.845612e-03 6.332795e-03 5.810681e-03 5.279160e-03 4.738124e-03 [86] 4.187462e-03 3.627068e-03 3.056834e-03 2.476652e-03 1.886417e-03 [91] 1.286024e-03 6.753683e-04 5.434682e-05 -5.771424e-04 -1.219200e-03 [96] -1.871927e-03 -2.535420e-03 -3.209777e-03 -3.895094e-03 -4.591464e-03 [101] -5.298979e-03 -6.017731e-03 -6.747808e-03 -7.489298e-03 -8.242285e-03 [106] -9.006852e-03 -9.783080e-03 -1.057105e-02 -1.137083e-02 -1.218251e-02 [111] -1.300615e-02 -1.384182e-02 -1.468959e-02 -1.554952e-02 -1.642167e-02 [116] -1.730611e-02 -1.820288e-02 -1.911204e-02 -2.003364e-02 -2.096773e-02 [121] -2.191435e-02 -2.287354e-02 -2.384533e-02 -2.482976e-02 -2.582686e-02 [126] -2.683666e-02 -2.785917e-02 -2.889442e-02 -2.994242e-02 -3.100319e-02 [131] -3.207673e-02 -3.316305e-02 -3.426214e-02 -3.537400e-02 -3.649863e-02 [136] -3.763602e-02 -3.878614e-02 -3.994898e-02 -4.112451e-02 -4.231271e-02 [141] -4.351355e-02 -4.472698e-02 -4.595297e-02 -4.719147e-02 -4.844243e-02 [146] -4.970581e-02 -5.098154e-02 -5.226956e-02 -5.356981e-02 -5.488221e-02 [151] -5.620670e-02 -5.754318e-02 -5.889160e-02 -6.025184e-02 -6.162383e-02 [156] -6.300747e-02 -6.440267e-02 -6.580931e-02 -6.722729e-02 -6.865650e-02 [161] -7.009683e-02 -7.154816e-02 -7.301037e-02 -7.448332e-02 -7.596690e-02 [166] -7.746097e-02 -7.896539e-02 -8.048002e-02 -8.200472e-02 -8.353934e-02 [171] -8.508373e-02 -8.663775e-02 -8.820122e-02 -8.977400e-02 -9.135593e-02 [176] -9.294683e-02 -9.454654e-02 -9.615489e-02 -9.777171e-02 -9.939682e-02 [181] -1.010300e-01 -1.026712e-01 -1.043201e-01 -1.059766e-01 -1.076405e-01 [186] -1.093115e-01 -1.109896e-01 -1.126745e-01 -1.143660e-01 -1.160639e-01 [191] -1.177681e-01 -1.194783e-01 -1.211944e-01 -1.229161e-01 -1.246432e-01 [196] -1.263756e-01 -1.281130e-01 -1.298553e-01 -1.316022e-01 -1.333535e-01 [201] -1.351091e-01 -1.368686e-01 -1.386321e-01 -1.403991e-01 -1.421696e-01 [206] -1.439433e-01 -1.457200e-01 -1.474995e-01 -1.492816e-01 -1.510662e-01 [211] -1.528529e-01 -1.546417e-01 -1.564323e-01 -1.582245e-01 -1.600182e-01 [216] -1.618130e-01 -1.636089e-01 -1.654057e-01 -1.672031e-01 -1.690009e-01 [221] -1.707990e-01 -1.725972e-01 -1.743954e-01 -1.761932e-01 -1.779906e-01 [226] -1.797873e-01 -1.815832e-01 -1.833781e-01 -1.851718e-01 -1.869642e-01 [231] -1.887550e-01 -1.905442e-01 -1.923316e-01 -1.941169e-01 -1.959000e-01 [236] -1.976808e-01 -1.994592e-01 -2.012349e-01 -2.030077e-01 -2.047777e-01 [241] -2.065445e-01 -2.083081e-01 -2.100683e-01 -2.118250e-01 -2.135781e-01 [246] -2.153273e-01 -2.170727e-01 -2.188139e-01 -2.205510e-01 -2.222838e-01 [251] -2.240121e-01 -2.257359e-01 -2.274551e-01 -2.291694e-01 -2.308789e-01 [256] -2.325833e-01 -2.342827e-01 -2.359768e-01 -2.376656e-01 -2.393490e-01 [261] -2.410269e-01 -2.426992e-01 -2.443658e-01 -2.460266e-01 -2.476815e-01 [266] -2.493305e-01 -2.509735e-01 -2.526103e-01 -2.542409e-01 -2.558653e-01 [271] -2.574833e-01 -2.590949e-01 -2.607000e-01 -2.622986e-01 -2.638906e-01 [276] -2.654759e-01 -2.670545e-01 -2.686263e-01 -2.701913e-01 -2.717493e-01 [281] -2.733005e-01 -2.748446e-01 -2.763818e-01 -2.779118e-01 -2.794348e-01 [286] -2.809506e-01 -2.824591e-01 -2.839605e-01 -2.854546e-01 -2.869414e-01 [291] -2.884209e-01 -2.898930e-01 -2.913578e-01 -2.928151e-01 -2.942650e-01 [296] -2.957075e-01 -2.971425e-01 -2.985700e-01 -2.999900e-01 -3.014025e-01 [301] -3.028074e-01 -3.042048e-01 -3.055947e-01 -3.069770e-01 -3.083517e-01 [306] -3.097188e-01 -3.110784e-01 -3.124303e-01 -3.137747e-01 -3.151115e-01 [311] -3.164406e-01 -3.177622e-01 -3.190762e-01 -3.203826e-01 -3.216814e-01 [316] -3.229727e-01 -3.242564e-01 -3.255325e-01 -3.268011e-01 -3.280621e-01 [321] -3.293156e-01 -3.305615e-01 -3.318000e-01 -3.330309e-01 -3.342544e-01 [326] -3.354704e-01 -3.366789e-01 -3.378800e-01 -3.390737e-01 -3.402600e-01 [331] -3.414389e-01 -3.426104e-01 -3.437746e-01 -3.449314e-01 -3.460810e-01 [336] -3.472233e-01 -3.483583e-01 -3.494860e-01 -3.506066e-01 -3.517200e-01 [341] -3.528262e-01 -3.539252e-01 -3.550171e-01 -3.561020e-01 -3.571798e-01 [346] -3.582505e-01 -3.593142e-01 -3.603710e-01 -3.614208e-01 -3.624636e-01 [351] -3.634996e-01 -3.645286e-01 -3.655509e-01 -3.665663e-01 -3.675749e-01 [356] -3.685768e-01 -3.695719e-01 -3.705604e-01 -3.715422e-01 -3.725173e-01 [361] -3.734859e-01 -3.744478e-01 -3.754033e-01 -3.763522e-01 -3.772946e-01 [366] -3.782306e-01 -3.791601e-01 -3.800833e-01 -3.810001e-01 -3.819106e-01 [371] -3.828148e-01 -3.837127e-01 -3.846044e-01 -3.854899e-01 -3.863693e-01 [376] -3.872425e-01 -3.881096e-01 -3.889707e-01 -3.898257e-01 -3.906747e-01 [381] -3.915177e-01 -3.923548e-01 -3.931860e-01 -3.940114e-01 -3.948308e-01 [386] -3.956445e-01 -3.964524e-01 -3.972546e-01 -3.980510e-01 -3.988418e-01 [391] -3.996269e-01 -4.004064e-01 -4.011803e-01 -4.019486e-01 -4.027114e-01 [396] -4.034688e-01 -4.042207e-01 -4.049671e-01 -4.057082e-01 -4.064439e-01 [401] -4.071743e-01 > mx [1] 0.4071743 > 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/rcomp/tmp/1a8pk1257943189.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/rcomp/tmp/2ctnh1257943189.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/rcomp/tmp/3whpj1257943189.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4096z1257943189.tab") > > system("convert tmp/1a8pk1257943189.ps tmp/1a8pk1257943189.png") > system("convert tmp/2ctnh1257943189.ps tmp/2ctnh1257943189.png") > system("convert tmp/3whpj1257943189.ps tmp/3whpj1257943189.png") > > > proc.time() user system elapsed 0.920 0.770 1.525