cmr.ConditionalMomentEstimator
Guide & worked example · Source
cmr.ConditionalMomentEstimator(
model,
moment_function,
optimizer=torch.optim.LBFGS,
maxiter=100,
lr=1.0,
dtype=torch.float32,
device=None,
**optimizer_kwargs,
)Base class for neural conditional moment estimators.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| model | torch.nn.Module | Structural model mapping treatments/features t to predictions. |
required |
| moment_function | callable | Function moment_function(prediction, y) returning an (n, q) moment matrix. For NPIV this is often prediction - y. |
required |
| optimizer | torch optimizer class | Optimizer used to update model.parameters(). |
torch.optim.LBFGS |
| maxiter | int | Number of optimizer iterations. For LBFGS this is passed as max_iter. |
100 |
| lr | float | Optimizer learning rate. | 1.0 |
Attributes
| Name | Description |
|---|---|
device |
|
dtype |
|
history |
|
lr |
|
maxiter |
|
model |
|
moment_function |
|
optimizer_class |
|
optimizer_kwargs |
|
params |
Methods
| Name | Description |
|---|---|
| fit | Fit the model to the data. |
| moments | Evaluate sample moments at the current model parameters. |
| predict | Predict with the fitted structural model. |
| summary | Print a summary of the model results. |
| to |
fit
cmr.ConditionalMomentEstimator.fit(*args, **kwargs)Fit the model to the data.
moments
cmr.ConditionalMomentEstimator.moments(t, y)Evaluate sample moments at the current model parameters.
predict
cmr.ConditionalMomentEstimator.predict(t)Predict with the fitted structural model.
summary
cmr.ConditionalMomentEstimator.summary()Print a summary of the model results.
to
cmr.ConditionalMomentEstimator.to(device)