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(103.2,102.9,102.6,102.3,102.1,101.5,101.1,101.9,101.5,101.5,102.0,101.5,101.6,101.5,101.9,102.0,102.0,102.2,102.2,102.3,102.0,101.8,101.8,101.6,101.9,102.3,102.4,102.1,102.3,102.2) > x <- c(103.0,103.5,103.9,104.4,103.5,104.7,101.6,102.3,101.2,101.4,102.7,101.5,102.1,100.5,101.7,103.6,103.2,101.7,105.6,103.7,104.3,105.9,104.8,106.0,105.6,106.7,103.3,103.0,101.6,101.7) > #'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.2304761 0.2304419 0.2304076 0.2303734 0.2303391 0.2303049 0.2302707 [8] 0.2302364 0.2302022 0.2301679 0.2301337 0.2300994 0.2300652 0.2300309 [15] 0.2299967 0.2299625 0.2299282 0.2298940 0.2298597 0.2298255 0.2297912 [22] 0.2297570 0.2297227 0.2296885 0.2296542 0.2296200 0.2295857 0.2295515 [29] 0.2295172 0.2294830 0.2294487 0.2294145 0.2293802 0.2293460 0.2293117 [36] 0.2292775 0.2292432 0.2292090 0.2291747 0.2291404 0.2291062 0.2290719 [43] 0.2290377 0.2290034 0.2289692 0.2289349 0.2289007 0.2288664 0.2288321 [50] 0.2287979 0.2287636 0.2287294 0.2286951 0.2286609 0.2286266 0.2285923 [57] 0.2285581 0.2285238 0.2284896 0.2284553 0.2284210 0.2283868 0.2283525 [64] 0.2283183 0.2282840 0.2282497 0.2282155 0.2281812 0.2281469 0.2281127 [71] 0.2280784 0.2280442 0.2280099 0.2279756 0.2279414 0.2279071 0.2278728 [78] 0.2278386 0.2278043 0.2277700 0.2277358 0.2277015 0.2276672 0.2276330 [85] 0.2275987 0.2275644 0.2275302 0.2274959 0.2274616 0.2274274 0.2273931 [92] 0.2273588 0.2273246 0.2272903 0.2272560 0.2272218 0.2271875 0.2271532 [99] 0.2271189 0.2270847 0.2270504 0.2270161 0.2269819 0.2269476 0.2269133 [106] 0.2268790 0.2268448 0.2268105 0.2267762 0.2267420 0.2267077 0.2266734 [113] 0.2266391 0.2266049 0.2265706 0.2265363 0.2265020 0.2264678 0.2264335 [120] 0.2263992 0.2263649 0.2263307 0.2262964 0.2262621 0.2262278 0.2261936 [127] 0.2261593 0.2261250 0.2260907 0.2260565 0.2260222 0.2259879 0.2259536 [134] 0.2259193 0.2258851 0.2258508 0.2258165 0.2257822 0.2257480 0.2257137 [141] 0.2256794 0.2256451 0.2256108 0.2255766 0.2255423 0.2255080 0.2254737 [148] 0.2254394 0.2254052 0.2253709 0.2253366 0.2253023 0.2252680 0.2252338 [155] 0.2251995 0.2251652 0.2251309 0.2250966 0.2250623 0.2250281 0.2249938 [162] 0.2249595 0.2249252 0.2248909 0.2248566 0.2248224 0.2247881 0.2247538 [169] 0.2247195 0.2246852 0.2246509 0.2246167 0.2245824 0.2245481 0.2245138 [176] 0.2244795 0.2244452 0.2244110 0.2243767 0.2243424 0.2243081 0.2242738 [183] 0.2242395 0.2242052 0.2241710 0.2241367 0.2241024 0.2240681 0.2240338 [190] 0.2239995 0.2239652 0.2239310 0.2238967 0.2238624 0.2238281 0.2237938 [197] 0.2237595 0.2237252 0.2236910 0.2236567 0.2236224 0.2235881 0.2235538 [204] 0.2235195 0.2234852 0.2234509 0.2234167 0.2233824 0.2233481 0.2233138 [211] 0.2232795 0.2232452 0.2232109 0.2231766 0.2231424 0.2231081 0.2230738 [218] 0.2230395 0.2230052 0.2229709 0.2229366 0.2229023 0.2228680 0.2228338 [225] 0.2227995 0.2227652 0.2227309 0.2226966 0.2226623 0.2226280 0.2225937 [232] 0.2225594 0.2225252 0.2224909 0.2224566 0.2224223 0.2223880 0.2223537 [239] 0.2223194 0.2222851 0.2222508 0.2222166 0.2221823 0.2221480 0.2221137 [246] 0.2220794 0.2220451 0.2220108 0.2219765 0.2219422 0.2219079 0.2218737 [253] 0.2218394 0.2218051 0.2217708 0.2217365 0.2217022 0.2216679 0.2216336 [260] 0.2215993 0.2215651 0.2215308 0.2214965 0.2214622 0.2214279 0.2213936 [267] 0.2213593 0.2213250 0.2212907 0.2212564 0.2212222 0.2211879 0.2211536 [274] 0.2211193 0.2210850 0.2210507 0.2210164 0.2209821 0.2209478 0.2209135 [281] 0.2208793 0.2208450 0.2208107 0.2207764 0.2207421 0.2207078 0.2206735 [288] 0.2206392 0.2206049 0.2205707 0.2205364 0.2205021 0.2204678 0.2204335 [295] 0.2203992 0.2203649 0.2203306 0.2202963 0.2202621 0.2202278 0.2201935 [302] 0.2201592 0.2201249 0.2200906 0.2200563 0.2200220 0.2199877 0.2199535 [309] 0.2199192 0.2198849 0.2198506 0.2198163 0.2197820 0.2197477 0.2197134 [316] 0.2196792 0.2196449 0.2196106 0.2195763 0.2195420 0.2195077 0.2194734 [323] 0.2194391 0.2194049 0.2193706 0.2193363 0.2193020 0.2192677 0.2192334 [330] 0.2191991 0.2191648 0.2191306 0.2190963 0.2190620 0.2190277 0.2189934 [337] 0.2189591 0.2189248 0.2188906 0.2188563 0.2188220 0.2187877 0.2187534 [344] 0.2187191 0.2186848 0.2186506 0.2186163 0.2185820 0.2185477 0.2185134 [351] 0.2184791 0.2184449 0.2184106 0.2183763 0.2183420 0.2183077 0.2182734 [358] 0.2182392 0.2182049 0.2181706 0.2181363 0.2181020 0.2180677 0.2180335 [365] 0.2179992 0.2179649 0.2179306 0.2178963 0.2178621 0.2178278 0.2177935 [372] 0.2177592 0.2177249 0.2176906 0.2176564 0.2176221 0.2175878 0.2175535 [379] 0.2175192 0.2174850 0.2174507 0.2174164 0.2173821 0.2173478 0.2173136 [386] 0.2172793 0.2172450 0.2172107 0.2171765 0.2171422 0.2171079 0.2170736 [393] 0.2170393 0.2170051 0.2169708 0.2169365 0.2169022 0.2168680 0.2168337 [400] 0.2167994 0.2167651 > mx [1] 0.2304761 > 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/1lwru1226590958.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/2c0ll1226590958.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/3ctfl1226590958.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/4ei761226590958.tab") > > system("convert tmp/1lwru1226590958.ps tmp/1lwru1226590958.png") > system("convert tmp/2c0ll1226590958.ps tmp/2c0ll1226590958.png") > system("convert tmp/3ctfl1226590958.ps tmp/3ctfl1226590958.png") > > > proc.time() user system elapsed 1.093 0.569 1.600