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(2529,2196,3202,2718,2728,2354,2697,2651,2067,2641,2539,2294,2712,2314,3092,2677,2813,2668,2939,2617,2231,2481,2421,2408,2560,2100,3315,2801,2403,3024,2507,2980,2211,2471,2594,2452,2232,2373,3127,2802,2641,2787,2619,2806,2193,2323,2529,2412,2262,2154,3230,2295,2715,2733,2317,2730,1913,2390,2484,1960) > x <- c(22,27,24,24,22,23,25,23,21,21,22,20,22,22,20,21,20,21,21,21,19,21,21,22,19,24,22,22,22,24,22,23,24,21,20,22,23,23,22,20,21,21,20,20,17,18,19,19,20,21,20,21,19,22,20,18,16,17,18,19) > #'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.2503715 0.2501885 0.2500053 0.2498219 0.2496384 0.2494546 0.2492707 [8] 0.2490866 0.2489022 0.2487178 0.2485331 0.2483482 0.2481632 0.2479780 [15] 0.2477925 0.2476070 0.2474212 0.2472352 0.2470491 0.2468628 0.2466763 [22] 0.2464896 0.2463027 0.2461156 0.2459284 0.2457410 0.2455534 0.2453656 [29] 0.2451777 0.2449896 0.2448012 0.2446127 0.2444241 0.2442352 0.2440462 [36] 0.2438570 0.2436676 0.2434780 0.2432883 0.2430984 0.2429083 0.2427180 [43] 0.2425275 0.2423369 0.2421461 0.2419551 0.2417639 0.2415726 0.2413811 [50] 0.2411894 0.2409976 0.2408055 0.2406133 0.2404209 0.2402284 0.2400356 [57] 0.2398427 0.2396496 0.2394564 0.2392629 0.2390693 0.2388756 0.2386816 [64] 0.2384875 0.2382932 0.2380988 0.2379041 0.2377093 0.2375143 0.2373192 [71] 0.2371239 0.2369284 0.2367327 0.2365369 0.2363409 0.2361448 0.2359484 [78] 0.2357519 0.2355553 0.2353584 0.2351614 0.2349642 0.2347669 0.2345694 [85] 0.2343717 0.2341739 0.2339759 0.2337777 0.2335794 0.2333809 0.2331822 [92] 0.2329834 0.2327844 0.2325852 0.2323859 0.2321864 0.2319867 0.2317869 [99] 0.2315869 0.2313868 0.2311865 0.2309860 0.2307854 0.2305846 0.2303837 [106] 0.2301826 0.2299813 0.2297798 0.2295783 0.2293765 0.2291746 0.2289725 [113] 0.2287703 0.2285679 0.2283653 0.2281626 0.2279598 0.2277568 0.2275536 [120] 0.2273502 0.2271467 0.2269431 0.2267393 0.2265353 0.2263312 0.2261269 [127] 0.2259225 0.2257179 0.2255132 0.2253083 0.2251032 0.2248980 0.2246927 [134] 0.2244872 0.2242815 0.2240757 0.2238697 0.2236636 0.2234573 0.2232509 [141] 0.2230444 0.2228376 0.2226308 0.2224237 0.2222166 0.2220092 0.2218018 [148] 0.2215941 0.2213864 0.2211785 0.2209704 0.2207622 0.2205538 0.2203453 [155] 0.2201367 0.2199279 0.2197189 0.2195098 0.2193006 0.2190912 0.2188817 [162] 0.2186720 0.2184622 0.2182522 0.2180421 0.2178318 0.2176215 0.2174109 [169] 0.2172002 0.2169894 0.2167785 0.2165674 0.2163561 0.2161447 0.2159332 [176] 0.2157215 0.2155097 0.2152978 0.2150857 0.2148734 0.2146611 0.2144486 [183] 0.2142359 0.2140232 0.2138102 0.2135972 0.2133840 0.2131707 0.2129572 [190] 0.2127436 0.2125299 0.2123160 0.2121020 0.2118878 0.2116736 0.2114592 [197] 0.2112446 0.2110299 0.2108151 0.2106002 0.2103851 0.2101699 0.2099546 [204] 0.2097391 0.2095235 0.2093078 0.2090919 0.2088759 0.2086598 0.2084435 [211] 0.2082271 0.2080106 0.2077940 0.2075772 0.2073603 0.2071433 0.2069262 [218] 0.2067089 0.2064915 0.2062740 0.2060563 0.2058385 0.2056206 0.2054026 [225] 0.2051844 0.2049662 0.2047478 0.2045292 0.2043106 0.2040918 0.2038729 [232] 0.2036539 0.2034348 0.2032155 0.2029961 0.2027766 0.2025570 0.2023373 [239] 0.2021174 0.2018974 0.2016773 0.2014571 0.2012368 0.2010163 0.2007958 [246] 0.2005751 0.2003543 0.2001333 0.1999123 0.1996911 0.1994699 0.1992485 [253] 0.1990270 0.1988054 0.1985836 0.1983618 0.1981398 0.1979178 0.1976956 [260] 0.1974733 0.1972509 0.1970284 0.1968058 0.1965830 0.1963602 0.1961372 [267] 0.1959141 0.1956910 0.1954677 0.1952443 0.1950208 0.1947971 0.1945734 [274] 0.1943496 0.1941257 0.1939016 0.1936775 0.1934532 0.1932288 0.1930044 [281] 0.1927798 0.1925551 0.1923303 0.1921055 0.1918805 0.1916554 0.1914302 [288] 0.1912049 0.1909795 0.1907540 0.1905284 0.1903027 0.1900769 0.1898510 [295] 0.1896250 0.1893989 0.1891727 0.1889464 0.1887200 0.1884935 0.1882669 [302] 0.1880402 0.1878134 0.1875865 0.1873595 0.1871324 0.1869053 0.1866780 [309] 0.1864506 0.1862232 0.1859956 0.1857680 0.1855402 0.1853124 0.1850845 [316] 0.1848565 0.1846283 0.1844001 0.1841718 0.1839435 0.1837150 0.1834864 [323] 0.1832578 0.1830290 0.1828002 0.1825713 0.1823423 0.1821132 0.1818840 [330] 0.1816547 0.1814254 0.1811959 0.1809664 0.1807368 0.1805071 0.1802773 [337] 0.1800474 0.1798175 0.1795875 0.1793573 0.1791271 0.1788969 0.1786665 [344] 0.1784360 0.1782055 0.1779749 0.1777442 0.1775134 0.1772826 0.1770517 [351] 0.1768206 0.1765896 0.1763584 0.1761271 0.1758958 0.1756644 0.1754329 [358] 0.1752014 0.1749698 0.1747381 0.1745063 0.1742744 0.1740425 0.1738105 [365] 0.1735784 0.1733463 0.1731140 0.1728817 0.1726494 0.1724169 0.1721844 [372] 0.1719518 0.1717192 0.1714865 0.1712537 0.1710208 0.1707879 0.1705549 [379] 0.1703218 0.1700887 0.1698555 0.1696222 0.1693888 0.1691554 0.1689220 [386] 0.1686884 0.1684548 0.1682211 0.1679874 0.1677536 0.1675198 0.1672858 [393] 0.1670518 0.1668178 0.1665837 0.1663495 0.1661153 0.1658810 0.1656466 [400] 0.1654122 0.1651777 > mx [1] 0.2503715 > 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/1p6ix1193865225.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/2uonx1193865225.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/341ua1193865225.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/4lwyz1193865226.tab") > > system("convert tmp/1p6ix1193865225.ps tmp/1p6ix1193865225.png") > system("convert tmp/2uonx1193865225.ps tmp/2uonx1193865225.png") > system("convert tmp/341ua1193865225.ps tmp/341ua1193865225.png") > > > proc.time() user system elapsed 1.045 0.534 1.200