Command reference — Stata-class syntax, GPU-accelerated by Apple Silicon.
Every command follows one grammar:
command [varlist] [if] [in] [, options]
Data management
use
Load a dataset into memory. Format is inferred from the extension: .parquet, .csv, .tsv, .json, .arrow, and Stata .dta (formats 117–119).
use filename
. use sales.parquet
. use ~/data/panel.dta
Loading goes through DuckDB for columnar formats and a native reader for .dta. The sandboxed app reads user-selected files and its own container.
sysuse
Load a sample dataset shipped with Metrika. Bare `sysuse` lists what is available.
sysuse [name]
. sysuse sales
. sysuse mtcars
sales: 200-firm × 5-year panel (revenue, price, region, employees). mtcars: the R classic, with a string model column.
save
Write the working dataset to disk (.parquet, .csv, or Stata .dta format 118).
save filename [, replace]
replace
overwrite an existing file
. save results.dta, replace
clear
Drop the working dataset from memory.
clear
describeabbreviation: d
List variables with their storage types and missing counts.
describe
listabbreviation: l
Print observations (first 50 shown).
list [varlist] [if] [in]
. list revenue price in 1/10
countabbreviation: cou
Count observations satisfying a condition.
count [if]
. count if revenue > 100 & !missing(price)
generateabbreviation: gen
Create a new variable from an expression. Observations excluded by `if` become missing.
generate newvar = expression [if] [in]
. gen log_rev = ln(revenue)
. gen high = revenue > 120 if !missing(revenue)
Functions: ln, log, log10, exp, sqrt, abs, floor, ceil, round, int, min, max, missing. Missing values propagate through arithmetic; division by zero and ln of a nonpositive number yield missing.
replace
Overwrite values of an existing variable; reports the number of real changes.
replace varname = expression [if] [in]
. replace flag = 0 if missing(flag)
drop
Remove variables, or observations with `if`/`in`.
drop varlist | drop if expression | drop in range
. drop temp1 temp2
. drop if price < 0
keep
Keep only the listed variables, or only observations satisfying a condition.
keep varlist | keep if expression | keep in range
. keep in 1/1000
Descriptive statistics
summarizeabbreviation: su
Means, standard deviations, and ranges; `detail` adds percentiles, skewness, and kurtosis (Stata definitions).
summarize [varlist] [if] [in] [, detail]
detail
percentiles p1–p99, skewness, kurtosis
. summarize revenue price, detail
tabulateabbreviation: tab
One-way frequency table or two-way cross-tabulation with totals.
tabulate varname [varname2] [if] [, missing]
missing
include missing values as a category
. tab region
. tabulate region purchase
correlateabbreviation: cor
Pearson correlation matrix with listwise deletion.
correlate [varlist] [if]
. correlate revenue price orders
Estimation
regressabbreviation: reg
Ordinary least squares via LAPACK QR. Factor variables (i.var) expand to indicators; c.a#c.b forms continuous interactions.
Replicates are counter-addressable: any subset recomputes identically regardless of chunking or backend. The planner dispatches ≥500 reps to the GPU when available.
bayes
Bayesian linear regression by Gibbs sampling: posterior means, standard deviations, and 95% credible intervals.
Average marginal effects with delta-method standard errors. After OLS/IV the effect is the coefficient; after logit/probit/poisson it averages dμ/dx over the estimation sample.
margins, dydx(varlist) [level(#)]
. logit purchase price
. margins, dydx(price)
Continuous regressors only for now; factor and interaction terms are rejected with a message.
Graphics
scatter
Scatter plot (also available as `graph scatter`). `by()` splits into colored series.
scatter yvar xvar [if] [, by(varname)]
. scatter log_rev price, by(region)
histogramabbreviation: hist
Frequency histogram of one variable (Sturges bins by default).
histogram varname [if] [, bins(#)]
bins(#)
override the bin count
. histogram revenue, bins(12)
kdensityabbreviation: kden
Kernel density estimate (Epanechnikov kernel, Silverman bandwidth).
kdensity varname [if]
. kdensity revenue
graphabbreviation: gr
General plotting front end: graph scatter, graph line, graph histogram.
graph scatter|line yvar xvar [if] [, by(varname)]
. graph line gdp year
Panel data
xtset
Declare the panel structure (unit and, optionally, time variable) for xtreg.
xtset panelvar [timevar]
. xtset firm_id year
Session & scripting
displayabbreviation: di
Evaluate and print an expression.
display expression
. display 2 + 2 * 3
. display ln(100)
log
Record commands and output to a text file.
log using filename | log close
. log using session.log
help
Show this reference, or the entry for one command.
help [command]
. help regress
User commands
zscore
Sample native plugin: generates z_varname, the standardized version of a variable.
zscore varname
. zscore revenue
Native plugins are Swift types conforming to ZQCommandPlugin, compiled into the app. Script commands are .zyq files in ~/Library/Application Support/Metrika/Commands/ — an optional leading `args name…` line names positional arguments, referenced as `name' or `1' in the body.