dens | R Documentation |
glm
object based on possibly new covariate values, with automatic detection of family and link.Evaluate data against the implied density from a fitted glm
object based on possibly new covariate values, with automatic detection of family and link.
dens(x, model, newdata, binomial_n = 1)
x |
vector of values at which to evaluate the density |
model |
a fitted |
newdata |
data frame with values of the covariates based on which to simulate the response, similar to |
binomial_n |
int length nrow(newdata). If |
A vector of length(x) of density estimates.
n = 100 df = tibble::tibble(x = rnorm(n), y = rpois(n, lambda = exp(x))) mod = glm(y~x, poisson('log'), df) dens_y = dens(df$y, mod, newdata=df) # equivalent to dpois(df$y, lambda = predict(mod, type='response'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.