PostF | R Documentation |
From a Bayesian fit object such as that from blrm()
generates an R function for evaluating the probability that an assertion is true. The probability, within simulation error, is the proportion of times the assertion is true over the posterior draws. If the assertion does not evaluate to a logical or 0/1 quantity, it is taken as a continuous derived parameter and the vector of draws for that parameter is returned and can be passed to the PostF
plot method. PostF
can also be used on objects created by contrast.rms
PostF(fit, name = c("short", "orig"), pr = FALSE)
fit |
a Bayesian fit or |
name |
specifies whether assertions will refer to shortened parameter names (the default) or original names. Shorted names are of the form |
pr |
set to |
an R function
Frank Harrell
## Not run:
f <- blrm(y ~ age + sex)
P <- PostF(f)
P(b2 > 0) # Model is a1 + b1*age + b2*(sex == 'male')
P(b1 < 0 & b2 > 0) # Post prob of a compound assertion
# To compute probabilities using original parameter names:
P <- PostF(f, name='orig')
P(age < 0) # Post prob of negative age effect
P(`sex=male` > 0)
f <- blrm(y ~ sex + pol(age, 2))
P <- PostF(f)
# Compute and plot posterior density of the vertex of the
# quadratic age effect
plot(P(-b2 / (2 * b3)))
# The following would be useful in age and sex interacted
k <- contrast(f, list(age=c(30, 50), sex='male'),
list(age=c(30, 50), sex='female'),
cnames=c('age 30 M-F', 'age 50 M-F'))
P <- PostF(k)
P(`age 30 M-F` > 0 & `age 50 M-F` > 0)
##'
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.