Description Usage Arguments Details Note Author(s) References Examples
This function takes a variable as input, computes the optimal lambda using a boxcox transformation, then returnes a transformed version of the variable.
1 |
x |
a numerical vector |
minval |
before a transformation is performed, the variables must often be positive. This tells R what the minimum value should be. Defaults to .01. |
lam |
Should the lambda value be returned? |
... |
additional parameters to be used in the model fitting. |
The MASS
package has a function that computes the optimal lambda value for a particular regression equation. However, it currently (as of version 7.3-23)
returns a lambda vector rather than the boxcox transformed variable. This function is a wrapper for boxcox
that actually returns a vector that is a
transformed version of the original variable.
This function calls the boxcox function in the MASS package. To avoid loading the package, I have branched the function directly into the fifer package.
Dustin Fife fife.dustin@gmail.com.
Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition. Springer, New York. ISBN 0-387-95457-0
1 2 3 4 5 |
Loading required package: MASS
$x
[1] -2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6
[16] -0.5 -0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
[31] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0
$y
[1] -2210.4243 -2101.5408 -1992.9345 -1884.6370 -1776.6858 -1669.1257
[7] -1562.0108 -1455.4079 -1349.4003 -1244.0949 -1139.6325 -1036.2054
[13] -934.0874 -833.6898 -735.6655 -641.1078 -551.9064 -471.2380
[19] -403.6401 -353.2681 -320.6934 -302.5749 -294.6105 -293.5034
[25] -297.1337 -304.1892 -313.8425 -325.5504 -338.9384 -353.7350
[31] -369.7347 -386.7751 -404.7246 -423.4739 -442.9306 -463.0161
[37] -483.6624 -504.8110 -526.4110 -548.4180 -570.7931
[1] 0.15473242 -0.12157505 -0.56076335 1.97854452 -1.07541788 0.91462068
[7] -1.36575169 0.38523167 -0.55359804 -0.71265269 0.08645239 -2.34387314
[13] -1.69280803 -2.39876446 -2.99516213 -3.13252858 -2.34225943 0.45148954
[19] -0.99008041 0.34019566 -0.44675268 -2.58922004 -1.71194511 -2.80023599
[25] -1.09925360 -0.12019338 -1.53814659 -1.30305868 -3.25870995 -1.39189522
[31] -0.29993115 0.24351631 0.07565764 -2.00387107 -1.10856229 -3.08075103
[37] 0.33673653 -0.16926205 -0.73867942 0.09292368 1.51402249 0.83813120
[43] -0.11877733 -1.32034448 -1.77838945 -2.97078240 0.42584118 -1.24104949
[49] -0.83232383 -0.66870880 1.62857606 -1.20664528 -1.87287832 -2.47850015
[55] 1.37274759 -2.53615224 0.94984894 -1.49647545 -1.71903240 -0.01554910
[61] -1.03522056 -1.00196703 -0.17182025 0.64503537 -0.88647908 -0.17275404
[67] 0.90093248 0.77574979 0.73516884 -0.40985770 -0.34122345 0.62344147
[73] 0.02423719 0.11217369 -1.39923089 -1.57041237 0.53401004 -1.32880299
[79] -1.41942530 1.24174176 -2.13183632 -0.27732306 0.53865524 -0.74846655
[85] 2.00288967 0.02407692 2.12578757 -1.81587444 -2.69781018 0.88362182
[91] -0.02320477 -1.74212620 -1.25367376 1.02077057 1.71836786 0.00337073
[97] -1.25300513 0.60070697 -0.26916836 1.01406251
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.