| Title: | Information-Theoretic Methods for Econometric Estimation |
|---|---|
| Description: | Implements the class of Information-Theoretic (IT) estimators for econometric models, following the unified framework of Golan (2008) <doi:10.1561/0800000004>. Provides Generalized Maximum Entropy (GME) and Generalized Cross-Entropy (GCE) estimators for linear regression, instrumental variables, one-way error-component panel data, multinomial response, matrix balancing, and first-order Markov transition matrices, together with pure and noisy inverse-problem solvers. All estimators use the concentrated (dual) formulation for computational efficiency and report normalized-entropy, entropy-ratio, and Fano-bound diagnostics. |
| Authors: | Ganbaatar Jambal [aut, cre] |
| Maintainer: | Ganbaatar Jambal <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.0 |
| Built: | 2026-10-11 10:17:30 UTC |
| Source: | https://github.com/genmaxent/infometrics_r |
Constructs default signal (Z) and error (V) support spaces for GME
estimation using OLS estimates as reference points. The signal support for
each coefficient is centered on the OLS estimate with half-range equal to
signal_scale times the absolute OLS estimate. The error support is
symmetric around zero with half-range equal to error_scale times
the OLS residual standard deviation.
default_supports( y, X, M_signal = 5L, M_error = 5L, signal_scale = 2, error_scale = 3 )default_supports( y, X, M_signal = 5L, M_error = 5L, signal_scale = 2, error_scale = 3 )
y |
Numeric vector of length T. The dependent variable. |
X |
Numeric matrix of dimension T x K. The regressor matrix. |
M_signal |
Integer. Number of support points per coefficient (default 5). |
M_error |
Integer. Number of support points for error terms (default 5). |
signal_scale |
Positive numeric. Half-range multiplier for the signal support (default 2: support spans +/- 2 * |OLS estimate|). |
error_scale |
Positive numeric. Half-range multiplier for the error support (default 3: support spans +/- 3 * OLS residual SD, the "three-sigma rule" of Pukelsheim, 1994). |
A list with two elements:
ZK x M_signal matrix. Row k is the support for beta_k.
VNumeric vector of length M_error. The error support, symmetric around zero.
Golan, A. (2008). Information and Entropy Econometrics. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 6.1.
Pukelsheim, F. (1994). The three sigma rule. The American Statistician, 48, 88-91.
set.seed(42) n <- 50; K <- 3 X <- cbind(1, matrix(rnorm(n * (K-1)), n, K-1)) y <- X %*% c(1, 2, -1) + rnorm(n) sp <- default_supports(y, X) sp$Z # 3 x 5 signal support matrix sp$V # 5-point error supportset.seed(42) n <- 50; K <- 3 X <- cbind(1, matrix(rnorm(n * (K-1)), n, K-1)) y <- X %*% c(1, 2, -1) + rnorm(n) sp <- default_supports(y, X) sp$Z # 3 x 5 signal support matrix sp$V # 5-point error support
Generic for Fano's-inequality error bounds on a fitted probability matrix.
fano_bounds(object, ...)fano_bounds(object, ...)
object |
A fitted model object. |
... |
Passed to methods. |
A method-specific object of error bounds.
The recovered p is a single distribution over the states, so
Golan's (2008, sec 7.5) Fano bound applies to it directly and is the natural
companion to the normalized entropy S: reading S as an
irreducible prediction error, a modal classifier that guesses
errs with probability , and
Fano's inequality lower-bounds this by
The S used here is the uniform-reference the
Fano bound requires – distinct from inverse_ce's prior-relative
reported . This is an information-theoretic error bound on
prediction accuracy, not a sampling standard error (for the
identification SEs of the multipliers see vcov.inverse_ce /
summary).
## S3 method for class 'inverse_ce' fano_bounds(object, ...)## S3 method for class 'inverse_ce' fano_bounds(object, ...)
object |
An |
... |
Unused. |
A one-row data frame with columns p_max, pe (modal
error), H (entropy, nats), S (uniform-normalized entropy), and
pe_lower (Fano weak lower bound). An "overall" attribute holds
mean_pe, mean_pe_lower, and S_system (here identical to
the single row).
Golan, A. (2008). Information and Entropy Econometrics. Foundations and Trends in Econometrics, 2(1-2), 1-145 (sec 7.5); Fano, R. (1961). Transmission of Information.
The recovered p_hat is a single distribution over the states, so
Golan's (2008, sec 7.5) Fano bound applies to it directly (a parallel of
fano_bounds.inverse_ce): a modal classifier that guesses
errs with probability , and
with
(uniform-reference, distinct from the prior-relative S/S_w the
object reports). An information-theoretic error bound, not a sampling SE
(for those see vcov.inverse_noise / summary).
## S3 method for class 'inverse_noise' fano_bounds(object, ...)## S3 method for class 'inverse_noise' fano_bounds(object, ...)
object |
An |
... |
Unused. |
A one-row data frame with columns p_max, pe, H,
S, and pe_lower; an "overall" attribute mirrors the row.
Golan, A. (2008). Information and Entropy Econometrics. Foundations and Trends in Econometrics, 2(1-2), 1-145 (sec 7.5); Fano, R. (1961). Transmission of Information.
For each observation (a row of p_hat, a distribution over the
categories) the modal classifier predicts with error
, lower-bounded (Golan 2008, sec 7.5) by
. This is an information-theoretic error bound,
not a sampling standard error (for those see margins with
se = TRUE).
## S3 method for class 'mixed_gce' fano_bounds(object, ...)## S3 method for class 'mixed_gce' fano_bounds(object, ...)
object |
A |
... |
Unused. |
A data frame with one row per observation (p_max, pe,
H, S, pe_lower) and an "overall" attribute.
For each observation (a row of p_hat, a distribution over the
alternatives) the modal classifier predicts with error
probability . Fano's inequality (Golan 2008,
sec 7.5) lower-bounds this error by the normalized entropy:
This is an information-theoretic error bound on prediction accuracy,
not a sampling standard error (for the latter see
margins with se = TRUE).
## S3 method for class 'multinomial_gce' fano_bounds(object, ...)## S3 method for class 'multinomial_gce' fano_bounds(object, ...)
object |
A |
... |
Unused. |
A data frame with one row per observation and columns p_max,
pe (modal error), H (entropy, nats), S (normalized
entropy), and pe_lower (Fano weak lower bound). An "overall"
attribute holds mean_pe, mean_pe_lower, and S_system.
Golan, A. (2008). Information and Entropy Econometrics. Foundations and Trends in Econometrics, 2(1-2), 1-145 (sec 3.6, 7.5); Fano, R. (1961). Transmission of Information.
Estimates the K-dimensional distribution p closest (in
Kullback-Leibler divergence) to a prior p0 subject to the T pure
moment constraints , by solving the unconstrained dual
(concentrated) model of Golan (2008, Section 4.2; see also Golan, Judge &
Miller, 1996, Ch. 3). This is the
lm-style formula interface to the maximum-entropy /
cross-entropy problem, where a uniform prior p0 gives Maximum Entropy;
a non-uniform p0 gives Cross-Entropy (hence the name).
inverse_ce(formula, data, p0 = NULL, subset, na.action, control = list(), ...) ## S3 method for class 'inverse_ce' coef(object, ...) ## S3 method for class 'inverse_ce' fitted(object, ...) ## S3 method for class 'inverse_ce' residuals(object, ...) ## S3 method for class 'inverse_ce' vcov(object, ...) ## S3 method for class 'inverse_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'inverse_ce' summary(object, ...) ## S3 method for class 'summary.inverse_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...)inverse_ce(formula, data, p0 = NULL, subset, na.action, control = list(), ...) ## S3 method for class 'inverse_ce' coef(object, ...) ## S3 method for class 'inverse_ce' fitted(object, ...) ## S3 method for class 'inverse_ce' residuals(object, ...) ## S3 method for class 'inverse_ce' vcov(object, ...) ## S3 method for class 'inverse_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'inverse_ce' summary(object, ...) ## S3 method for class 'summary.inverse_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...)
formula |
A model formula. The response is the moment vector |
data |
A data frame (or environment) with one row per moment. |
p0 |
Numeric vector of length K (number of model-matrix columns):
strictly-positive prior probabilities for the Cross-Entropy formulation.
Defaults to the uniform distribution, which makes CE reduce to ME. (Named
|
subset |
Optional vector specifying a subset of moments (rows) to use,
as in |
na.action |
A function indicating how to handle |
control |
A named list of control parameters merged over the defaults
and passed to |
... |
Currently unused. |
object, x
|
An |
digits |
Number of significant digits to print. |
The dual concentrated objective (Golan 2008, Eq. 4.4-4.5), minimised here to match the package's dual sign convention, is
with partition function
. Minimising
this convex objective is equivalent to maximising the entropy of p
subject to the moment constraints. With uniform p0 this is Maximum
Entropy; with a non-uniform prior it is Cross-Entropy. The estimated
probabilities are recovered as
(Golan 2008, Eq. 4.3), and the analytic dual Hessian
is (Eq. 4.7), which is positive semidefinite.
An object of class c("inverse_ce", "infometrics"): a list
with components
p_hatNamed K-vector of estimated probabilities.
lambda_hatNamed T-vector of Lagrange multipliers (dual variables).
fitted.valuesFitted moments (length T).
residualsMoment residuals (length T).
hessianAnalytic T-by-T dual Hessian = information matrix
(Eq. 4.7), positive
semidefinite.
vcov_lambda
(T-by-T), or NULL when is singular.
se_lambdaInformation-matrix SEs of (length T),
or NA when is singular.
se_pDelta-method SEs of the probabilities p
(length K), or NA when is singular.
H_signalShannon entropy .
SNormalized entropy in [0, 1]
(pseudo-R2 = 1 - S).
objectiveDual objective at the optimum.
p0The prior distribution used.
convergenceRaw optim convergence code.
methodSolver used ("dual").
terms, model, call
Standard model components.
coef(inverse_ce): Estimated probabilities p.
fitted(inverse_ce): Fitted moments .
residuals(inverse_ce): Moment-fitting residuals .
vcov(inverse_ce): Information-matrix covariance of the multipliers
(T-by-T), or NULL when
is singular.
print(inverse_ce): Compact printed display.
summary(inverse_ce): lm()-style summary (information-matrix SE tables + Fano).
print(summary.inverse_ce): Print method for the summary object.
The Hessian above is the Fisher information matrix of the multipliers,
, so its inverse gives their
covariance (Golan 2008, p. 59;
Cover & Thomas, 2006, Ch. 17). inverse_ce() reports the
resulting se_lambda, the delta-method probability SEs
se_p ( with
), and the
full vcov_lambda (via vcov). These are
information-matrix / curvature quantities: they measure how well the
moments identify – following the multiplier's reading as the
marginal information content of a moment (a moment with larger
carries more information, hence a smaller
; means moment adds little)
– and are not frequentist sampling standard errors, because a pure
inverse problem is deterministic. is singular when a moment
row is constant/collinear or (its rank is at most );
there the affected SEs are returned as NA rather than a pseudo-inverse's
misleadingly finite value. For sampling-based inference use the
stochastic-moment inverse_noise.
Unlike a regression, the response is the vector of moments and each
right-hand-side term is a state. The model matrix built from
formula and data is therefore the T-by-K matrix with
rows = moment constraints (T) and columns = states / support points (K); the
data frame has one row per moment. The estimated coefficients (coef)
are the K probabilities p, one per column. Because columns are states,
an intercept would add a spurious extra state; drop it with - 1. A
warning is issued if an intercept is present.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 4.2. Cover, T. M. & Thomas, J. A. (2006). Elements of Information Theory, 2nd ed., Ch. 17. Golan, A., Judge, G. and Miller, D. (1996). Maximum Entropy Econometrics: Robust Estimation with Limited Data. Wiley. Chapter 3.
inverse_noise for the stochastic-moment (GME/GCE)
estimator that reports sampling standard errors; fano_bounds
for the Fano error bound on the recovered p.
# Recover a 5-state distribution from 2 exact moment constraints. # The data frame has one row per moment (T = 2) and one column per # state (K = 5). Because p_true is the maximum-entropy distribution for # its own moments, it is recovered exactly. X <- rbind(c(1, 2, 3, 4, 5), c(1, 4, 9, 16, 25)) # 2 moments x 5 states p_true <- exp(as.vector(crossprod(X, c(0.2, -0.05)))) p_true <- p_true / sum(p_true) dat <- data.frame(y = as.vector(X %*% p_true), s1 = X[, 1], s2 = X[, 2], s3 = X[, 3], s4 = X[, 4], s5 = X[, 5]) fit <- inverse_ce(y ~ s1 + s2 + s3 + s4 + s5 - 1, data = dat) fit coef(fit) # ~ p_true summary(fit) # info-matrix SEs of lambda / p + a Fano line vcov(fit) # Var(lambda) = I^{-1} fano_bounds(fit) # Fano error bound for the recovered p# Recover a 5-state distribution from 2 exact moment constraints. # The data frame has one row per moment (T = 2) and one column per # state (K = 5). Because p_true is the maximum-entropy distribution for # its own moments, it is recovered exactly. X <- rbind(c(1, 2, 3, 4, 5), c(1, 4, 9, 16, 25)) # 2 moments x 5 states p_true <- exp(as.vector(crossprod(X, c(0.2, -0.05)))) p_true <- p_true / sum(p_true) dat <- data.frame(y = as.vector(X %*% p_true), s1 = X[, 1], s2 = X[, 2], s3 = X[, 3], s4 = X[, 4], s5 = X[, 5]) fit <- inverse_ce(y ~ s1 + s2 + s3 + s4 + s5 - 1, data = dat) fit coef(fit) # ~ p_true summary(fit) # info-matrix SEs of lambda / p + a Fano line vcov(fit) # Var(lambda) = I^{-1} fano_bounds(fit) # Fano error bound for the recovered p
Estimates a K-dimensional signal distribution p together with
per-moment noise distributions w for the stochastic-moment problem
, , by solving the
unconstrained dual (concentrated) model of Golan (2008, Section 6.1). This
is the noisy-moment counterpart of inverse_ce.
inverse_noise( formula, data, v = NULL, nu = 0.5, p0 = NULL, w0 = NULL, se_method = c("sandwich", "delta", "bootstrap", "none"), B = 1000L, subset, na.action, control = list(), ... ) ## S3 method for class 'inverse_noise' coef(object, ...) ## S3 method for class 'inverse_noise' fitted(object, ...) ## S3 method for class 'inverse_noise' residuals(object, ...) ## S3 method for class 'inverse_noise' vcov(object, type = c("sandwich", "delta", "bootstrap"), B = 1000L, ...) ## S3 method for class 'inverse_noise' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'inverse_noise' summary(object, se_method = NULL, B = 1000L, ...) ## S3 method for class 'summary.inverse_noise' print(x, digits = max(3L, getOption("digits") - 3L), ...)inverse_noise( formula, data, v = NULL, nu = 0.5, p0 = NULL, w0 = NULL, se_method = c("sandwich", "delta", "bootstrap", "none"), B = 1000L, subset, na.action, control = list(), ... ) ## S3 method for class 'inverse_noise' coef(object, ...) ## S3 method for class 'inverse_noise' fitted(object, ...) ## S3 method for class 'inverse_noise' residuals(object, ...) ## S3 method for class 'inverse_noise' vcov(object, type = c("sandwich", "delta", "bootstrap"), B = 1000L, ...) ## S3 method for class 'inverse_noise' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'inverse_noise' summary(object, se_method = NULL, B = 1000L, ...) ## S3 method for class 'summary.inverse_noise' print(x, digits = max(3L, getOption("digits") - 3L), ...)
formula |
A model formula. The response is the moment vector; each RHS
term is a state. Usually written without an intercept, e.g.
|
data |
A data frame (or environment) with one row per moment. |
v |
Noise support. One of: |
nu |
Entropy weight in |
p0 |
Prior signal probabilities, length K (= model-matrix columns); strictly positive, default uniform (GME). A non-uniform prior gives GCE. |
w0 |
Prior noise probabilities, a |
se_method |
For |
B |
Integer number of bootstrap resamples when
|
subset |
Optional vector specifying a subset of moments (rows) to use,
as in |
na.action |
A function indicating how to handle |
control |
A named list merged over the defaults and passed to
|
... |
Currently unused. |
object, x
|
An |
type |
Covariance method for |
digits |
Number of significant digits to print. |
Unlike inverse_ce, the moments are treated as noisy:
the constraint is rather than . The estimator
therefore shrinks p toward its prior p0; how much depends on
the width of the noise support v. As v collapses toward 0 the
solution approaches the pure-CE solution of inverse_ce.
The dual objective is minimised here (convex) to match the package
convention used by inverse_ce:
with signal partition function
and
per-moment noise partition functions
. The weight
splits entropy between signal and noise;
gives the standard equal-weight GME/GCE. Minimising this convex objective is
equivalent to maximising the joint signal-plus-noise entropy subject to the
noisy moment constraints. The estimates are recovered as
and
, with
. Uniform priors (p0 = NULL,
w0 = NULL) give the GME version; user-supplied priors give GCE.
An object of class c("inverse_noise", "infometrics"): a list
with components
p_hatNamed K-vector of signal probabilities.
foc_residual at the optimum; near 0
for a healthy fit (see Support feasibility).
lambda_hatNamed T-vector of Lagrange multipliers.
w_hatT x M matrix of noise probabilities.
fitted.valuesSignal-fitted moments (length T).
residualsMoment residuals , equal to the
estimated noise at the optimum.
hessianAnalytic T-by-T dual Hessian (positive definite).
vcov_lambda, se_lambda, se_p
Covariance of
and standard errors of / by
se_method (NULL when se_method = "none").
se_methodThe SE method stored.
H_signal, H_error, H_error0
Shannon entropies
of the signal , the noise , and the noise
prior .
S, S_p
Normalized signal entropy
in [0, 1] (pseudo-R2 = 1 - S).
S_wNormalized noise entropy .
objectiveDual objective at the optimum.
nu, prior, noise_prior, support
The
entropy weight, signal prior p0, noise prior w0, and the
noise support v.
X, y, control
Stored for SE recomputation and the bootstrap.
convergenceRaw optim convergence code.
method, terms, model, call
Solver and standard model components.
coef(inverse_noise): Estimated signal probabilities p.
fitted(inverse_noise): Fitted (signal) moments .
residuals(inverse_noise): Residuals (the estimated noise).
vcov(inverse_noise): Covariance of the Lagrange multipliers by method.
type = "sandwich" (default) is the robust
; "delta" is the naive
(overstates ~10x); "bootstrap" refits B residual
resamples. Note: the default changed from the raw to
the sandwich, since is not a valid sampling covariance here.
print(inverse_noise): Compact printed display.
summary(inverse_noise): lm()-style summary; prints a p coefficient
table with standard errors and t-stats, the signal/noise normalized
entropies, and a Fano line. se_method selects the SE method
(default: the one stored on the object).
print(summary.inverse_noise): Print method for the summary object.
Structurally this is a GME regression with p on the
simplex, so the moment rows are the effective sample size and sampling
SEs are meaningful. Because solves
, the implicit-function theorem gives
, so
and
with
.
Three methods are provided via se_method / vcov(type=) /
summary(se_method=):
"sandwich" (default)robust HC0
(meat = squared fitted noise).
Accurate for p (validated against a Monte-Carlo SD and the
bootstrap); per-element lambda SEs are noisier (each rests on one
).
"delta"the naive . Kept for comparison but it
overstates the sampling SE by roughly ten-fold (it is not a
sampling covariance) – do not use it for inference.
"bootstrap"residual bootstrap: keep the rows fixed, resample
the fitted noise , refit. Gives stable, aligned SEs for both
lambda and p; the gold-standard cross-check.
All three mildly understate (~15-20%) because the finite-support entropy penalty shrinks the fitted noise below the true noise dispersion (the bootstrap shows the same, so it is a property of the estimator and of an over-wide support, not a bug).
The dual is bounded below only if y can be represented as
with on the simplex and every inside the noise
support v. If it cannot, the dual is unbounded: the
multipliers diverge, the softmax saturates, and p_hat collapses to a
vertex of the simplex (a 0/1 corner) even though optim reports
convergence. inverse_noise() therefore checks the first-order
condition at the optimum, reports it as
foc_residual, and warns when it is not satisfied. The remedy
is a wider noise support v.
Unlike a regression, the response is the vector of moments and each
right-hand-side term is a state. The model matrix built from
formula and data is therefore the T-by-K matrix with
rows = moment constraints (T) and columns = states / support points (K); the
data frame has one row per moment. The estimated coefficients (coef)
are the K probabilities p, one per column. Because columns are states,
an intercept would add a spurious extra state; drop it with - 1. A
warning is issued if an intercept is present.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 6.1.
inverse_ce for the exact-moment (pure) version;
linreg for the GME/GCE regression estimator;
fano_bounds for the Fano error bound on p_hat.
set.seed(123) X <- matrix(runif(30), nrow = 10, ncol = 3) # T = 10 moments, K = 3 states p_true <- c(0.5, 0.2, 0.3) y <- as.vector(X %*% p_true) + rnorm(nrow(X), 0, 0.3) dat <- data.frame(y = y, x1 = X[, 1], x2 = X[, 2], x3 = X[, 3]) fit <- inverse_noise(y ~ x1 + x2 + x3 - 1, data = dat) fit summary(fit) # p table (SE + t), signal/noise entropy, Fano vcov(fit) # sandwich Cov(lambda) fano_bounds(fit) # Fano error bound for p_hatset.seed(123) X <- matrix(runif(30), nrow = 10, ncol = 3) # T = 10 moments, K = 3 states p_true <- c(0.5, 0.2, 0.3) y <- as.vector(X %*% p_true) + rnorm(nrow(X), 0, 0.3) dat <- data.frame(y = y, x1 = X[, 1], x2 = X[, 2], x3 = X[, 3]) fit <- inverse_noise(y ~ x1 + x2 + x3 - 1, data = dat) fit summary(fit) # p table (SE + t), signal/noise entropy, Fano vcov(fit) # sandwich Cov(lambda) fano_bounds(fit) # Fano error bound for p_hat
Fits the linear model by Generalized Cross-Entropy
(Golan 2008, Section 6.1, Eq. 6.5; see also Golan, Judge & Miller, 1996,
Ch. 6). Each coefficient is reparameterized on
a bounded support, , and each error on a
noise support, ; the signal and noise entropies
(relative to priors p0, w0) are maximized subject to the data
constraints, with weight on the noise. Estimation uses
the concentrated dual in the T Lagrange multipliers.
linreg( formula, data, Z = NULL, nu = 0.5, p0 = NULL, v = NULL, w0 = NULL, subset, na.action, control = list(), ... ) ## S3 method for class 'linreg' coef(object, ...) ## S3 method for class 'linreg' fitted(object, ...) ## S3 method for class 'linreg' residuals(object, ...) ## S3 method for class 'linreg' vcov(object, ...) ## S3 method for class 'linreg' predict(object, newdata, ...) ## S3 method for class 'linreg' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'linreg' summary(object, ...) ## S3 method for class 'summary.linreg' print( x, digits = max(3L, getOption("digits") - 3L), signif.stars = getOption("show.signif.stars"), ... )linreg( formula, data, Z = NULL, nu = 0.5, p0 = NULL, v = NULL, w0 = NULL, subset, na.action, control = list(), ... ) ## S3 method for class 'linreg' coef(object, ...) ## S3 method for class 'linreg' fitted(object, ...) ## S3 method for class 'linreg' residuals(object, ...) ## S3 method for class 'linreg' vcov(object, ...) ## S3 method for class 'linreg' predict(object, newdata, ...) ## S3 method for class 'linreg' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'linreg' summary(object, ...) ## S3 method for class 'summary.linreg' print( x, digits = max(3L, getOption("digits") - 3L), signif.stars = getOption("show.signif.stars"), ... )
formula, data, subset, na.action
|
Standard model-frame arguments, as in
|
Z |
Coefficient support. Either a length-M numeric vector (a common
support recycled across all coefficients) or a K-by-M matrix whose rows
correspond, in order, to the columns of the model matrix (so row 1 is the
intercept's support when an intercept is present). Default: a 5-point
symmetric support spanning +/- a multiple of |
nu |
Entropy weight in |
p0 |
Prior signal probabilities, a K-by-M matrix matching |
v, w0
|
Noise support and prior, as in |
control |
A named list merged over the defaults and passed to
|
... |
Currently unused. |
object, x
|
A |
newdata |
Optional data frame of new observations. |
digits |
Significant digits to print. |
signif.stars |
Logical; show significance stars (default from options). |
This fits the Generalized Cross-Entropy (GCE) linear regression estimator
with an lm-style interface, adding a predict method,
an lm-style coefficient table, and r.squared. The dual is
minimised here (convex) to match the package convention used by
inverse_ce and inverse_noise;
this is equivalent to maximising the joint signal-plus-noise entropy. Uniform
priors (p0 = NULL, w0 = NULL) give GME; user priors give GCE.
summary() reports a per-coefficient Entropy-Ratio (ER) test of
(Golan 2008, Sec. 6.4/6.6) in place of a Wald
z test. To do so it refits the model times (one per
coefficient plus one joint test of all coefficients = 0), each warm-started from the fitted
multipliers; the resolved Z, p0, v, w0,
X, y are stored on the object to make these refits faithful.
An object of class c("linreg", "infometrics"), which is a list
containing the following components:
coefficientsNumeric vector of length K: the estimated
coefficients , named by the model-matrix
columns. Extracted by coef.
p, p_hat
K-by-M matrix of estimated signal probabilities (two names for the same object).
lambda, lambda_hat
Numeric vector of length T: the estimated Lagrange multipliers (two names for the same object).
w, w_hat
T-by-J matrix of estimated noise probabilities (two names for the same object).
eNumeric vector of length T: the estimated noise,
.
fitted.valuesNumeric vector of length T:
. Extracted by fitted.
residualsNumeric vector of length T: ,
which equals e at a converged optimum. Extracted by
residuals.
vcovK-by-K asymptotic covariance matrix of
(Golan 2008, p. 96). Extracted by vcov.
hessianT-by-T dual Hessian at the optimum; positive definite.
r.squaredSingle number: the ordinary coefficient of determination.
H_signalNumeric vector of length K: the per-coefficient
signal entropies .
SSingle number: the normalized signal entropy
. With a uniform prior this reduces to
and lies in [0, 1]; with an informative prior it is
measured relative to that prior and may exceed 1.
objective, value
Single number: the minimised dual objective (two names for the same value).
foc_residualSingle number: at the optimum. Near 0 for a healthy fit; see
Support feasibility.
convergedLogical: TRUE when optim converged
and the first-order condition is satisfied.
convergenceInteger: the raw optim
convergence code.
nuSingle number: the entropy weight used.
methodCharacter string naming the solver, "dual".
Z, p0, v, w0, X, y,
control
The resolved inputs, retained so that summary()
can refit the model for the entropy-ratio test.
terms, model, xlevels, call
The standard
model components, as returned by lm.
coef(linreg): Estimated coefficients .
fitted(linreg): Fitted values .
residuals(linreg): Residuals (the estimated noise e).
vcov(linreg): Asymptotic covariance of , Golan (2008) p. 96
(coincides with OLS as the supports widen).
predict(linreg): Predictions for newdata (or fitted values).
print(linreg): Compact display.
summary(linreg): lm()-style summary with an entropy-ratio coefficient
table. For each coefficient an Entropy-Ratio (ER) test of
is computed by refitting with row of the
signal support collapsed to zero and forming
with ;
under , (Golan 2008, Sec.
6.4/6.6). An overall ER test of all coefficients (intercept
and slopes) is also reported. Note this performs
warm-started refits.
print(summary.linreg): Print method for the summary object.
The dual is bounded below only if y can be represented as
with every inside its signal support Z
and every inside the noise support v. If it cannot, the dual
is unbounded: the multipliers diverge, the signal softmax saturates
and pins to a vertex of Z even though optim reports
convergence. This is why the default v widens with – the
largest of errors grows like , so a fixed
three-sigma support becomes infeasible in large samples.
linreg() checks the first-order condition at
the optimum, reports it as foc_residual, and warns (setting
converged = FALSE) when it is not satisfied. The remedy is a wider
v and/or Z.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 6.1. Golan, A., Judge, G. and Miller, D. (1996). Maximum Entropy Econometrics: Robust Estimation with Limited Data. Wiley. Chapter 6.
inverse_ce, inverse_noise for related
information-theoretic estimators.
set.seed(1) d <- data.frame(x1 = rnorm(100), x2 = rnorm(100)) d$y <- 2 - 1.5 * d$x1 + 0.8 * d$x2 + rnorm(100, sd = 0.7) fit <- linreg(y ~ x1 + x2, data = d, Z = seq(-20, 20, length.out = 5)) summary(fit)set.seed(1) d <- data.frame(x1 = rnorm(100), x2 = rnorm(100)) d$y <- 2 - 1.5 * d$x1 + 0.8 * d$x2 + rnorm(100, sd = 0.7) fit <- linreg(y ~ x1 + x2, data = d, Z = seq(-20, 20, length.out = 5)) summary(fit)
Fits the linear model by the (relaxed) stochastic-moments
Generalized Maximum Entropy estimator of Golan (2008, pp. 89-91), identified
by instrument moments . Each coefficient is
reparameterized on a bounded signal support, , and each error on a noise support, ; the
signal and noise entropies are maximized subject to the instrument moments,
with weight . It is the instrumental-variables sibling of
linreg.
linreg_iv( y, X, IV, Z, p0 = NULL, v = NULL, w0 = NULL, nu = 0.5, se_method = c("sandwich", "delta", "bootstrap", "none"), control = list(), boot = 200L )linreg_iv( y, X, IV, Z, p0 = NULL, v = NULL, w0 = NULL, nu = 0.5, se_method = c("sandwich", "delta", "bootstrap", "none"), control = list(), boot = 200L )
y |
Numeric response vector of length N. |
X |
N-by-K design matrix (include an intercept column if wanted). |
IV |
N-by-P instrument matrix, |
Z |
Coefficient (signal) support: a K-by-M matrix whose row k is the
support for |
p0 |
Optional K-by-M signal prior (rows strictly positive, summing to 1); default uniform. |
v |
Optional error support: |
w0 |
Optional N-by-J error prior (rows strictly positive, summing to 1); default uniform. |
nu |
Entropy weight in |
se_method |
Standard-error method: |
control |
Named list merged over defaults and passed to
|
boot |
Number of bootstrap resamples when
|
The concentrated dual is maximized over the Lagrange multipliers
(one per instrument moment): with and , the gradient is the instrument moment
. Supports just-identified
(ncol(IV) == ncol(X)) and over-identified (ncol(IV) > ncol(X))
systems. The instruments are standardized internally for numerical
conditioning ( is invariant to instrument scaling); lambda
is reported on the original scale. coef() returns .
As the signal support widens the GME estimate approaches the exact (2SLS-type)
IV solution; narrower supports shrink toward the support centers.
Standard errors. Because solves the instrument
moments, is a Z-estimator with sandwich
covariance , where is the dual Hessian and . The "meat" is set by
se_method: "sandwich" (default, robust HC0
), "delta" (classical homoskedastic
), or "bootstrap" (pairs resampling). The
robust sandwich matches a Monte-Carlo sampling SD and reduces to the 2SLS
robust SE as the support widens; the classical delta assumes homoskedasticity.
These are asymptotic SEs: the sampling distribution of
is support-bounded and can be skewed, so symmetric Wald intervals are
approximate with weak instruments or small .
An object of class c("linreg_iv", "infometrics"), which is a list
containing the following components:
coefficients, b_hat
Numeric vector of length K: the
estimated coefficients
(two names for the same object). Extracted by coef.
lambda_hatNumeric vector of length P: the estimated Lagrange multipliers, one per instrument moment, reported on the original instrument scale.
p_hatK-by-M matrix of estimated signal probabilities.
w_hatN-by-J matrix of estimated noise probabilities.
e_hat, e
Numeric vector of length N: the estimated
noise, (two names for the same object).
fitted.valuesNumeric vector of length N:
. Extracted by fitted.
residualsNumeric vector of length N:
. Extracted by
residuals.
se_betaNumeric vector of length K: standard errors of
, or NULL when
se_method = "none".
vcovK-by-K covariance matrix of ,
or NULL when se_method = "none". Extracted by
vcov.
se_method, boot
The standard-error method used and, for the bootstrap, the number of resamples.
H_signalNumeric vector of length K: the per-coefficient signal entropies.
SSingle number: the normalized signal entropy.
objective, value
Single number: the maximized dual objective (two names for the same value).
moment_residSingle number: the largest absolute instrument
moment at the optimum. Not normalized by – see
Note on moment_resid.
convergedLogical: TRUE when optim reported
convergence.
convergenceInteger: the raw optim
convergence code.
methodCharacter string naming the solver, "dual".
Z, p0, v, w0, nu, X,
y, IV
The resolved inputs.
N, K, P, M
Integers: the numbers of observations, coefficients, instruments and signal support points.
callThe matched call.
The signal support Z is the consequential input here. It must
contain the true coefficients: if it does not, is pinned to
the boundary of Z (for example, a support of returns
for a coefficient whose true value is 1.5). Widening
Z moves the estimate toward the exact (2SLS-type) IV solution;
narrowing it shrinks toward the support centers.
The error support v is far less critical, and – unlike
linreg and inverse_noise – its default does not
need to grow with the sample size. Those estimators impose one dual condition
per observation, , so every realized error must fit
inside v; because the largest of errors grows like
, a fixed three-sigma support eventually becomes
infeasible and their duals become unbounded. linreg_iv() instead
imposes only the aggregate instrument moments
, so the noise never has to absorb individual
residuals and no per-observation feasibility condition arises. In practice
is nearly invariant to the width of v, and large
samples pose no difficulty: the multipliers stay small and the estimate
tracks the exact IV solution.
moment_resid
moment_resid is evaluated on the
standardized instruments. It is a sum over the observations and
is not divided by , so its magnitude grows with the sample size even
when the fit is excellent; judge it relative to (or compare fits of
the same size) rather than against a fixed threshold.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Pages 89-91. Golan, A., Judge, G. and Miller, D. (1996). Maximum Entropy Econometrics: Robust Estimation with Limited Data. Wiley.
linreg for the (non-IV) GME/GCE regression.
set.seed(1) n <- 200L z <- rnorm(n) # instrument u <- rnorm(n) # structural error xe <- 0.7 * z + u + rnorm(n) # endogenous regressor (corr. with u) y <- 1 + 1.5 * xe + u # true slope 1.5; OLS biased X <- cbind(1, xe) # intercept + endogenous regressor IV <- cbind(1, z) # intercept is its own instrument Z <- matrix(c(-10, 0, 10), nrow = 2, ncol = 3, byrow = TRUE) # signal support fit <- linreg_iv(y, X, IV, Z) coef(fit) # slope ~ 1.5 (vs OLS biased upward)set.seed(1) n <- 200L z <- rnorm(n) # instrument u <- rnorm(n) # structural error xe <- 0.7 * z + u + rnorm(n) # endogenous regressor (corr. with u) y <- 1 + 1.5 * xe + u # true slope 1.5; OLS biased X <- cbind(1, xe) # intercept + endogenous regressor IV <- cbind(1, z) # intercept is its own instrument Z <- matrix(c(-10, 0, 10), nrow = 2, ncol = 3, byrow = TRUE) # signal support fit <- linreg_iv(y, X, IV, Z) coef(fit) # slope ~ 1.5 (vs OLS biased upward)
Creates an M-point symmetric support vector centered at zero (or a specified center) over a given half-range. Support spaces are required inputs for the GME and GCE estimators, bounding the parameter vector beta and the error vector epsilon.
make_support(half_range, M = 5L, center = 0)make_support(half_range, M = 5L, center = 0)
half_range |
Positive numeric. The half-width of the support interval.
The support spans from |
M |
Positive integer. Number of support points. Must be >= 2. The default of 5 (a 5-point support) is commonly used in the GME literature. |
center |
Numeric. Center of the support interval (default 0). |
In the GME framework (Golan, 2008, Section 6.1), each parameter beta_k is reparameterized as the expected value of a random variable defined on a bounded support z_k = (z_{k1}, ..., z_{kM}). The support must contain the true parameter value. A common default is a symmetric 5-point grid with half-range set to 3 standard deviations of the OLS residuals (for the error support V) or 2 times the absolute OLS estimate (for the signal support Z).
The complexity of the GME dual model is invariant to M (the number of support points), since the real parameters are the Lagrange multipliers whose dimension equals T (the number of observations), not K*M.
A numeric vector of length M giving the support points, evenly
spaced from center - half_range to center + half_range.
Golan, A. (2008). Information and Entropy Econometrics. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 6.1.
# 5-point support for error terms: [-3, -1.5, 0, 1.5, 3] make_support(half_range = 3, M = 5) # 3-point support centered at a non-zero value: [0, 5, 10] make_support(half_range = 5, M = 3, center = 5) # 7-point support for a coefficient bounded in [-2, 2] make_support(half_range = 2, M = 7)# 5-point support for error terms: [-3, -1.5, 0, 1.5, 3] make_support(half_range = 3, M = 5) # 3-point support centered at a non-zero value: [0, 5, 10] make_support(half_range = 5, M = 3, center = 5) # 7-point support for a coefficient bounded in [-2, 2] make_support(half_range = 2, M = 7)
Generic for average (or per-observation) marginal effects of a fitted model.
margins(object, ...)margins(object, ...)
object |
A fitted model object. |
... |
Passed to methods. |
A method-specific object of marginal effects.
Partial derivatives of the signal probabilities with respect to each design
slot, holding and fixed:
## S3 method for class 'mixed_gce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "bootstrap"), B = 500L, ... )## S3 method for class 'mixed_gce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "bootstrap"), B = 500L, ... )
object |
A |
average |
Logical (default |
se |
Logical (default |
se_method |
|
B |
Integer number of bootstrap resamples when
|
... |
Unused. |
With se = TRUE (and average = TRUE) standard errors for the
average marginal effects are attached. These are a sampling quantity,
unrelated to the Fano fano_bounds (which bound
classification error). se_method = "sandwich" (default) uses the robust
covariance of the dual multipliers, with
the per-observation score outer products,
sandwiched with a numerical Jacobian of the average effects. This matches a
row bootstrap; the naive Hessian-inverse would overstate by ~7-9x for this
model (the support reparameterization plus per-observation block
make solve(-H) a poor sampling-covariance estimate), so it is not used.
se_method = "bootstrap" resamples observations, refits, and takes the
across-resample SD.
With se = FALSE: a K x J matrix (average effects) or an
N x J x K array. With se = TRUE: a margins_gce object.
fano_bounds for information-theoretic error bounds.
Partial derivatives of the signal probabilities with respect to each column
of X:
The reference alternative's column is included like any other; its "intercept" effect (derivative w.r.t. a constant) is rarely interpreted.
## S3 method for class 'multinomial_gce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "delta", "bootstrap"), B = 500L, ... )## S3 method for class 'multinomial_gce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "delta", "bootstrap"), B = 500L, ... )
object |
A |
average |
Logical (default |
se |
Logical (default |
se_method |
|
B |
Integer number of bootstrap resamples when
|
... |
Unused. |
With se = TRUE (and average = TRUE) standard errors for the
average marginal effects are attached. These are a sampling quantity,
unrelated to the Fano fano_bounds (which bound
classification error, not sampling variance). All methods sandwich a numerical
Jacobian of the average effects in the free multipliers with a
covariance of :
se_method = "sandwich" (default) uses the robust covariance
with the
per-observation dual scores. This matches a row bootstrap and is the
accurate choice under the GME's finite-support regularization.
se_method = "delta" uses the naive Hessian inverse
vcov(object) (the classical Golan 2008 sec. 7.3
observed-information SE); being tied to it is
conservative (~1.35x the bootstrap here).
se_method = "bootstrap" resamples observations, refits, and
takes the across-resample SD (accurate, slower).
With se = FALSE: a K x J matrix (average effects) or an
N x J x K array. With se = TRUE: a margins_gce object.
fano_bounds for information-theoretic error bounds.
Estimates a first-order, stationary row-stochastic matrix
() linking simplex-valued state vectors over time,
from a balanced long panel, by Cross-Entropy (Golan 2008, Section 7.7.1,
eqs. 7.25-7.27). States may be one-hot membership indicators or
compositional shares (a panel/time-indexed extension of matrix balancing).
Data are supplied in long form (one row per unit-period) and reshaped
internally; transitions are formed within each unit.
markov_ce( data, id, time, states, covariates = NULL, p0 = NULL, control = list() ) ## S3 method for class 'markov_ce' coef(object, ...) ## S3 method for class 'markov_ce' fitted(object, ...) ## S3 method for class 'markov_ce' fano_bounds(object, ...) ## S3 method for class 'markov_ce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "bootstrap"), B = 500L, ... ) ## S3 method for class 'markov_ce' residuals(object, ...) ## S3 method for class 'markov_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'markov_ce' summary(object, ...)markov_ce( data, id, time, states, covariates = NULL, p0 = NULL, control = list() ) ## S3 method for class 'markov_ce' coef(object, ...) ## S3 method for class 'markov_ce' fitted(object, ...) ## S3 method for class 'markov_ce' fano_bounds(object, ...) ## S3 method for class 'markov_ce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "bootstrap"), B = 500L, ... ) ## S3 method for class 'markov_ce' residuals(object, ...) ## S3 method for class 'markov_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'markov_ce' summary(object, ...)
data |
A balanced long-format |
id, time
|
Names of the unit-identifier and time columns. |
states |
Character vector of state columns; each row over them is
non-negative and sums to 1. |
covariates |
Optional character vector of covariate columns
( |
p0 |
Optional |
control |
A named list merged over the defaults and passed to
|
object, x
|
A |
... |
Unused. |
average |
Logical; if |
se |
Logical (default |
se_method |
|
B |
Integer bootstrap resamples when |
digits |
Significant digits to print. |
Optional covariates z enter lead/lagged like the states: per
transition the lagged states pair with lagged covariates
and the lead states with lead covariates , forming the
cross moments (K x S) and
(S x K), number of covariates. The concentrated dual
is maximized over the S x K multipliers. With no covariates the
conditioning is the lagged-state indicator (, transition counts).
When the conditioning is full rank (A = X'X}, the common indicator
case), the moment condition \eqn{A'P = M exactly determines as the
empirical/regression transition matrix, so the prior is irrelevant for
identified origin states. Only under-identified rows
(, e.g. a state never observed as an origin) fall
back to the prior (maximum entropy when p0 is uniform); see the
rank warning and the normalized entropy S in summary().
Standard errors of (se_lambda) use the analytic Hessian
of the CE log-partition (Golan 2008, eq. 4.7),
– the covariance of the moment functions under . Note that
alone overstates the SE (~), because the
moments are cross-moment sums (); the reported SE
is the robust sandwich (Golan 2008, Sec. 3.3), which
matches a unit bootstrap. Because is identified only up to a
per-conditioning additive shift, se_lambda is relative to a reference
destination (lambda_ref = 1, that column NA); a (near-)boundary
fit () yields NA (an infinite log-odds SE).
An object of class c("markov_ce", "infometrics"), which is a list
containing the following components:
p, p_hat
K-by-K row-stochastic transition matrix,
(two names for the same
object). Extracted by coef.
lambda, lambda_hat
S-by-K matrix of estimated Lagrange multipliers, reported on the original covariate scale (two names for the same object).
seK-by-K matrix of large-sample multinomial standard errors
of .
se_lambdaS-by-K matrix of analytic-Hessian sandwich standard
errors of . The reference-destination column is
NA, as are entries at a (near-)boundary fit.
lambda_refInteger: the index of the reference destination
state used to normalize se_lambda.
vcov_lambdaCovariance matrix of the free (non-reference)
elements of , or NULL if the sandwich could
not be formed.
n_fromNumeric vector of length K: the total weight of each origin state across transitions.
statesCharacter vector of length K: the state labels.
se_dataList of the cross moments, lead/lagged design blocks
and scaling used by margins.markov_ce, or NULL when
no covariates were supplied.
n_transitionsInteger: the number of unit-period transitions,
.
state_typeCharacter string, "indicator" or
"shares", describing the supplied state columns.
fitted.valuesMatrix of fitted lead states,
, one row per transition. Extracted by
fitted.
residualsMatrix of the same dimension:
. Extracted by residuals.
entropy, H_signal
Single number: the mean row entropy
of (two names for the same value).
SSingle number: the prior-relative normalized entropy, the
mean row entropy of divided by that of p0.
moment_residualSingle number:
at the optimum.
objective, value
Single number: the maximized dual objective (two names for the same value).
priorThe resolved K-by-K prior p0.
convergedLogical: TRUE when optim reported
convergence.
convergenceInteger: the raw optim
convergence code.
methodCharacter string naming the solver, "dual".
callThe matched call.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 7.7.1.
set.seed(1) P_true <- matrix(c(.6,.3,.1, .2,.5,.3, .1,.3,.6), nrow = 3, byrow = TRUE) N <- 150L; Tn <- 5L; K <- 3L s <- sample(K, N, replace = TRUE) id <- rep(seq_len(N), each = Tn); tm <- rep(seq_len(Tn), N) state <- integer(N * Tn) for (t in seq_len(Tn)) { state[tm == t] <- s s <- vapply(s, function(k) sample(K, 1L, prob = P_true[k, ]), integer(1)) } oh <- diag(K)[state, ] panel <- data.frame(i = id, t = tm, y1 = oh[, 1], y2 = oh[, 2], y3 = oh[, 3]) fit <- markov_ce(panel, id = "i", time = "t", states = c("y1", "y2", "y3")) coef(fit)set.seed(1) P_true <- matrix(c(.6,.3,.1, .2,.5,.3, .1,.3,.6), nrow = 3, byrow = TRUE) N <- 150L; Tn <- 5L; K <- 3L s <- sample(K, N, replace = TRUE) id <- rep(seq_len(N), each = Tn); tm <- rep(seq_len(Tn), N) state <- integer(N * Tn) for (t in seq_len(Tn)) { state[tm == t] <- s s <- vapply(s, function(k) sample(K, 1L, prob = P_true[k, ]), integer(1)) } oh <- diag(K)[state, ] panel <- data.frame(i = id, t = tm, y1 = oh[, 1], y2 = oh[, 2], y3 = oh[, 3]) fit <- markov_ce(panel, id = "i", time = "t", states = c("y1", "y2", "y3")) coef(fit)
Estimates a row-stochastic matrix linking simplex-
valued state vectors over time, conditioning on covariates, by Generalized
Cross-Entropy from a balanced long panel (Golan 2008, Section 7.7.1, eqs.
7.25a and 7.28). Unlike markov_ce (which imposes the moments
exactly), each conditional moment carries an additive error
on a support symmetric
on . This makes over-identified moment systems – in particular
time-varying covariates such as household income – feasible, where the exact
problem is unbounded.
markov_gce( data, id, time, states, covariates, v = NULL, nu = 0.5, p0 = NULL, w0 = NULL, control = list() ) ## S3 method for class 'markov_gce' coef(object, ...) ## S3 method for class 'markov_gce' fano_bounds(object, ...) ## S3 method for class 'markov_gce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "bootstrap"), B = 500L, ... ) ## S3 method for class 'markov_gce' fitted(object, ...) ## S3 method for class 'markov_gce' residuals(object, ...) ## S3 method for class 'markov_gce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'markov_gce' summary(object, ...)markov_gce( data, id, time, states, covariates, v = NULL, nu = 0.5, p0 = NULL, w0 = NULL, control = list() ) ## S3 method for class 'markov_gce' coef(object, ...) ## S3 method for class 'markov_gce' fano_bounds(object, ...) ## S3 method for class 'markov_gce' margins( object, average = TRUE, se = FALSE, se_method = c("sandwich", "bootstrap"), B = 500L, ... ) ## S3 method for class 'markov_gce' fitted(object, ...) ## S3 method for class 'markov_gce' residuals(object, ...) ## S3 method for class 'markov_gce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'markov_gce' summary(object, ...)
data |
A balanced long-format |
id, time
|
Names of the unit-identifier and time columns. |
states |
Character vector of state columns; each row over them is
non-negative and sums to 1. |
covariates |
Character vector of covariate columns
( |
v |
Numeric error support, symmetric about 0 with at least two points;
default |
nu |
Signal/noise weight in |
p0 |
Optional |
w0 |
Optional error prior on the support (length |
control |
A named list merged over the defaults and passed to
|
object, x
|
A |
... |
Unused. |
average |
Logical; if |
se |
Logical (default |
se_method |
|
B |
Integer bootstrap resamples when |
digits |
Significant digits to print. |
The -weighted concentrated dual maximized over the
multipliers is
with and
.
The first-order conditions are the noisy moments . The exact estimator markov_ce
is recovered in two limits: as the support (the slack vanishes
mechanically), and as (the noise-divergence term dominates,
forcing ). Conversely, a wide support or
lets the errors absorb the moments and pulls
toward the prior.
Standard errors of (se_lambda) use the analytic Hessian
of the dual (Golan 2008, eq. 4.7): the signal covariance
plus the noise
covariance
(block-diagonal in the destination ). The noise term makes the Hessian
full rank – is identified, so no reference normalization is
needed (unlike markov_ce). The reported SE is the robust
unit-clustered sandwich (Golan 2008, Sec.
3.3), which matches a unit bootstrap; the naive and the
non-clustered sandwich are conservative because covariate scores are correlated
within a unit.
An object of class c("markov_gce", "infometrics"), which is a list
containing the following components:
p, p_hat
K-by-K row-stochastic transition matrix,
(two names for the same
object). Extracted by coef.
lambda, lambda_hat
S-by-K matrix of estimated Lagrange multipliers, reported on the original covariate scale (two names for the same object).
epsilonMatrix of fitted per-transition errors
, one row per transition and one
column per destination state.
seK-by-K matrix of large-sample multinomial standard errors
of .
se_lambdaS-by-K matrix of analytic-Hessian, unit-clustered
sandwich standard errors of . All entries are
reported: the noise identifies , so no reference
normalization is needed.
vcov_lambdaCovariance matrix of , or
NULL if the sandwich could not be formed.
statesCharacter vector of length K: the state labels.
se_dataList of the cross moments, lead/lagged design blocks
and scaling used by margins.markov_gce.
n_transitionsInteger: the number of unit-period transitions,
.
n_fromNumeric vector of length K: the total weight of each origin state across transitions.
nuSingle number: the signal/noise weight used.
v, w0
The resolved error support and its prior.
H_p, H_signal, entropy
Single number: the mean
row entropy of (three names for the same value).
H_wSingle number: the mean noise entropy
.
SSingle number: the prior-relative normalized entropy, the
mean row entropy of divided by that of p0.
fitted.valuesMatrix of fitted lead states,
, one row per transition. Extracted by
fitted.
residualsMatrix of the same dimension:
. Extracted by residuals.
moment_residualSingle number:
, the exact-moment gap.
Expected to be nonzero – it is absorbed by the noise.
foc_residualSingle number:
,
the noisy first-order condition. Near 0 at a healthy optimum.
objective, value
Single number: the maximized dual objective (two names for the same value).
priorThe resolved K-by-K prior p0.
convergedLogical: TRUE when optim reported
convergence.
convergenceInteger: the raw optim
convergence code.
methodCharacter string naming the solver, "dual".
callThe matched call.
There is no universally correct default. The
noise enters per observation and the literal support is
permissive relative to share-valued moment contributions, so at a wide
support or large nu the errors can absorb the signal and pull
toward the prior. In controlled recovery experiments the
estimate approaches the exact markov_ce solution monotonically
as the support narrows () or as nu decreases toward 0,
though an ultra-narrow support can make the over-identified exact problem
numerically unbounded (non-convergence). Users should report sensitivity to
nu and v for their data rather than rely on a single setting.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 7.7.1, eqs. (7.25a), (7.28).
set.seed(1) P_true <- matrix(c(.6,.3,.1, .2,.5,.3, .1,.3,.6), nrow = 3, byrow = TRUE) N <- 120L; Tn <- 5L; K <- 3L Y <- matrix(rgamma(N * K, 1), N, K); Y <- Y / rowSums(Y); inc <- rnorm(N) id <- rep(seq_len(N), each = Tn); tm <- rep(seq_len(Tn), N) sh <- matrix(0, N * Tn, K); income <- numeric(N * Tn); infl <- numeric(N * Tn) for (t in seq_len(Tn)) { idx <- which(tm == t); inc <- 0.8 * inc + rnorm(N, 0, 0.5) sh[idx, ] <- Y; income[idx] <- inc; infl[idx] <- 0.02 * t Y <- (Y %*% P_true) * exp(matrix(rnorm(N * K, 0, 0.03), N, K)); Y <- Y / rowSums(Y) } panel <- data.frame(i = id, t = tm, y1 = sh[, 1], y2 = sh[, 2], y3 = sh[, 3], income = income, infl = infl) fit <- markov_gce(panel, id = "i", time = "t", states = c("y1","y2","y3"), covariates = c("income", "infl"), v = c(-0.2, 0, 0.2), nu = 0.2) coef(fit)set.seed(1) P_true <- matrix(c(.6,.3,.1, .2,.5,.3, .1,.3,.6), nrow = 3, byrow = TRUE) N <- 120L; Tn <- 5L; K <- 3L Y <- matrix(rgamma(N * K, 1), N, K); Y <- Y / rowSums(Y); inc <- rnorm(N) id <- rep(seq_len(N), each = Tn); tm <- rep(seq_len(Tn), N) sh <- matrix(0, N * Tn, K); income <- numeric(N * Tn); infl <- numeric(N * Tn) for (t in seq_len(Tn)) { idx <- which(tm == t); inc <- 0.8 * inc + rnorm(N, 0, 0.5) sh[idx, ] <- Y; income[idx] <- inc; infl[idx] <- 0.02 * t Y <- (Y %*% P_true) * exp(matrix(rnorm(N * K, 0, 0.03), N, K)); Y <- Y / rowSums(Y) } panel <- data.frame(i = id, t = tm, y1 = sh[, 1], y2 = sh[, 2], y3 = sh[, 3], income = income, infl = infl) fit <- markov_gce(panel, id = "i", time = "t", states = c("y1","y2","y3"), covariates = c("income", "infl"), v = c(-0.2, 0, 0.2), nu = 0.2) coef(fit)
Recovers a non-negative matrix (each column a probability
distribution) from column weights x and row-weighted aggregates
y by minimizing the cross-entropy relative to a prior
p0, solving the concentrated dual of Golan (2008), Section 7.2. With
a uniform p0 this reduces to Maximum Entropy. The model is
with solution and
.
matrix_ce(y, x, p0 = NULL, control = list()) ## S3 method for class 'matrix_ce' coef(object, ...) ## S3 method for class 'matrix_ce' fitted(object, ...) ## S3 method for class 'matrix_ce' residuals(object, ...) ## S3 method for class 'matrix_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'matrix_ce' summary(object, ...) ## S3 method for class 'summary.matrix_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...)matrix_ce(y, x, p0 = NULL, control = list()) ## S3 method for class 'matrix_ce' coef(object, ...) ## S3 method for class 'matrix_ce' fitted(object, ...) ## S3 method for class 'matrix_ce' residuals(object, ...) ## S3 method for class 'matrix_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'matrix_ce' summary(object, ...) ## S3 method for class 'summary.matrix_ce' print(x, digits = max(3L, getOption("digits") - 3L), ...)
y |
Numeric vector of length n: the row-weighted aggregates
|
x |
Numeric vector of length m: the column weights (in |
p0 |
Optional n-by-m matrix of strictly-positive prior probabilities
whose columns sum to 1. Defaults to uniform ( |
control |
A named list merged over the defaults and passed to
|
object |
A |
... |
Additional arguments passed to or from methods (currently ignored). |
digits |
Number of significant digits to print. |
The dual is minimised here (convex) to match the package convention used by
inverse_ce:
minimised over the row multipliers (equivalent to maximising the
column entropies subject to the data). The problem is typically
under-determined ( unknowns, constraints), so the
returned matrix is the minimum cross-entropy matrix relative to p0
consistent with the data (the maximum-entropy matrix when p0 is
uniform) – not necessarily the matrix that generated y. To bias the
solution toward a known target, pass that target as p0.
The normalized entropy is (Golan §7.5), the ratio
of the total Shannon entropy to the prior's entropy. For a uniform p0
(Maximum Entropy) (the absolute maximum, columns
uniform over rows), so with when every
column is uniform; for a non-uniform prior is relative to that prior.
summary() reports the §7.5 information measures built on : the
information index , pseudo-, the per-column
normalized entropy , and the entropy-ratio test
for .
An object of class c("matrix_ce", "infometrics"), which is a list
containing the following components:
p, p_hat
n-by-m matrix of estimated column-stochastic
probabilities (two names for the same object). Extracted by
coef.
lambda, lambda_hat
Numeric vector of length n: the estimated row multipliers (two names for the same object).
fitted, fitted.values
Numeric vector of length n:
(two names for the same
object). Extracted by fitted.
residualsNumeric vector of length n:
, the row-aggregate residual. Extracted by
residuals.
entropy, H_signal
Single number: the Shannon entropy
(two names for the same value).
entropy_p0Single number: the prior entropy .
SSingle number: the prior-relative normalized entropy
, which lies in [0, 1] for a
uniform p0.
cross_entropySingle number: the cross-entropy
at the optimum.
objective, value
Single number: the minimised dual objective (two names for the same value).
priorThe resolved n-by-m prior p0.
convergedLogical: TRUE when optim reported
convergence.
convergenceInteger: the raw optim
convergence code.
methodCharacter string naming the solver, "dual".
y, x, n, m
The resolved inputs and their
lengths n = length(y), m = length(x).
callThe matched call.
coef(matrix_ce): Estimated probability matrix (n x m).
fitted(matrix_ce): Fitted row aggregates .
residuals(matrix_ce): Moment residuals fitted.
print(matrix_ce): Compact printed display.
summary(matrix_ce): Summary with the Section-7.5 information measures, the
entropy-ratio test for the signal matrix, and a moment-fit table.
print(summary.matrix_ce): Print method for the summary object.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 7.2.
inverse_ce for the formula-interface
pure-moment ME/CE estimator.
P <- sweep(matrix(1:6, ncol = 2), 2, colSums(matrix(1:6, ncol = 2)), "/") x <- c(3, 2) y <- as.vector(P %*% x) fit <- matrix_ce(y, x) fit$p summary(fit)P <- sweep(matrix(1:6, ncol = 2), 2, colSums(matrix(1:6, ncol = 2)), "/") x <- c(3, 2) y <- as.vector(P %*% x) fit <- matrix_ce(y, x) fit$p summary(fit)
Noisy extension of matrix_ce (Golan 2008, Section 7.4). The
aggregates are treated as stochastic,
with , and the cross-entropy of both the signal
p (columns sum to 1) and the noise w (rows sum to 1) is
minimized relative to priors p0, w0.
matrix_gce(y, x, p0 = NULL, w0 = NULL, v = NULL, nu = 0.5, control = list()) ## S3 method for class 'matrix_gce' coef(object, ...) ## S3 method for class 'matrix_gce' fitted(object, ...) ## S3 method for class 'matrix_gce' residuals(object, ...) ## S3 method for class 'matrix_gce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'matrix_gce' summary(object, ...) ## S3 method for class 'summary.matrix_gce' print(x, digits = max(3L, getOption("digits") - 3L), ...)matrix_gce(y, x, p0 = NULL, w0 = NULL, v = NULL, nu = 0.5, control = list()) ## S3 method for class 'matrix_gce' coef(object, ...) ## S3 method for class 'matrix_gce' fitted(object, ...) ## S3 method for class 'matrix_gce' residuals(object, ...) ## S3 method for class 'matrix_gce' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'matrix_gce' summary(object, ...) ## S3 method for class 'summary.matrix_gce' print(x, digits = max(3L, getOption("digits") - 3L), ...)
y, x
|
Numeric vectors (lengths n and m), each normalized to [0, 1] so the implied errors lie in [-1, 1]. |
p0 |
Optional n-by-m signal prior, columns summing to 1, strictly positive. Default uniform. |
w0 |
Optional n-by-H noise prior, rows summing to 1, strictly positive.
Default uniform; its column count must match |
v |
Noise support, symmetric around 0 in [-1, 1]: |
nu |
Entropy weight in |
control |
A named list merged over the defaults and passed to
|
object |
A |
... |
Additional arguments passed to or from methods (currently ignored). |
digits |
Significant digits to print. |
The dual is minimised here (convex) to match the package convention used by
inverse_noise and matrix_ce:
minimised over the row multipliers, with
(normalised within
each column) and
(normalised within each row); .
Equivalent to maximising the joint signal-plus-noise entropy subject to the
stochastic-moment constraints.
The weight (an extension to Eq. 7.22) balances prediction
against precision by trading signal entropy against noise entropy. At
this is the equal-weight GCE of Eq. (7.22) and the estimates
coincide with it (only the scale differs). As the noise support
v shrinks toward 0 the noise is forced out and the solution returns to
matrix_ce.
An object of class c("matrix_gce", "infometrics"), which is a list
containing the following components:
p, p_hat
n-by-m matrix of estimated column-stochastic
signal probabilities (two names for the same object). Extracted by
coef.
w, w_hat
n-by-H matrix of estimated row-stochastic noise probabilities (two names for the same object).
eNumeric vector of length n: the estimated noise,
.
lambda, lambda_hat
Numeric vector of length n: the estimated row multipliers (two names for the same object).
nuSingle number: the entropy weight used.
fitted.valuesNumeric vector of length n: .
Extracted by fitted.
residualsNumeric vector of length n:
, which equals e at a converged
optimum. Extracted by residuals.
entropy_p, H_signal
Single number: the signal entropy
(two names for the same value).
entropy_wSingle number: the noise entropy
.
entropy_p0, entropy_w0
Single numbers: the signal and
noise prior entropies and .
S_p, S
Single number: the normalized signal entropy
(two names for the same value).
S_wSingle number: the normalized noise entropy
.
objective, value
Single number: the minimised dual objective (two names for the same value).
signal_prior, noise_prior
The resolved priors
p0 (n-by-m) and w0 (n-by-H).
supportNumeric vector of length H: the resolved noise
support v.
convergedLogical: TRUE when optim reported
convergence.
convergenceInteger: the raw optim
convergence code.
methodCharacter string naming the solver, "dual".
callThe matched call.
coef(matrix_gce): Estimated signal matrix p.
fitted(matrix_gce): Fitted aggregates .
residuals(matrix_gce): Residuals (the estimated noise e).
print(matrix_gce): Compact display.
summary(matrix_gce): Summary with the Section-7.5 information measures
and entropy-ratio test for the signal matrix.
print(summary.matrix_gce): Print method for the summary object.
Golan, A. (2008). Information and Entropy Econometrics - A Review and Synthesis. Foundations and Trends in Econometrics, 2(1-2), 1-145. Section 7.4.
matrix_ce (the exact-moment version this reduces to as
v shrinks to 0).
set.seed(1) P <- matrix(runif(6), ncol = 2); P <- sweep(P, 2, colSums(P), "/") x <- c(0.6, 0.3); y <- as.vector(P %*% x) fit <- matrix_gce(y, x, nu = 0.5) coef(fit) # estimated signal matrix p residuals(fit) # y - Px (= estimated noise e) summary(fit)set.seed(1) P <- matrix(runif(6), ncol = 2); P <- sweep(P, 2, colSums(P), "/") x <- c(0.6, 0.3); y <- as.vector(P %*% x) fit <- matrix_gce(y, x, nu = 0.5) coef(fit) # estimated signal matrix p residuals(fit) # y - Px (= estimated noise e) summary(fit)
Fits the Generalized Cross-Entropy "mixed" model in which the signal
probabilities are themselves reparameterized on a bounded support. From a
share response Y (N x J) and a design array X (N x J x K) it
recovers the coefficients (K x J), the per-observation adding-up
multipliers (N), the signal weights (N x J x M) with
, and the noise weights (N x J x H)
with , via the concentrated dual.
mixed_gce( Y, X, theta0 = NULL, w0 = NULL, s = NULL, u = NULL, nu = 0.5, control = list() )mixed_gce( Y, X, theta0 = NULL, w0 = NULL, s = NULL, u = NULL, nu = 0.5, control = list() )
Y |
N x J numeric response matrix of shares (rows are compositional, summing to about 1 up to the noise term). |
X |
N x J x K design array ( |
theta0 |
Optional N x J x M signal prior (each |
w0 |
Optional N x J x H noise prior (each |
s |
Signal support in |
u |
Noise support in |
nu |
Signal/noise entropy weight in |
control |
Named list merged over defaults and passed to
|
With ,
and
. The dual is
maximized (fnscale = -1):
whose first-order conditions are the adding-up constraint
(in ) and the data moment
(in ). Uniform
priors give the GME (maximum-entropy) solution; user priors give GCE. As the
noise support the fit approaches the pure-signal solution.
An object of class c("mixed_gce", "infometrics"), which is a list
containing the following components:
lambda, lambda_hat
K-by-J matrix of estimated
coefficients (two names for the same object). Extracted by
coef.
rho, rho_hat
Numeric vector of length N: the
per-observation adding-up multipliers enforcing
(two names for the same object).
theta, theta_hat
N-by-J-by-M array of
doubly-reparameterized signal weights, each fiber summing to
1, with
(two
names for the same object).
p, p_hat, fitted.values
N-by-J matrix of
estimated signal probabilities, rows summing to 1 (three names for the
same object). Extracted by fitted.
w, w_hat
N-by-J-by-H array of estimated noise
probabilities, each fiber summing to 1 (two names for the
same object).
e, e_hat
N-by-J matrix of estimated noise,
(two
names for the same object). The residuals returned by
residuals are .
VN-by-J matrix of linear indices
.
vcovCovariance matrix of the full parameter vector from the
dual Hessian, of dimension
with the block first, then . NA
throughout if the Hessian was singular. Extracted by vcov.
se_lambda, se_rho
Standard errors of
(K-by-J) and
(length N), taken from vcov. Being the naive Hessian inverse these
are conservative; for accurate marginal-effect standard errors use
margins with se = TRUE.
hessianDual Hessian at the optimum, of the same dimension as
vcov.
X, y_mat
The resolved design array (N-by-J-by-K) and response matrix (N-by-J).
s, u
The resolved signal support (length M, in
) and noise support (length H, symmetric in ).
theta0, w0, nu
The resolved signal prior (N-by-J-by-M), noise prior (N-by-J-by-H) and entropy weight.
H_signalNumeric vector of length N: the per-observation
signal entropies of , summed over the J
categories and M support points.
S, S_p
Single number: the normalized signal entropy
, in [0, 1] (two
names for the same value). It is measured against the uniform
distribution, not against theta0.
S_wSingle number: the normalized noise entropy
, in [0, 1].
objective, value
Single number: the maximized dual objective (two names for the same value).
convergenceInteger: the raw optim
convergence code.
convergedLogical: TRUE when optim reported
convergence.
methodCharacter string naming the solver, "dual".
N, J, K, M, H
Integers: the numbers of observations, categories, covariates, signal support points and noise support points.
callThe matched call.
Golan, A., Judge, G. and Perloff, J.M. (1996). A maximum entropy approach to recovering information from multinomial response data. Journal of the American Statistical Association, 91(434), 841-853.
multinomial_gce (the reference-normalized sibling),
margins for marginal effects.
set.seed(1) N <- 25L; J <- 3L; K <- 2L X <- array(0, dim = c(N, J, K)) X[, , 1] <- 1 # intercept-like column X[, , 2] <- matrix(rnorm(N * J), N, J) # a covariate Y <- matrix(runif(N * J), N, J); Y <- Y / rowSums(Y) # compositional shares fit <- mixed_gce(Y, X, nu = 0.5) coef(fit) # lambda (K x J) margins(fit) # K x J average marginal effects margins(fit, se = TRUE) # ... with robust sandwich SEs head(fano_bounds(fit)) # Fano error bounds (Golan sec 7.5)set.seed(1) N <- 25L; J <- 3L; K <- 2L X <- array(0, dim = c(N, J, K)) X[, , 1] <- 1 # intercept-like column X[, , 2] <- matrix(rnorm(N * J), N, J) # a covariate Y <- matrix(runif(N * J), N, J); Y <- Y / rowSums(Y) # compositional shares fit <- mixed_gce(Y, X, nu = 0.5) coef(fit) # lambda (K x J) margins(fit) # K x J average marginal effects margins(fit, se = TRUE) # ... with robust sandwich SEs head(fano_bounds(fit)) # Fano error bounds (Golan sec 7.5)
Fits an unordered multinomial response model by the Generalized Cross-Entropy
estimator of Golan, Judge & Perloff (1996), extended with a signal/noise
entropy weight nu. Recovers an N x J signal probability matrix and the
N x J x M noise weights from a one-hot / share response matrix y and a
design matrix X, via the concentrated dual over the free
Lagrange multipliers (one alternative normalized to zero).
multinomial_gce( y, X, which_alternative = 1L, p0 = NULL, w0 = NULL, v = NULL, nu = 0.5, control = list() )multinomial_gce( y, X, which_alternative = 1L, p0 = NULL, w0 = NULL, v = NULL, nu = 0.5, control = list() )
y |
N x J numeric response matrix: rows are one-hot indicators or compositional shares summing to 1. |
X |
N x K design matrix. |
which_alternative |
Integer in |
p0 |
Optional N x J signal prior (rows sum to 1, strictly positive);
default uniform |
w0 |
Optional N x J x M noise prior ( |
v |
Error support: |
nu |
Signal/noise entropy weight in |
control |
Named list merged over defaults and passed to
|
and
, with
. The dual is maximized
(fnscale = -1): , , and the free gradient
is dropping the normalized column.
At , which_alternative = 1, and a matched support this
recovers the same Golan-Judge-Perloff (1996) multinomial GME estimate. The
new pieces are nu, the matrix (y, X) interface, and
which_alternative. coef() returns the multipliers
lambda (not a transformed beta).
Because the GCE noise forces the reference alternative's error to zero, the
arbitrary which_alternative choice slightly shifts the fitted
probabilities (a model property, not a numerical artefact).
An object of class c("multinomial_gce", "infometrics"), which is a
list containing the following components:
lambda, lambda_hat
K-by-J matrix of estimated Lagrange
multipliers (two names for the same object). The reference alternative's
column is 0. Extracted by coef.
p, p_hat, fitted.values
N-by-J matrix of
estimated signal probabilities, rows summing to 1 (three names for the
same object). Extracted by fitted.
w, w_hat
N-by-J-by-M array of estimated noise
probabilities, each fiber summing to 1 (two names for the
same object).
ee, e
N-by-J matrix of estimated noise,
(two
names for the same object). The residuals returned by
residuals are .
p0, w0, v, nu
The resolved signal prior (N-by-J), noise prior (N-by-J-by-M), noise support (length M) and entropy weight.
objective, value
Single number: the maximized dual objective (two names for the same value).
convergenceInteger: the raw optim
convergence code.
convergedLogical: TRUE when optim reported
convergence.
methodCharacter string naming the solver, "dual".
H_signalNumeric vector of length N: the per-observation
signal entropies .
SSingle number: S_p + S_w, so it lies in [0, 2]. Note
that this differs from the other estimators in the package, where
S is the normalized signal entropy alone.
S_p, S_w
Single numbers: the normalized signal and
noise entropies, and
, each in [0, 1]. These
are measured against the uniform distribution, not against p0 and
w0.
y_mat, X
The resolved response matrix (N-by-J) and design matrix (N-by-K).
seK-by-J matrix of standard errors of
. The reference alternative's column is 0
(that alternative is normalized, not estimated). These come from the
naive Hessian inverse and are conservative; for accurate marginal-effect
standard errors use margins with se = TRUE.
vcovCovariance matrix of the free multipliers, of
dimension – the reference
alternative is excluded. NA throughout if the Hessian was
singular.
hessianDual Hessian at the optimum, over the same free
multipliers as vcov.
which_alternativeInteger: the index of the reference alternative.
n_missesInteger: the number of observations whose modal fitted alternative differs from the modal observed one.
N, J, K, M
Integers: the numbers of observations, alternatives, covariates and noise support points.
callThe matched call.
Golan, A., Judge, G. and Perloff, J.M. (1996). A maximum entropy approach to recovering information from multinomial response data. Journal of the American Statistical Association, 91(434), 841-853.
margins for marginal effects, fano_bounds
for information-theoretic error bounds.
set.seed(123) n <- 200L; J <- 3L; x <- rnorm(n); X <- cbind(1, x) bt <- cbind(c(0, 0), c(1, 2), c(-0.5, -1)) P <- exp(X %*% bt); P <- P / rowSums(P) yc <- apply(P, 1, function(p) sample(J, 1, prob = p)) Y <- matrix(0, n, J); Y[cbind(seq_len(n), yc)] <- 1 fit <- multinomial_gce(Y, X, which_alternative = 1L, nu = 0.5) coef(fit) # lambda (K x J, reference column 0) margins(fit) # K x J average marginal effects margins(fit, se = TRUE) # ... with delta-method standard errors head(fano_bounds(fit)) # Fano error bounds for p_hat (Golan sec 7.5)set.seed(123) n <- 200L; J <- 3L; x <- rnorm(n); X <- cbind(1, x) bt <- cbind(c(0, 0), c(1, 2), c(-0.5, -1)) P <- exp(X %*% bt); P <- P / rowSums(P) yc <- apply(P, 1, function(p) sample(J, 1, prob = p)) Y <- matrix(0, n, J); Y[cbind(seq_len(n), yc)] <- 1 fit <- multinomial_gce(Y, X, which_alternative = 1L, nu = 0.5) coef(fit) # lambda (K x J, reference column 0) margins(fit) # K x J average marginal effects margins(fit, se = TRUE) # ... with delta-method standard errors head(fano_bounds(fit)) # Fano error bounds for p_hat (Golan sec 7.5)
Rescales a numeric vector so that all values lie in [0, 1] by dividing by the maximum absolute value. Useful for pre-scaling moment matrices before ME/CE estimation to avoid numerical overflow in the exponential terms of the partition function.
normalize_data(x, by = c("max", "range"))normalize_data(x, by = c("max", "range"))
x |
Numeric vector or matrix. |
by |
Character. Either |
Golan (2008, Section 7.1) notes that normalization is often necessary when data contain exponential terms (as in the partition function Omega), since the concentrated (dual) ME/CE model involves expressions of the form exp(lambda * x). A common normalization is dividing each element by max{x_j, y_i}.
A numeric vector or matrix of the same dimensions as x,
scaled to [0, 1].
x <- c(10, 30, 50, 20, 40) normalize_data(x) normalize_data(x, by = "range")x <- c(10, 30, 50, 20, 40) normalize_data(x) normalize_data(x, by = "range")
Estimates the panel regression by dual Generalized Cross-Entropy (Lee & Cheon 2014, eq.
3.12), extended with priors p0, g0, w0 and a
signal/noise weight nu. The coefficients , the individual
effects , and the errors are each
reparameterized on bounded supports and recovered jointly via the
concentrated dual over the Lagrange multipliers.
panel_gce( y, X, Z, tt, FF, p0 = NULL, g0 = NULL, v = NULL, w0 = NULL, nu = 0.5, layout = c("period", "unit"), vcov_type = c("within", "cluster", "disturbance"), control = list() )panel_gce( y, X, Z, tt, FF, p0 = NULL, g0 = NULL, v = NULL, w0 = NULL, nu = 0.5, layout = c("period", "unit"), vcov_type = c("within", "cluster", "disturbance"), control = list() )
y |
Numeric response vector of length |
X |
|
Z |
Coefficient (signal) support: a K-by-M matrix, row k the support for
|
tt |
Integer number of time periods (balanced panel; |
FF |
Individual-effects support: an N-by-R matrix, row n the support for
|
p0 |
Optional K-by-M signal prior (rows > 0, summing to 1); default uniform. |
g0 |
Optional N-by-R effects prior (rows > 0, summing to 1); default uniform. |
v |
Optional error support: |
w0 |
Optional |
nu |
Signal/noise entropy weight in |
layout |
How |
vcov_type |
Covariance estimator for
The |
control |
Named list merged over defaults and passed to
|
With (support Z, prior p0),
(support FF, prior g0), and
(support v, prior w0), the dual
is maximized (fnscale = -1); and are weighted by
nu, the errors by 1 - nu. The gradient is the model equation
, so at the optimum it holds to numerical zero
(foc_residual). As the supports widen the estimate approaches the
within (fixed-effects) estimate.
Standard errors follow Lee & Cheon (2014, Sec. 3.3). Because is
estimated, is identified from within-unit variation, so its
sampling variance is the within (fixed-effects) form (option vcov_type = "within", the default and
the most accurate in Monte Carlo). The paper's stated asymptotic variance
(eq. 3.17) with the composite disturbance is available
as vcov_type = "disturbance" (it is conservative here). SEs for
and are obtained by the delta method from : and (the latter a finite- prediction
SE, since individual effects are not -consistent). X must
not include an intercept column (the individual effects subsume the level;
a constant column makes the within design singular).
An object of class c("panel_gce", "infometrics") with
coefficients/b_hat (, K; coef() returns it),
mu_hat (N individual effects), e_hat (N*tt errors),
p_hat/g_hat/w_hat (reparameterization weights),
lambda_hat, fitted.values, residuals,
foc_residual, H_p/H_g/H_w, H_signal,
S_p/S, objective/value, converged/
convergence, method, nu, v, layout, the
stored inputs, and call. Standard errors: vcov (K-by-K,
accessible via vcov), se_beta (K), se_p
(K-by-M), se_mu (N), sigma2_eps, and vcov_type.
Lee, S. and Cheon, S. (2014). Dual generalized maximum entropy estimation for panel data regression models. Communications for Statistical Applications and Methods, 21(5), 395-409.
linreg for the (non-panel) GME/GCE regression.
set.seed(1) N <- 20L; T <- 4L; K <- 2L mu <- rnorm(N) # individual effects id <- rep(seq_len(N), each = T) # unit-major ordering X <- matrix(rnorm(N * T * K), N * T, K) y <- as.vector(X %*% c(1.5, -0.8)) + mu[id] + rnorm(N * T, 0, 0.5) Z <- matrix(c(-10, 0, 10), nrow = K, ncol = 3, byrow = TRUE) # beta support FF <- matrix(c(-6, 0, 6), nrow = N, ncol = 3, byrow = TRUE) # mu support fit <- panel_gce(y, X, Z, tt = T, FF = FF, layout = "unit") coef(fit) # ~ (1.5, -0.8) (within/FE estimate)set.seed(1) N <- 20L; T <- 4L; K <- 2L mu <- rnorm(N) # individual effects id <- rep(seq_len(N), each = T) # unit-major ordering X <- matrix(rnorm(N * T * K), N * T, K) y <- as.vector(X %*% c(1.5, -0.8)) + mu[id] + rnorm(N * T, 0, 0.5) Z <- matrix(c(-10, 0, 10), nrow = K, ncol = 3, byrow = TRUE) # beta support FF <- matrix(c(-6, 0, 6), nrow = N, ncol = 3, byrow = TRUE) # mu support fit <- panel_gce(y, X, Z, tt = T, FF = FF, layout = "unit") coef(fit) # ~ (1.5, -0.8) (within/FE estimate)
Computes the Shannon entropy H(p) = -sum(p * log(p)), using the natural logarithm (nats) by default. The convention 0 * log(0) = 0 is applied.
shannon_entropy(p, base = exp(1))shannon_entropy(p, base = exp(1))
p |
Numeric vector of probabilities. Must be non-negative and sum to 1. |
base |
Positive numeric. Logarithm base. Use |
Shannon's entropy measure satisfies three axioms: normalization (maximum
entropy for uniform distributions), continuity, and additivity for
independent sub-systems. It equals zero if and only if all probability
mass is concentrated on a single outcome (perfect certainty) and reaches
its maximum value of log(K) for the uniform distribution over K
outcomes. See Golan (2008, Section 3.1) for a detailed treatment.
A single non-negative numeric value. Returns 0 for a degenerate
(point-mass) distribution and log(length(p)) for the uniform
distribution.
Golan, A. (2008). Information and Entropy Econometrics. Foundations and Trends in Econometrics, 2(1-2), 1-145.
Shannon, C.E. (1948). A mathematical theory of communication. Bell System Technical Journal, 27, 379-423.
# Uniform distribution over 6 outcomes (maximum entropy) shannon_entropy(rep(1/6, 6)) # Non-uniform distribution (lower entropy) shannon_entropy(c(0.5, 0.3, 0.2)) # In bits (base 2) shannon_entropy(rep(1/2, 2), base = 2) # = 1 bit# Uniform distribution over 6 outcomes (maximum entropy) shannon_entropy(rep(1/6, 6)) # Non-uniform distribution (lower entropy) shannon_entropy(c(0.5, 0.3, 0.2)) # In bits (base 2) shannon_entropy(rep(1/2, 2), base = 2) # = 1 bit