stdev_transform | R Documentation |
This function changes a given standard deviation so that when a vector of samples is drawn from the given distribution, the original standard deviation will be recovered once it is back-transformed from the log or logit scale. In effect, the function "translates" a standard deviation from the natural scale to the log or logit scale for the purposes of random draws from a probability distribution.
stdev_transform(mu, sigma, dist)
mu |
The mean of the distribution on the natural scale. |
sigma |
The standard deviation of the distribution on the natural scale. |
dist |
The distribution to which the standard deviation should be transformed. |
The standard deviation translated to the log or logit scale.
mean <- 10
stdev <- 2
mean_trans <- log(mean)
stdev_trans <- stdev_transform(mean, stdev, "log")
draws <- rnorm(50, mean_trans, stdev_trans)
natural_scale <- exp(draws)
mean(draws)
sd(draws)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.