Learn R Programming

diseq (version 0.4.6)

scores: Likelihood scores.

Description

It calculates the gradient of the likelihood at the given parameter point for each observation in the sample. It, therefore, returns an n x k matrix, where n denotes the number of observations in the sample and k the number of estimated parameters. The ordering of the parameters is the same as the one that is used in the summary of the results. The method can be called either using directly a fitted model object, or by separately providing a model object and a parameter vector.

Usage

scores(object, parameters, fit = missing())

# S4 method for diseq_basic,ANY,ANY scores(object, parameters)

# S4 method for diseq_deterministic_adjustment,ANY,ANY scores(object, parameters)

# S4 method for diseq_directional,ANY,ANY scores(object, parameters)

# S4 method for diseq_stochastic_adjustment,ANY,ANY scores(object, parameters)

# S4 method for equilibrium_model,ANY,ANY scores(object, parameters)

# S4 method for missing,missing,market_fit scores(fit)

Arguments

object

A model object.

parameters

A vector with model parameters.

fit

A fitted model object.

Value

The score matrix.

Examples

Run this code
# NOT RUN {
model <- simulate_model(
  "diseq_basic", list(
    # observed entities, observed time points
    nobs = 500, tobs = 3,
    # demand coefficients
    alpha_d = -0.9, beta_d0 = 8.9, beta_d = c(0.6), eta_d = c(-0.2),
    # supply coefficients
    alpha_s = 0.9, beta_s0 = 7.9, beta_s = c(0.03, 1.2), eta_s = c(0.1)
  ),
  seed = 7523
)

# estimate the model object (BFGS is used by default)
fit <- estimate(model)

# Calculate the score matrix
head(scores(model, coef(fit)))
# }

Run the code above in your browser using DataLab