log_lik | R Documentation |
Calculates the sum of log likelihoods of each observation given the model parameterization (considering a normal distribution around the prediction for each datapoint)
log_lik(npars, obs, pred)
npars |
named numeric vector of parameters that the model was calibrated on |
obs |
numeric vector of observed values |
pred |
numeric vector of predicted values |
the log likelihood value
# observations
obs <- c(12, 38, 92, 176, 176, 627, 1283, 2640)
# intercept, a, and slope, b, of a Poisson regression fitted through obs
pars <- c(a = 2, b = 0.73)
# predictions with the Poisson regression
pred <- c(15.43, 32.15, 66.99, 139.57, 290.82, 605.94, 1262.52, 2630.58)
# example plot
plot(seq(1:length(obs)), obs)
lines(seq(1:length(obs)), pred)
log_lik(
npars = length(pars),
obs = obs,
pred = pred
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.