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(13.5,16.2,17.6,15.8,17.6,15.2,15.9,12.0,13.3,14.8,16.1,16.9,17.6,13.9,10.0,7.6,7.1,8.1,8.1,7.7,4.0,1.4,0.3,-1.0,-1.9,-1.5,-0.2,3.4,3.0,4.1,3.4,3.2,6.1,5.8,6.2,5.8,5.9,6.7,5.9,3.8,1.7,1.4,1.8,3.0,3.6,4.8,4.3,4.2,2.9,4.9,7.2,8.7,9.1,8.9,9.0,11.6,9.6,9.1,9.2,10.8,11.0,8.5,6.5,7.2,7.8,8.7,7.8,7.5,7.7,7.5,8.3,7.9,10.4,11.5,14.0,11.9,11.9,10.3,11.3,9.9,8.9,9.2,8.8,6.7,7.1,6.6,7.2,5.0,5.3,6.3) > x <- c(7.3,7.2,7.1,6.9,6.8,6.7,6.8,6.8,6.7,6.8,6.8,6.7,6.3,6.2,6.2,6.5,6.5,6.4,6.2,6.2,6.3,7.5,7.4,7.4,7.4,7.4,7.4,7.2,7.2,7.2,7.5,7.4,7.5,8.0,8.0,8.0,8.1,8.1,8.1,7.9,7.9,8.0,8.2,8.1,8.2,8.5,8.5,8.6,8.4,8.4,8.4,7.7,7.8,7.9,8.8,8.8,8.9,8.5,8.5,8.5,8.4,8.5,8.4,8.3,8.4,8.4,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.3,8.3,8.3,8.2,8.1,8.1,8.2,8.0,7.9,7.9,7.8,7.7,7.9,7.7,7.6) > #'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.2594200 -0.2593197 -0.2592191 -0.2591184 -0.2590175 -0.2589165 [7] -0.2588153 -0.2587139 -0.2586123 -0.2585106 -0.2584087 -0.2583067 [13] -0.2582045 -0.2581021 -0.2579995 -0.2578968 -0.2577939 -0.2576909 [19] -0.2575877 -0.2574843 -0.2573808 -0.2572771 -0.2571732 -0.2570692 [25] -0.2569650 -0.2568606 -0.2567561 -0.2566514 -0.2565465 -0.2564415 [31] -0.2563363 -0.2562310 -0.2561255 -0.2560198 -0.2559140 -0.2558080 [37] -0.2557018 -0.2555955 -0.2554890 -0.2553824 -0.2552756 -0.2551686 [43] -0.2550615 -0.2549542 -0.2548467 -0.2547391 -0.2546314 -0.2545234 [49] -0.2544153 -0.2543071 -0.2541987 -0.2540901 -0.2539814 -0.2538725 [55] -0.2537634 -0.2536542 -0.2535448 -0.2534353 -0.2533256 -0.2532158 [61] -0.2531058 -0.2529956 -0.2528853 -0.2527748 -0.2526642 -0.2525534 [67] -0.2524424 -0.2523313 -0.2522200 -0.2521086 -0.2519970 -0.2518853 [73] -0.2517734 -0.2516614 -0.2515492 -0.2514368 -0.2513243 -0.2512116 [79] -0.2510988 -0.2509858 -0.2508727 -0.2507594 -0.2506459 -0.2505323 [85] -0.2504186 -0.2503047 -0.2501906 -0.2500764 -0.2499620 -0.2498475 [91] -0.2497328 -0.2496180 -0.2495030 -0.2493879 -0.2492726 -0.2491572 [97] -0.2490416 -0.2489259 -0.2488100 -0.2486939 -0.2485777 -0.2484614 [103] -0.2483449 -0.2482283 -0.2481115 -0.2479945 -0.2478774 -0.2477602 [109] -0.2476428 -0.2475253 -0.2474076 -0.2472897 -0.2471717 -0.2470536 [115] -0.2469353 -0.2468169 -0.2466983 -0.2465796 -0.2464607 -0.2463417 [121] -0.2462225 -0.2461032 -0.2459837 -0.2458641 -0.2457444 -0.2456245 [127] -0.2455044 -0.2453842 -0.2452639 -0.2451434 -0.2450228 -0.2449020 [133] -0.2447811 -0.2446600 -0.2445388 -0.2444175 -0.2442960 -0.2441743 [139] -0.2440526 -0.2439306 -0.2438086 -0.2436864 -0.2435640 -0.2434415 [145] -0.2433189 -0.2431961 -0.2430732 -0.2429501 -0.2428269 -0.2427036 [151] -0.2425801 -0.2424565 -0.2423327 -0.2422088 -0.2420848 -0.2419606 [157] -0.2418363 -0.2417118 -0.2415872 -0.2414625 -0.2413376 -0.2412126 [163] -0.2410874 -0.2409621 -0.2408367 -0.2407111 -0.2405854 -0.2404596 [169] -0.2403336 -0.2402075 -0.2400812 -0.2399549 -0.2398283 -0.2397017 [175] -0.2395749 -0.2394479 -0.2393209 -0.2391937 -0.2390664 -0.2389389 [181] -0.2388113 -0.2386836 -0.2385557 -0.2384277 -0.2382995 -0.2381713 [187] -0.2380429 -0.2379143 -0.2377857 -0.2376569 -0.2375280 -0.2373989 [193] -0.2372697 -0.2371404 -0.2370109 -0.2368813 -0.2367516 -0.2366218 [199] -0.2364918 -0.2363617 -0.2362315 -0.2361011 -0.2359706 -0.2358400 [205] -0.2357092 -0.2355784 -0.2354474 -0.2353162 -0.2351850 -0.2350536 [211] -0.2349221 -0.2347904 -0.2346587 -0.2345268 -0.2343947 -0.2342626 [217] -0.2341303 -0.2339979 -0.2338654 -0.2337328 -0.2336000 -0.2334671 [223] -0.2333341 -0.2332009 -0.2330677 -0.2329343 -0.2328008 -0.2326671 [229] -0.2325334 -0.2323995 -0.2322655 -0.2321313 -0.2319971 -0.2318627 [235] -0.2317282 -0.2315936 -0.2314589 -0.2313240 -0.2311891 -0.2310540 [241] -0.2309188 -0.2307834 -0.2306480 -0.2305124 -0.2303767 -0.2302409 [247] -0.2301050 -0.2299689 -0.2298328 -0.2296965 -0.2295601 -0.2294236 [253] -0.2292869 -0.2291502 -0.2290133 -0.2288764 -0.2287393 -0.2286021 [259] -0.2284647 -0.2283273 -0.2281897 -0.2280521 -0.2279143 -0.2277764 [265] -0.2276384 -0.2275002 -0.2273620 -0.2272236 -0.2270852 -0.2269466 [271] -0.2268079 -0.2266691 -0.2265302 -0.2263912 -0.2262520 -0.2261128 [277] -0.2259734 -0.2258340 -0.2256944 -0.2255547 -0.2254149 -0.2252750 [283] -0.2251350 -0.2249949 -0.2248546 -0.2247143 -0.2245738 -0.2244333 [289] -0.2242926 -0.2241518 -0.2240110 -0.2238700 -0.2237289 -0.2235877 [295] -0.2234464 -0.2233050 -0.2231635 -0.2230218 -0.2228801 -0.2227383 [301] -0.2225963 -0.2224543 -0.2223122 -0.2221699 -0.2220276 -0.2218851 [307] -0.2217425 -0.2215999 -0.2214571 -0.2213143 -0.2211713 -0.2210282 [313] -0.2208851 -0.2207418 -0.2205984 -0.2204549 -0.2203114 -0.2201677 [319] -0.2200239 -0.2198801 -0.2197361 -0.2195920 -0.2194479 -0.2193036 [325] -0.2191592 -0.2190148 -0.2188702 -0.2187255 -0.2185808 -0.2184359 [331] -0.2182910 -0.2181460 -0.2180008 -0.2178556 -0.2177102 -0.2175648 [337] -0.2174193 -0.2172737 -0.2171280 -0.2169822 -0.2168363 -0.2166903 [343] -0.2165442 -0.2163980 -0.2162517 -0.2161054 -0.2159589 -0.2158124 [349] -0.2156657 -0.2155190 -0.2153722 -0.2152253 -0.2150783 -0.2149312 [355] -0.2147840 -0.2146367 -0.2144893 -0.2143419 -0.2141943 -0.2140467 [361] -0.2138990 -0.2137512 -0.2136033 -0.2134553 -0.2133072 -0.2131591 [367] -0.2130108 -0.2128625 -0.2127141 -0.2125656 -0.2124170 -0.2122683 [373] -0.2121196 -0.2119707 -0.2118218 -0.2116728 -0.2115237 -0.2113745 [379] -0.2112252 -0.2110759 -0.2109264 -0.2107769 -0.2106273 -0.2104776 [385] -0.2103279 -0.2101780 -0.2100281 -0.2098781 -0.2097280 -0.2095778 [391] -0.2094276 -0.2092772 -0.2091268 -0.2089763 -0.2088258 -0.2086751 [397] -0.2085244 -0.2083736 -0.2082227 -0.2080717 -0.2079207 > mx [1] 0.2594200 > 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/1zuu41199649132.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/24vdv1199649132.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/3m2gq1199649132.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/4iapw1199649132.tab") > > system("convert tmp/1zuu41199649132.ps tmp/1zuu41199649132.png") > system("convert tmp/24vdv1199649132.ps tmp/24vdv1199649132.png") > system("convert tmp/3m2gq1199649132.ps tmp/3m2gq1199649132.png") > > > proc.time() user system elapsed 1.011 0.496 1.144