Description Usage Arguments Details Value Examples
Compute the probability mass function for a specified categorical variable conditional on values of the primary random variable.
1 | inverse_pmf(x, values, id, sample.args)
|
x |
an rvtable. |
values |
range of values of the continuous random variable in the rvtable. |
id |
the categorical variable for which to compute the pmf given |
sample.args |
optional arguments used when sampling. |
This function computes the pmf of a categorical variable, providing probabilities corresponding to the levels of the variable, conditional on values of the primary random variable in the rvtable. When the primary random variable is continuous, 'values' must be a length-2 vector giving a valid range. When discrete, 'values' can be a range or a single discrete value. If conditioning on a value or range of values restricts the conditional support for 'id' to one where 'id' has probability zero everywhere, a warning will be thrown and the returned rvtable will have zero rows.
an rvtable.
1 2 3 4 5 6 7 8 9 10 11 | library(dplyr)
x <- data.frame(
id1=rep(LETTERS[1:5], each=4),
id2=factor(c("low", "high")),
id3=rep(1:2, each=2),
Val=rep(1:10, each=20), Prob=rep(sqrt(1:10), each=20)) %>% rvtable
y1 <- inverse_pmf(x, c(5, 8), "id1", sample.args=list(n=5))
y1
x <- filter(x, id2=="low" & id3==1) %>% select(-id2, -id3) %>% rvtable
y2 <- inverse_pmf(x, c(5,8), "id1", sample.args=list(n=5))
y2
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.