The Virata manual
Virata reads a language that looks like Stata’s and does the work in Python. This is every command it understands, in plain English, with the technical word in brackets after it. Every example on this site was run while the page was being written.
What we have
- 86 commands, each with its own page and a runnable example
- 22 chart types
- survey estimation with a real design, survival analysis, and the basics of time series
- pandas shown for every command, and R for 46 of them
Coming later
- nothing has been compared with real Stata; much of it is checked against R — what that means
- panel data (
xtset,xtreg) - postestimation:
predict,test,margins - 84 more catalogue chart types
Getting data in and out
Opening a file, saving one, and finding your way around the folders.
useOpens a data file that is already on your computer and puts it in memory.
saveWrites the dataset in memory out to a file.
sysuseOpens one of the four example datasets that come with Virata.
importReads a spreadsheet or a text file into memory.
exportWrites the dataset in memory out as a spreadsheet or a text file.
clearThrows away the dataset in memory.
browseOpens the data in a spreadsheet-like window so you can scroll through it.
editOpens the data viewer, the same window browse opens.
cdMoves you to a different folder.
pwdTells you which folder you are currently in.
dirLists the files in the current folder.
lsLists the files in the current folder — the same command as dir.
Looking at what you have
Before you analyse anything, find out what is actually in the file.
describeLists every column: its name, what kind of thing it holds, and what it means.
codebookGoes through variables one at a time and says what is really in them.
listPrints the actual rows to the screen.
countCounts rows — all of them, or only those meeting a condition.
misstableCounts the blanks (missing values) in each column.
duplicatesFinds rows that appear more than once.
assertStops with an error unless something you believe is true of every row.
isidChecks that a column (or a set of them) identifies each row uniquely.
Making and changing variables
Adding columns, fixing values, renaming, sorting, labelling.
generateAdds a new column, worked out from the ones you already have.
replaceChanges values in a column you already have.
egenAdds a column holding a group summary — the group's average, total, biggest.
recodeTurns values into other values by rule — ages into age bands, say.
renameGives a column a different name.
orderMoves columns to the front so they are the first thing you see.
dropRemoves columns, or removes rows.
keepThe opposite of drop: keeps only what you name and removes the rest.
sortPuts the rows in order, smallest first.
gsortSorts with a direction you choose for each column.
labelAttaches readable text to a column, or to the codes inside it.
encodeTurns a text column into numbered categories.
decodeTurns a coded number back into the words it stands for.
destringTurns a column of text that is really numbers into actual numbers.
tostringTurns a number column into text.
preserveTakes a snapshot of the data so you can get it back.
restorePuts back the data that preserve saved.
Putting datasets together
Joining, stacking, summarising down to one row per group, reshaping.
mergeJoins another file onto this one side by side, matching on a shared key.
appendStacks another file underneath this one.
joinbyPairs up every matching row on both sides — a many-to-many join.
crossPairs every row here with every row in the other file.
collapseReplaces the data with one row per group, holding summaries.
contractReplaces the data with one row per combination, and a count.
reshapeSwaps the data between wide and long shape.
Describing the numbers
Averages, tables, correlations and the two-group test.
summarizeThe standard summary of a number column.
tabulateCounts how many rows fall in each category, or in each pair of categories.
tabstatOne compact table of exactly the statistics you ask for.
correlateShows how strongly each pair of columns moves together.
pwcorrThe same correlation grid, but each pair uses every row it can.
ttestAsks whether two groups really differ on average, or whether a mean differs from a number.
meanThe average, together with how precise that average is.
totalThe sum, together with how precise that sum is.
proportionThe share of rows in each category, with a margin of error.
Fitting models
Explaining one column with several others, whatever kind of column it is.
regressExplains a number using other columns, by fitting a straight line.
logitExplains a yes/no outcome.
probitExplains a yes/no outcome, with a slightly different curve.
poissonExplains a count — how many times something happened.
nbregExplains a count that is more spread out than Poisson allows.
ologitExplains an outcome with ordered categories — poor, fair, good, excellent.
oprobitThe same ordered-category model, with the bell-curve shape.
mlogitExplains a choice among categories with no order.
coefplotDraws the coefficients of the model you just fitted, with their error bars.
Survey data
Results that respect how the sample was drawn, not just how big it is.
svysetTells Virata how the sample was drawn, once, before any survey command.
svy: meanThe average for the whole population, from a survey sample.
svy: totalThe population total, from a survey sample.
svy: proportionThe share of the population in each category, from a survey sample.
svy: ratioThe ratio of one population total to another.
svy: regressRegression that respects the survey design.
svy: tabulateCross-tabulation with survey-correct percentages and test.
How long until something happens
Time-to-event work, where some people have not had the event yet.
stsetDeclares which column is the time and which says the event happened.
stsShows the share still surviving as time passes, and tests groups against each other.
stcoxExplains how long people last, using several columns at once.
Series over time
Lags, differences, smoothing and seasonality.
tssetDeclares which column is time, so lags and differences know what they mean.
tslineDraws one or more series against time.
tssmoothSmooths a bumpy series by averaging each point with its neighbours.
tsdecompSplits a series into its trend, its seasonal pattern and what is left.
Charts
Twenty-one chart types, each drawn as a self-contained web page.
Settings, help and the session
Switching language, protecting small numbers, macros, saved logs.
setChanges how the session behaves.
logRecords everything that appears on screen into a file.
helpShows the built-in help, at the prompt.
manualOpens this manual in your browser, at the page for whatever you name.
recipeWorked examples you can read, run or copy and edit.
displayPrints something to the screen.
localStores a piece of text or a number under a name, for the session.
globalThe same idea as local, visible everywhere.
macroShows or clears the macros you have defined.
Reference
Conditions, functions and operatorsThe small language you type inside if, generate and replace.
What is not built, and how far to trust what isRead this before you rely on a number.
Typing Python or R insteadSwitch the prompt to Python or to R, on the same dataset, and switch back.
Hiding small numbersStop a table from pointing at two identifiable people.
Seeing the Python or the RPrint every command in another language as you run it.
Chart galleryThe 21 chart types, and the ones still to come.