-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reorganize into univariate and bivariate functions, as well as adding…
… documentation for univariate transformations
- Loading branch information
Showing
3 changed files
with
280 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
Simple Transformations | ||
===== | ||
========================== | ||
Univariate Transformations | ||
========================== | ||
|
||
There are currently 4 simple transformations implemented in distrx: | ||
There are currently 4 univariate transformations implemented in distrx: | ||
* log | ||
* logit | ||
* exp | ||
* expit | ||
|
||
These transformations are implemented using the first order delta method, which works in these | ||
cases as all of the transformations listed are continuous and differentiable. | ||
cases as all of the transformations listed are continuous and differentiable. To briefly summarize, | ||
the delta method transforms the variance by multiplying the original standard error by the first | ||
order Taylor expansion of the transformation function. | ||
|
||
Example: Log Transform | ||
---------------------- | ||
|
||
Assume that we have some means and standard errors (SEs) of systolic blood pressure (SBP) from | ||
several different samples. The data may look something like the following, | ||
|
||
.. csv-table:: | ||
:header: mean, se, n | ||
:widths: 10, 10, 10 | ||
:align: center | ||
|
||
122, 10, 106 | ||
140, 14, 235 | ||
113, 8, 462 | ||
124, 15, 226 | ||
134, 7, 509 | ||
|
||
and our goal is to obtain the appropriate SEs for the data after applying the log transform. | ||
|
||
The first step is to import the required function from the distrx package. | ||
|
||
.. code-block:: python | ||
from distrx import transform_univariate | ||
Different transformation functions can be chosen through specifying a string parameter of which | ||
transform you would like to apply to your data. In this case, it is the following. | ||
|
||
.. code-block:: python | ||
mu_tx, sigma_tx = transform_univariate(mu=df["means"], | ||
sigma=df["se"], | ||
n=df["n"], | ||
transform="log") | ||
``mu_tx`` and ``sigma_tx`` are simply the means with the transformation function applied and their | ||
corresponding standard errors, respectively. ``sigma_tx`` has already been scaled by :math:`\sqrt{n}` | ||
so the we **should not** scale it by square root of the sample size to obtain a confidence interval. |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.