*! version 1.0.1 21aug2026

Title

gvar clear -- drop the GVAR from memory

Syntax

gvar clear [, nosummary]

Description

gvar clear drops the fitted model. It leaves the compiled Mata engine in
place, so the next gvar setup starts immediately instead of
recompiling.

It is not an error to run it when there is no model; it says so and exits.

Options

gvar clear takes no options. It drops the model from Mata memory and leaves
the data alone.

Use it rather than clear all between specifications in a do-file.
clear all also drops every program and Mata function defined in the
session, which in a test file means the reporting programs vanish and the run
dies with "command not recognized" several lines later.

Remarks

There is no undo. If the model took minutes to fit, run
gvar save first.

You rarely need it. gvar setup replaces any existing
model, so the ordinary way to start again is simply to set up again. Use
gvar clear when you want to free the memory, when you are about to
gvar use a saved model, or when you want a later
gvar subcommand to fail loudly rather than quietly report results from a
model you had forgotten was there.

How this relates to Stata's own clearing commands.

gvar clear drops the model, keeps the engine.

clear all drops both, and everything else.

discard drops neither. Interactively compiled Mata survives
discard, which is worth knowing when you are editing the package
yourself: after changing a Mata function you must clear all, not
discard, or you will keep running the old code.

Examples

. gvar clear

Save, drop, restore

. gvar save demo_fitted, replace
. gvar clear
. gvar use demo_fitted

Source

Utility command; see gvar save.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane