For chapter navigation, search and expandable alternatives, open the Stata to R Reference. The book has English and Chinese editions with a language switch on each chapter. This page remains available as the single-page reference.
If you know Stata, you already know what you want to do; the question is how to say it in R. This page lists Stata commands next to the R code that does the same job, using tidystata where it has a Stata-style function and the standard package everywhere else.
Look it up from the console
findit() searches the same list from R. Type one Stata
word bare, or quote anything longer. Stata’s abbreviations work.
findit(reg)
#> # Linear regression [stats]
#> Stata: regress y x1 x2
#> R: fit <- lm(y ~ x1 + x2, data = data)
#> # Note: summary(fit) shows the coefficient table; broom::tidy(fit) returns it as a data frame.
#>
#> # 17 more examples. To see them all: findit(reg) |> print(n = Inf)
findit("merge 1:1 id, keep(match)")
#> # Keep matched rows only [dplyr]
#> Stata: merge 1:1 id using data2, keep(match)
#> R: inner_join(data1, data2, by = "id")
#> # Note: dplyr retains overlapping non-key columns with suffixes instead of Stata master values, creates no _merge, and does not enforce a declared 1:1 key constraint.
#>
#> # merge() [base]: Merge two data frames (base R)
#> Related Stata: merge
#>
#> # 17 more examples. To see them all: findit("merge 1:1 id, keep(match)") |> print(n = Inf)You can also look up an R function (findit(left_join))
or ask a question
(findit("how do I remove duplicate rows")). The console
shows the best matches; the returned table contains all matches. Call
findit() for the whole list. Descriptions follow R’s
language setting; English and Chinese queries both work.
Comma-separated names customize compatible examples, such as
findit(tab, sex, region). The default shows one preferred
answer when the task is clear;
findit(tab) |> print(n = Inf) shows all variants,
selected alternative R approaches, qualifications and source links.
Package-qualified lookups such as findit(dplyr::filter)
distinguish functions with the same name.
This reference contains 514 command families, 181 Stata functions and 3 operators, with 1716 distinct Stata examples and 1782 paired R examples. Abbreviations and alternative R implementations do not increase the command count. The R index describes 949 function/package pairs.
Use the command tables
The tables cover tidystata and other R packages, including modelling,
reshaping, survey analysis and graphics. For panel lags and leads,
tidystata provides stata_lag(), stata_lead()
and stata_diff(); specify the time column and use
.by to identify panels.
The index is alphabetical; tables are grouped by subject and sorted
by command, preferred answer and example. A package named beside a
snippet is needed to run that snippet, but findit() itself
does not load or install reference packages. The label names the primary
package, rather than every helper dependency; the R function index
identifies additional functions and their packages.
A note that begins Differs from Stata means the R code does the same job, but a default, the missing-value handling, an estimator or the output layout differs; the note says how. Other notes are practical tips. Most R snippets are run against controlled checks when the catalogue is built; this tests the R code itself, not numerical agreement with Stata. Missing-value comparisons, weights, factor reference levels, join rules and standard-error corrections need particular care. Known gaps are explained explicitly, and related search results are not a translation of unsupported syntax.
In the tables below, data is your dataset,
data1 and data2 are the master and using data
of a merge, and fit is a fitted model. Most entries use
dplyr, so attach it with library(dplyr) or
library(tidyverse).
Alphabetical command index
F · Fden · Ftail · about · ac · ado · adopath · alpha · ameans · anova · append · arch · areg · arfima · arfimasoc · args · arima · arimasoc · assert · assertnested · avplots · bayesboot · bayesmh · bayespredict · bayesreps · bayesstats · bayestest · betaden · betareg · binomial · binomialp · binomialtail · binormal · binreg · binscatter · biprobit · bitest · bitesti · bootstrap · boottest · boxcox · brier · browse · bsample · bsqreg · bstat · ca · camat · candisc · canon · capture · carryforward · cauchy · cauchyden · cauchytail · cc · cci · cd · ceil · cem · centile · cf · changeeol · char · checksum · chi2 · chi2den · chi2tail · ci · cii · ciwidth · clear · clock · cloglog · clonevar · cls · cluster · clustermat · cnsreg · codebook · coefplot · cofd · collapse · compare · compress · cond · confirm · constraint · continue · contract · contrast · copy · corr2data · correlate · corrgram · count · cpoisson · creturn · cross · cs · csdid · csi · cumsp · cumul · d. · dataex · datasignature · date · day · daysinmonth · decode · describe · destring · dfbeta · dfgls · dfuller · did_imputation · didregress · dir · discrim · display · distinct · do · dofc · dofm · dofq · dofy · dotplot · dow · doy · drawnorm · drdid · drop · ds · dstdize · dtable · duplicates · ebalance · egen · eivreg · elasticnet · encode · ereturn · error · esize · esizei · estat · estimates · eststo · esttab · etable · eventstudyinteract · exit · expand · expandcl · exponential · exponentialden · exponentialtail · export · f. · factor · factormat · fcast · fcollapse · file · filefilter · fillin · findfile · findit · firstdayofmonth · flevelsof · floor · fmerge · foreach · forecast · format · forvalues · fracreg · fralias · frame · fre · frget · frlink · frunalias · ftools · gammaden · gammap · gammaptail · gcollapse · gcontract · gdistinct · gduplicates · gegen · gencohort · generate · getmata · gettoken · gisid · glevelsof · glm · global · gquantiles · graph · greshape · gsort · gstats · gtoplevelsof · gunique · halfyear · hashsort · hausman · heatplot · heckman · help · hetregress · hexdump · hh · histogram · hotelling · hypergeometric · hypergeometricp · ibeta · ibetatail · icc · if · import · include · infile · infix · inlist · input · inrange · insobs · inspect · intreg · invF · invFtail · invbinomial · invbinomialtail · invcauchy · invcauchytail · invchi2 · invchi2tail · invexponential · invexponentialtail · invgammap · invgammaptail · invibeta · invibetatail · invlogistic · invlogistictail · invnF · invnFtail · invnbinomial · invnbinomialtail · invnchi2 · invnchi2tail · invnibeta · invnormal · invnt · invnttail · invpoisson · invpoissontail · invt · invttail · invtukeyprob · invweibull · invweibullph · invweibullphtail · invweibulltail · ipolate · iqreg · ir · irf · iri · isid · istdize · ivlpirf · ivreg2 · ivreghdfe · ivregress · jackknife · jdbc · joinby · kap · kdensity · keep · kmatch · ksmirnov · ktau · kwallis · l. · label · labelbook · labmask · lasso · levelsof · lincom · line · linktest · list · ln · lncauchyden · lnigammaden · lnmvnormalden · lnnormal · lnnormalden · local · log · logistic · logisticden · logistictail · logit · lookfor · lower · lowess · lpirf · lrtest · ltable · macro · manova · manovatest · margins · marginsplot · mark · markin · markout · marksample · matlist · matname · matrix · mca · mcc · mcci · mdesc · mds · mdsmat · mdy · mean · mecloglog · median · meglm · melogit · memory · menbreg · menl · meologit · meoprobit · mepoisson · meprobit · merge · meta · mhodds · mi · missing · missings · misstable · mixed · mkdir · mkmat · mlexp · mlogit · mm · mofd · month · mvdecode · mvencode · mvreg · mvtest · nF · nFden · nFtail · nbetaden · nbinomial · nbinomialp · nbinomialtail · nbreg · nchi2 · nchi2den · nchi2tail · nestreg · net · newey · nibeta · nl · nlcom · normal · normalden · notes · npnF · npnchi2 · npnt · nptrend · nt · nttail · numlabel · numlist · oaxaca · odbc · ologit · oneway · oprobit · order · orthog · orthpoly · outfile · outreg2 · pac · pca · pcamat · pchi · pcorr · pctile · pergram · permute · pnorm · poisson · poissonp · poissontail · post · postclose · postfile · power · pperron · ppmlhdfe · predict · predictnl · preserve · probit · program · proportion · prtest · prtesti · psdensity · psmatch2 · pstest · putdocx · putexcel · putmata · pwcompare · pwcorr · pwd · pwmean · qchi · qnorm · qofd · qqplot · qreg · quadchk · quantile · quarter · query · quietly · range · rangestat · ranksum · rbeta · rbinomial · rcauchy · rchi2 · rdbwdensity · rdbwselect · rddensity · rdrobust · real · recast · recode · regexm · regexr · regexreplaceall · regexs · reghdfe · regress · rename · replace · require · reshape · return · rexponential · rgamma · rhypergeometric · rlogistic · rnbinomial · rnormal · robvar · roccomp · roctab · rolling · rotate · rotatemat · round · rpoisson · rreg · rt · runiform · runtest · rvfplot · rweibull · sample · save · saveold · savespss · scalar · scatter · sdtest · sdtesti · search · sem · separate · seqvar · serrbar · set · setroot · signrank · signtest · simulate · sktest · sleep · slogit · snapshot · snapspan · sort · spbalance · spdistance · spearman · spgenerate · spikeplot · split · splitsample · spmatrix · spset · sqreg · ss · ssc · sspace · stack · stbase · stci · stcox · stcrreg · stdescribe · stem · stfill · stgen · stintreg · stir · stjoin · stmh · stptime · strate · streg · string · stritrim · strlen · strlower · strltrim · strmatch · strofreal · strpos · strproper · strreverse · strrtrim · strtoname · strtrim · strupper · sts · stset · stsplit · stsum · sttocc · stvary · subinstr · subinword · substr · sum · summarize · svmat · svy · svydescribe · svyset · swilk · symmetry · symmi · symplot · syntax · synth · sysdir · sysuse · t · tab1 · tab2 · tabdisp · tabi · table · tabodds · tabstat · tabulate · tden · tebalance · teffects · tempfile · tempname · tempvar · teoverlap · test · testnl · testparm · tetrachoric · timer · tnbreg · tobit · tokenize · tostring · tpoisson · truncreg · tsfill · tsfilter · tsline · tsreport · tsset · tssmooth · ttail · ttest · ttesti · tukeyprob · twoway · type · uchar · ucm · unab · unabcmd · unicode · univar · unzipfile · upper · use · uselabel · ustrlen · ustrlower · ustrnormalize · ustrpos · ustrregexm · ustrregexra · ustrregexrf · ustrreverse · ustrtrim · ustrupper · usubstr · var · vargranger · varstable · vec · vecrank · version · viewsource · vif · vioplot · webuse · weibull · weibullden · weibullph · weibullphden · weibullphtail · weibulltail · which · while · winsor2 · wntestq · word · wordcount · xcorr · xi · xpose · xtabond · xtcloglog · xtdescribe · xtdidregress · xtdpd · xtdpdsys · xtgee · xtgls · xthtaylor · xtile · xtivreg · xtline · xtlogit · xtologit · xtoprobit · xtpcse · xtpoisson · xtprobit · xtrc · xtreg · xtregar · xtscc · xtset · xtsum · xttest0 · xtunitroot · year · ym · yq · zinb · zip · zipfile · ztest · ztesti
Basics
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
base
|
Change the working directory An RStudio project sets the working directory for you, so scripts can use relative paths. Stata reference · R reference |
|
base
|
Remove a dataset from memory Rarely needed: R holds many tables at once, each under its own name. Stata reference · R reference |
|
base
|
List the files in the working
directory Stata reference · R reference |
|
base
|
Calculate and show a
result Stata reference · R reference |
|
base
|
Run a script
file Stata reference · R reference |
|
readr
|
Export a CSV
file Stata reference · R reference |
|
writexl
|
Export an Excel
file Stata reference · R reference |
|
tidystata
|
Find the R equivalent of a Stata command Bare words and comma-separated names work: findit(tab, sex, region). Add hints such as findit(tab, gen), or quote full Stata syntax. One clear example is shown by default; print(n = Inf) reveals every match. findit() with no argument returns the whole list. Stata reference · R reference |
|
base
|
Store a value for later use Any R object works like a macro: assign it once and reuse its name, as in setwd(path). Stata reference · R reference |
|
utils
|
Open the help page of a function ?function does the same. In RStudio you can also search the Help pane. Stata reference · R reference |
|
readr
|
Import a CSV file RStudio's File > Import Dataset menu writes this code for you. Stata reference · R reference |
|
readxl
|
Import an Excel
sheet Stata reference · R reference |
|
haven
|
Import a SAS
file Stata reference · R reference |
|
haven
|
Import an SPSS
file Stata reference · R reference |
|
base
|
Record console output in a file Most R users write an R Markdown or Quarto report instead of a log. Stata reference · R reference |
|
remotes
|
Install a package from
GitHub Stata reference · R reference |
|
base
|
Show the working
directory Stata reference · R reference |
|
haven
|
Save as a Stata dataset saveRDS(data, "data.rds") keeps every R type, such as factors and dates, exactly. Stata reference · R reference |
|
haven
|
Save for an older Stata
version Stata reference · R reference |
|
utils
|
Search all installed help pages ??keyword is a shortcut. To find the R version of a Stata command, use findit(). Stata reference · R reference |
|
utils
|
Install a package Unlike Stata, an installed package must be attached in every session with library(package). Stata reference · R reference |
|
datasets
|
Load an example
dataset Stata reference · R reference |
|
haven
|
Open a Stata dataset Variable and value labels are kept. Data saved in R's own format open with readRDS("data.rds") or load("data.RData"). Stata reference · R reference |
|
haven
|
Load an example dataset from the Stata
website Stata reference · R reference |
Explore data
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Analysis of
variance Stata reference · R reference |
|
tidystata
|
View the data in a spreadsheet
window Stata reference · R reference |
|
tidystata
|
View selected variables Ranges of variables use a colon (x3:x5), not a dash. Stata reference · R reference |
|
dplyr
|
Variables whose names end with given
text Stata reference · R reference |
|
dplyr
|
Variables whose names contain given
text Stata reference · R reference |
|
dplyr
|
Rows meeting a
condition Stata reference · R reference |
|
base
|
The last rows Stata reference · R reference |
|
base
|
The first
rows Stata reference · R reference |
|
dplyr
|
Rows by
position Stata reference · R reference |
|
dplyr
|
Variables whose names start with given
text Stata reference · R reference |
|
tidystata
|
View variables matching Stata wildcards varlist() understands Stata's * and ? wildcards and works in any selection, such as select(). Stata reference · R reference |
|
stats
|
Confidence interval of a mean Add conf.level = 0.99 for ci mean x, level(99). Stata reference · R reference |
|
tidystata
|
Describe every
variable Stata reference · R reference |
|
tidystata
|
One line of statistics per
variable Stata reference · R reference |
|
tidystata
|
Pearson correlations (complete cases) Differs from Stata: Uses one common complete-case sample, like Stata correlate. Returns r and n in a tidy table; .wide = TRUE gives a lower-triangular table. Stata covariance, means and display-formatting options are not implemented. Stata reference · R reference |
|
tidystata
|
List variables with their types and labels glimpse(data) gives a compact view with the first values of each variable. Stata reference · R reference |
|
haven
|
Variables in a file, without loading its
data Stata reference · R reference |
|
tidystata
|
List variable names ds(data, .type = "table") returns the names as a one-column table; names(data) is base R. Stata reference · R reference |
|
gtsummary
|
Descriptive Table 1 (Stata 18+) modelsummary::datasummary_skim(data) gives a quick overview without a by variable. Stata reference · R reference |
|
stats
|
Factor analysis Differs from Stata: factanal() uses maximum likelihood; psych::fa(..., fm = "pa") gives Stata's default principal-factor method. Stata reference · R reference |
|
tidystata
|
Frequency table with totals Like Ben Jann's fre: tab() with a total row. Stata reference · R reference |
|
tidystata
|
Distribution, zeros and missing values of a variable hist(data$x) adds the quick histogram that inspect draws. Stata reference · R reference |
|
stats
|
Kolmogorov-Smirnov test of equal distributions Differs from Stata: The R code assumes group codes 0 and 1; exact/asymptotic inference and tied-value handling can differ from Stata ksmirnov. Stata reference · R reference |
|
stats
|
Kendall's tau Differs from Stata: The rank coefficient has the same interpretation, but exact/asymptotic p-value selection and tie corrections may differ; match inference options separately. Stata reference · R reference |
|
stats
|
Kruskal-Wallis
test Stata reference · R reference |
|
base
|
Distinct values of a variable Differs from Stata: Store them for a loop: levels <- sort(unique(data$x)), then for (v in levels) { ... }. sort(unique()) excludes NA by default, but string ordering follows R collation and can differ from Stata sorting. Stata reference · R reference |
|
tidystata
|
Print the first and last rows Prints every row and column. Typing data prints the first rows; print_headtail(data) prints the first and last rows. Stata reference · R reference |
|
dplyr
|
Print one variable data$x does the same. select(data, x) keeps x as a one-column table. Stata reference · R reference |
|
tidystata
|
Find variables by name or
label Stata reference · R reference |
|
tidystata
|
Mean with its standard error Differs from Stata: t.test(data$x) also reports the confidence interval. The R snippet returns point summaries only (plus SE for mean); Stata also reports confidence intervals and estimation results. Stata reference · R reference |
|
stats
|
One-way analysis of variance Differs from Stata: bartlett.test(y ~ group, data = data) gives the equal-variance test that oneway reports. aov() gives the ANOVA table but does not include the Bartlett equal-variance test printed by oneway; request bartlett.test() separately. Stata reference · R reference |
|
stats
|
Principal components Differs from Stata: Stata analyses the correlation matrix, so scale. = TRUE matches it. scale. = TRUE matches correlation PCA; signs of eigenvectors are arbitrary and the stored rotations and printed loadings have different normalization conventions. Stata reference · R reference |
|
base
|
Proportion in each category Differs from Stata: tab(data, x) shows the same percentages; prop.test() adds a confidence interval for one proportion. The R snippet returns point summaries only (plus SE for mean); Stata also reports confidence intervals and estimation results. Stata reference · R reference |
|
stats
|
Test of a proportion Differs from Stata: correct = FALSE gives Stata's normal-approximation test without continuity correction. The uncorrected test statistic matches the normal approximation, but prop.test() confidence intervals use score inversion rather than the prtest Wald interval. Stata reference · R reference |
|
tidystata
|
Pairwise correlations Differs from Stata: Gives r, n and p for each pair; .wide = TRUE gives the matrix. Base R: cor(select(data, x1, x2, x3), use = "pairwise.complete.obs"). pwcorr() returns pair counts and p-values in a tidy table; Stata prints a correlation matrix by default and needs options for additional reporting. Stata reference · R reference |
|
stats
|
Wilcoxon rank-sum (Mann-Whitney) test Differs from Stata: R can choose exact inference in small samples and applies continuity correction in its normal approximation; Stata defaults differ. Set exact and correct deliberately. Stata reference · R reference |
|
stats
|
Wilcoxon signed-rank test Differs from Stata: R can choose exact inference in small samples and applies continuity correction in its normal approximation; Stata defaults differ. Set exact and correct deliberately. Stata reference · R reference |
|
tidystata
|
Skewness and kurtosis For a formal normality test use shapiro.test(data$x). Stata reference · R reference |
|
stats
|
Spearman rank correlation Differs from Stata: The rank coefficient has the same interpretation, but exact/asymptotic p-value selection and tie corrections may differ; match inference options separately. Stata reference · R reference |
|
graphics
|
Stem-and-leaf
display Stata reference · R reference |
|
tidystata
|
Summary statistics for all variables Differs from Stata: summary(data) is the base R version, with a less tidy layout. summ() also reports missing counts and has its own default statistic layout; select .stat explicitly when matching Stata output. Stata reference · R reference |
|
tidystata
|
Summary statistics for one variable Differs from Stata: summ() also reports missing counts and has its own default statistic layout; select .stat explicitly when matching Stata output. Stata reference · R reference |
|
tidystata
|
Summary statistics by group Differs from Stata: group_by(data, group) |> summ(x) gives the same result. summ() also reports missing counts and has its own default statistic layout; select .stat explicitly when matching Stata output. Stata reference · R reference |
|
tidystata
|
Weighted summary statistics Differs from Stata: Frequency weights are the default: summ(data, x, .wt = w). summ() also reports missing counts and has its own default statistic layout; select .stat explicitly when matching Stata output. Stata reference · R reference |
|
tidystata
|
Detailed statistics, including percentiles Differs from Stata: Pick single statistics with .stat, as in summ(data, x, .stat = "p25"). summ() also reports missing counts and has its own default statistic layout; select .stat explicitly when matching Stata output. Stata reference · R reference |
|
stats
|
Shapiro-Wilk normality test Differs from Stata: shapiro.test() accepts 3 to 5000 nonmissing observations; Stata swilk has different sample-size limits and reporting. Stata reference · R reference |
|
tidystata
|
One frequency table per variable Differs from Stata: tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
tidystata
|
Cross-tabulation of two variables Differs from Stata: With three or more variables, tab2(data, x1, x2, x3) returns every pairwise table, as Stata does. tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
tidystata
|
Joint frequencies of several
variables Stata reference · R reference |
|
tidystata
|
A statistic by category (Stata 17+
table) Stata reference · R reference |
|
tidystata
|
Chosen statistics by group Differs from Stata: R retains missing grouping keys; Stata tabstat by() and tabulate summarize() exclude missing grouping categories unless requested. Check the intended grouping sample. Stata reference · R reference |
|
tidystata
|
One-way frequency table Differs from Stata: tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
tidystata
|
Two-way cross-tabulation Differs from Stata: fre2(data, x1, x2) adds row and column totals. tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
tidystata
|
Frequency table by group Differs from Stata: tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
tidystata
|
Frequencies with analytic (sampling) weights Differs from Stata: tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
tidystata
|
Frequencies with frequency weights Differs from Stata: tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
tidystata
|
Frequencies including missing values tab() always lists missing values as a separate row. Stata reference · R reference |
|
tidystata
|
Summary of y within each category of x Differs from Stata: R retains missing grouping keys; Stata tabstat by() and tabulate summarize() exclude missing grouping categories unless requested. Check the intended grouping sample. Stata reference · R reference |
|
tidystata
|
Chi-square test of independence Differs from Stata: Filter missing values on both variables for plain Stata tabulate, chi2. tab2 otherwise includes its displayed missing categories in the Pearson test. tidystata retains missing categories by default; Stata tabulate excludes them unless missing is specified. Use .missing = FALSE to match Stata. Stata reference · R reference |
|
stats
|
Fisher's exact
test Stata reference · R reference |
|
stats
|
Two-sample t test Differs from Stata: R's default is Welch's test; add var.equal = TRUE for Stata's default equal-variance test. Stata reference · R reference |
|
tidystata
|
Detailed univariate
statistics Stata reference · R reference |
Check data
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
tidystata
|
Stop when a condition fails Differs from Stata: Reports the number of contradictions and returns the data, so it fits in a pipe. Missing x counts as a contradiction, unlike Stata, where missing is larger than any number: write assert(data, is.na(x) | x > 0) for Stata's behaviour. Stata reference · R reference |
|
base
|
Check that a variable
exists Stata reference · R reference |
|
base
|
Number of
rows Stata reference · R reference |
|
base
|
Count rows meeting a condition Differs from Stata: Stata numeric missing values compare larger than every finite number; R comparisons return NA. Handle missing values explicitly before applying the condition. Stata reference · R reference |
|
dplyr
|
Number of distinct
combinations Stata reference · R reference |
|
tidystata
|
List duplicated
rows Stata reference · R reference |
|
tidystata
|
Count duplicated
rows Stata reference · R reference |
|
tidystata
|
Mark duplicated
rows Stata reference · R reference |
|
tidystata
|
Check that variables identify the
rows Stata reference · R reference |
|
tidystata
|
Missing values per
variable Stata reference · R reference |
|
tidystata
|
Missing-value patterns 1 marks an observed value and 0 a missing one, as in Stata. Stata reference · R reference |
|
tidystata
|
Missing values per variable Base R: colSums(is.na(data)). Stata reference · R reference |
Labels
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
tidystata
|
Turn labelled values into
text Stata reference · R reference |
|
dplyr
|
Turn text into labelled categories Differs from Stata: factor() creates integer level indices with an R class; encode creates numeric codes with a separate value-label definition. Collation can change code ordering. Stata reference · R reference |
|
dplyr
|
Label every value of a categorical variable In R a labelled categorical variable is usually a factor. Give levels explicitly so each code gets the right label. Stata reference · R reference |
|
haven
|
Remove value
labels Stata reference · R reference |
|
base
|
Show the categories of a variable For labelled data read with haven, use haven::print_labels(data$x). Stata reference · R reference |
|
haven
|
Attach a value label to a variable Define the labels once, as yesno <- c(No = 0, Yes = 1), then attach them to any variable; factor() is the usual R alternative. Stata reference · R reference |
|
labelled
|
Label a variable Labels read from Stata files are kept; variables() and codebook() display them. Stata reference · R reference |
|
haven
|
Label some values only Partial value labels are rare in R; haven keeps them so they survive a round trip to Stata. tab() and codebook() show them. Stata reference · R reference |
|
base
|
Attach a note to a variable R has no notes system; an attribute or a comment in the script is the usual substitute. Stata reference · R reference |
Construct and modify variables
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
base
|
Round
up Stata reference · R reference |
|
dplyr
|
Copy a variable Differs from Stata: mutate(x2 = x) copies the R vector and attributes, but does not reproduce all Stata clonevar characteristics and notes. Stata reference · R reference |
|
dplyr
|
Replace the data with group means Differs from Stata: Assign the result to replace the data, as collapse does: data <- summarise(...). summ(data, x1, x2, .by = group) shows a summary table instead. R retains missing grouping keys; Stata tabstat by() and tabulate summarize() exclude missing grouping categories unless requested. Check the intended grouping sample. Stata reference · R reference |
|
dplyr
|
Different statistics for different
variables Stata reference · R reference |
|
dplyr
|
One value if a condition holds, another if not Differs from Stata: With missing x, Stata's cond() takes the first value (missing counts as large); if_else() returns NA. Stata numeric missing values compare larger than every finite number; R comparisons return NA. Handle missing values explicitly before applying the condition. Stata reference · R reference |
|
tidystata
|
Text to numbers Differs from Stata: Text that is not a number becomes NA with a warning, as with force. destring(str_x, ignore = "kg") removes those characters first, like ignore(), so "10 kg" gives 10. Invalid numeric text becomes NA with a warning here; Stata destring without force refuses conversion of a variable containing such text. Stata reference · R reference |
|
tidystata
|
Ten groups of about equal size Differs from Stata: egen cut(), group() has its own grouping rule; xtile() follows Stata's xtile, the usual command for quantile groups. Stata reference · R reference |
|
tidystata
|
Mark the first row of each group Differs from Stata: Gives TRUE/FALSE; rows with a missing group are FALSE, as in Stata, unless .missing = TRUE. The R result is logical TRUE/FALSE rather than numeric 1/0; use as.integer() when the stored type matters. Stata reference · R reference |
|
dplyr
|
Number the groups Differs from Stata: cur_group_id() also numbers groups with missing keys; egen group() excludes those rows without the missing option. String collation can change ID ordering. Stata reference · R reference |
|
dplyr
|
Sample statistic as a new variable Differs from Stata: R functions keep missing values unless na.rm = TRUE; Stata's egen ignores them. For an all-missing group mean(..., na.rm = TRUE) gives NaN; Stata egen mean() gives numeric missing. Normalize NaN if that distinction matters. Stata reference · R reference |
|
tidystata
|
Row total Stata reference · R reference |
|
dplyr
|
Group median Stata reference · R reference |
|
dplyr
|
Group minimum Differs from Stata: All-missing groups return NA without evaluating min() on an empty set. All-missing groups produce -Inf/Inf and a warning in R max/min with na.rm = TRUE; Stata egen max()/min() returns missing. Stata reference · R reference |
|
dplyr
|
Group maximum Differs from Stata: All-missing groups return NA without evaluating max() on an empty set. All-missing groups produce -Inf/Inf and a warning in R max/min with na.rm = TRUE; Stata egen max()/min() returns missing. Stata reference · R reference |
|
dplyr
|
Number of observed values in each
group Stata reference · R reference |
|
dplyr
|
Group standard
deviation Stata reference · R reference |
|
dplyr
|
Group total Stata reference · R reference |
|
dplyr
|
Group statistic as a new variable Differs from Stata: For an all-missing group mean(..., na.rm = TRUE) gives NaN; Stata egen mean() gives numeric missing. Normalize NaN if that distinction matters. Stata reference · R reference |
|
base
|
Groups by given cutpoints Differs from Stata: right = FALSE makes each interval include its lower cutpoint, as egen cut() does. cut_length(x, 10) instead splits the range into 10 equal widths. cut() returns a factor of interval labels; egen cut() stores numeric lower endpoints even when interval closure matches. Stata reference · R reference |
|
dplyr
|
First observed value across
variables Stata reference · R reference |
|
base
|
Join variables into one string Differs from Stata: paste() turns NA into the text "NA"; egen concat() follows Stata missing-value and numeric-display conventions. Stata reference · R reference |
|
dplyr
|
Last observed value across
variables Stata reference · R reference |
|
dplyr
|
Count how many variables equal a
value Stata reference · R reference |
|
tidystata
|
Percentage of the total pc(x, prop = TRUE) gives proportions, like the prop option. Stata reference · R reference |
|
base
|
Rank, with ties averaged rank() gives tied values their average rank, like egen rank(); dplyr::min_rank() gives them the lowest. Stata reference · R reference |
|
dplyr
|
Repeating
sequence Stata reference · R reference |
|
tidystata
|
Row mean Stata reference · R reference |
|
tidystata
|
Row maximum Stata reference · R reference |
|
tidystata
|
Row median Stata reference · R reference |
|
tidystata
|
Number of missing values in each
row Stata reference · R reference |
|
tidystata
|
Row minimum Stata reference · R reference |
|
tidystata
|
Number of observed values in each
row Stata reference · R reference |
|
tidystata
|
Number of distinct values in each row From egenmore (SSC). Missing values are ignored unless .missing = TRUE, like the missing option. Stata reference · R reference |
|
tidystata
|
Row standard
deviation Stata reference · R reference |
|
tidystata
|
Standardise a variable Base R: as.vector(scale(x)). Add .by = g for by g: egen. Stata reference · R reference |
|
base
|
Round
down Stata reference · R reference |
|
base
|
Display numbers with two decimals R stores the number unchanged and formats it only when printing, for example with round(x, 2) or sprintf(). Stata reference · R reference |
|
dplyr
|
Create a variable Assign the result to keep it: data <- mutate(data, ...). R has no separate generate and replace. Stata reference · R reference |
|
dplyr
|
Number of rows Add .by = group for the number of rows in each group, like bysort group: generate N = _N. Stata reference · R reference |
|
dplyr
|
Row
number Stata reference · R reference |
|
base
|
Days between two
dates Stata reference · R reference |
|
dplyr
|
Dummy variable from a condition Differs from Stata: Stata numeric equality is false for missing operands; %in% keeps the dummy zero when either input is missing. The R result is logical TRUE/FALSE rather than numeric 1/0; use as.integer() when the stored type matters. Stata reference · R reference |
|
dplyr
|
Value from the previous row This shifts rows, like x[_n-1], and ignores gaps in time. See L. for panel lags. Stata reference · R reference |
|
dplyr
|
Value from two rows
ahead Stata reference · R reference |
|
dplyr
|
Create a variable under a condition In Stata missing is larger than any number, so x > 0 is true for missing x. In R the condition is NA and so is the result. Stata reference · R reference |
|
dplyr
|
Create a variable for some
rows Stata reference · R reference |
|
base
|
Whether x equals any listed value Differs from Stata: %in% gives FALSE for missing x, as inlist() does. R returns a logical indicator rather than the numeric 1/0 stored by Stata generate; use as.integer() if the stored type matters. Stata reference · R reference |
|
dplyr
|
Whether x lies within a range Differs from Stata: between() returns NA for missing x, whereas Stata's inrange() returns 0. Stata reference · R reference |
|
base
|
Natural logarithm Differs from Stata: log10() matches Stata's log10(). R's log(0) is -Inf rather than missing. R log(0) gives -Inf and a negative input gives NaN with a warning; Stata ln() gives numeric missing for these invalid inputs. Stata reference · R reference |
|
base
|
Whether a value is missing Differs from Stata: R returns a logical indicator rather than the numeric 1/0 stored by Stata generate; use as.integer() if the stored type matters. Stata reference · R reference |
|
tidystata
|
Turn missing-value codes into missing mvdecode(x, c(-8, -9)) handles several codes, like mv(-8 -9). Stata reference · R reference |
|
tidystata
|
Turn missing values into a
code Stata reference · R reference |
|
tidystata
|
Quantile cutpoints Differs from Stata: summ() uses Stata's percentile rule. quantile(x, type = 2) is close, but treats some whole positions, such as 100 * 0.3, as fractional. summ() returns percentile values in a summary table; pctile creates a dataset column containing the cutpoints. Stata reference · R reference |
|
base
|
Change the storage type R chooses storage automatically, so there is no compress either. Stata reference · R reference |
|
dplyr
|
Recode ranges of values Values that match no condition become NA, like else = . in Stata. Stata reference · R reference |
|
dplyr
|
Turn one code into
missing Stata reference · R reference |
|
dplyr
|
Rename a variable Note the order: new name = old name. Stata reference · R reference |
|
dplyr
|
Rename several
variables Stata reference · R reference |
|
dplyr
|
Add a suffix to every
name Stata reference · R reference |
|
dplyr
|
Make all names lower
case Stata reference · R reference |
|
dplyr
|
Upper-case some
names Stata reference · R reference |
|
dplyr
|
Change a
variable Stata reference · R reference |
|
dplyr
|
Change a variable under a condition Differs from Stata: Stata numeric missing values compare larger than every finite number; R comparisons return NA. Handle missing values explicitly before applying the condition. Stata reference · R reference |
|
dplyr
|
Change a variable for some
rows Stata reference · R reference |
|
stats
|
Normal random numbers Differs from Stata: R and Stata use different random-number streams; the same numeric seed does not reproduce the same draws or selected rows. Stata reference · R reference |
|
base
|
Round Differs from Stata: R's second argument is the number of decimals. R rounds halves to even (round(0.5) is 0); Stata rounds them up. Stata reference · R reference |
|
stats
|
Uniform random numbers Differs from Stata: R and Stata use different random-number streams; the same numeric seed does not reproduce the same draws or selected rows. Stata reference · R reference |
|
dplyr
|
Running sum Stata's sum() function treats missing values as 0, hence coalesce(x, 0). Stata reference · R reference |
|
tidystata
|
Dummy variables for every category Differs from Stata: as_dummy(data, x, .names = "index") numbers the columns x_1, x_2, ... as Stata does. Also: fastDummies::dummy_cols(data, "x"). as_dummy() defaults to value-based column names; .names = "index" gives numbered Stata-style suffixes. Check the missing-category indicator policy too. Stata reference · R reference |
|
tidystata
|
Numbers to text Differs from Stata: Labelled values keep their codes; decode() gives the value labels instead. Formatting and retained precision can differ from Stata tostring; choose an explicit format when exact text or round-trip precision matters. Stata reference · R reference |
|
datawizard
|
Winsorise at the 1st and 99th percentiles Differs from Stata: datawizard uses R quantile cutpoints while winsor2 uses Stata percentile rules; small samples and ties can therefore yield different caps. Stata reference · R reference |
|
tidystata
|
Quantile groups xtile() follows Stata's rule, so equal values stay in the same group. Stata reference · R reference |
|
tidystata
|
Weighted quantile
groups Stata reference · R reference |
Select variables and rows
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
dplyr
|
Drop rows meeting a condition Stata keeps rows with missing x here; | is.na(x) does the same in R. Stata reference · R reference |
|
dplyr
|
Drop rows by
position Stata reference · R reference |
|
dplyr
|
Drop a
variable Stata reference · R reference |
|
dplyr
|
Drop rows where x is
missing Stata reference · R reference |
|
dplyr
|
Drop several variables Positions work too: select(data, -c(1, 3:5)). Stata reference · R reference |
|
tidystata
|
Drop rows that duplicate an earlier
row Stata reference · R reference |
|
tidystata
|
Keep the first row for each key distinct(data, x1, x2, .keep_all = TRUE) is the dplyr version. Stata reference · R reference |
|
dplyr
|
Keep rows meeting a condition filter() drops rows where the condition is NA, so rows with missing values never pass. Stata reference · R reference |
|
base
|
Keep the first
rows Stata reference · R reference |
|
dplyr
|
Keep some variables Numbers select by position: select(data, 1, 3:5). select_or_transmute() also computes new columns. Stata reference · R reference |
|
dplyr
|
Keep rows where x is
observed Stata reference · R reference |
|
dplyr
|
Keep rows with listed
values Stata reference · R reference |
|
dplyr
|
Keep rows within a
range Stata reference · R reference |
|
base
|
Keep the last
rows Stata reference · R reference |
|
dplyr
|
Keep rows by
position Stata reference · R reference |
|
tidystata
|
Keep variables matching Stata
wildcards Stata reference · R reference |
|
tidystata
|
Reproducible random 10% sample Differs from Stata: R and Stata use different random-number streams; the same numeric seed does not reproduce the same draws or selected rows. Stata reference · R reference |
|
tidystata
|
Reproducible random sample of 1000 rows Differs from Stata: set_seed() sets the seed before the sampling step runs, so the pipe stays in one line. R and Stata use different random-number streams; the same numeric seed does not reproduce the same draws or selected rows. Stata reference · R reference |
Sort
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
dplyr
|
Sort ascending and
descending Stata reference · R reference |
|
dplyr
|
Move variables to the
front Stata reference · R reference |
|
dplyr
|
Move variables before
another Stata reference · R reference |
|
dplyr
|
Sort in ascending
order Stata reference · R reference |
Combine data
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
dplyr
|
Stack two datasets Differs from Stata: bind_rows() has R type-promotion and attribute rules; .id creates string source identifiers rather than the numeric codes of append, generate(). Stata reference · R reference |
|
dplyr
|
Stack datasets and record where each row came from Differs from Stata: Uses numeric source IDs: zero for the master and one for the first using dataset, as Stata append, generate() does. bind_rows() has R type-promotion and attribute rules; .id creates string source identifiers rather than the numeric codes of append, generate(). Stata reference · R reference |
|
dplyr
|
Every combination of rows from two datasets Differs from Stata: cross_join() suffixes overlapping column names; Stata cross keeps master values for overlapping names. Rename overlaps first to obtain the same columns. Stata reference · R reference |
|
dplyr
|
All pairs of rows within each id Differs from Stata: dplyr retains overlapping non-key columns with suffixes instead of Stata master values, creates no _merge, and does not enforce a declared 1:1 key constraint. Stata reference · R reference |
|
dplyr
|
Put two datasets side by side by row position Differs from Stata: bind_cols() needs matching row counts (or recyclable one-row inputs) and repairs duplicate names; merge 1:1 _n can retain unmatched rows. Stata reference · R reference |
|
tidystata
|
Merge with a match report Like Stata, all rows are kept and a .merge column records the match result. full_join(data1, data2, by = "id") merges without the report. Stata reference · R reference |
|
tidystata
|
One-to-many merge with a match
report Stata reference · R reference |
|
tidystata
|
Many-to-one merge with a match
report Stata reference · R reference |
|
dplyr
|
Keep all rows of the master data Differs from Stata: dplyr retains overlapping non-key columns with suffixes instead of Stata master values, creates no _merge, and does not enforce a declared 1:1 key constraint. Stata reference · R reference |
|
dplyr
|
Keep rows of data1 whose id is not in data2 Differs from Stata: semi_join()/anti_join() select rows by key membership but do not enforce the unique keys required by Stata merge 1:1; validate uniqueness separately. Stata reference · R reference |
|
dplyr
|
Keep matched rows only Differs from Stata: dplyr retains overlapping non-key columns with suffixes instead of Stata master values, creates no _merge, and does not enforce a declared 1:1 key constraint. Stata reference · R reference |
|
dplyr
|
Keep rows of data1 whose id is in data2 Differs from Stata: semi_join()/anti_join() select rows by key membership but do not enforce the unique keys required by Stata merge 1:1; validate uniqueness separately. Stata reference · R reference |
|
dplyr
|
Keep all rows of the using data Differs from Stata: dplyr retains overlapping non-key columns with suffixes instead of Stata master values, creates no _merge, and does not enforce a declared 1:1 key constraint. Stata reference · R reference |
|
dplyr
|
Merge on two keys Differs from Stata: Variables with the same name in both tables get suffixes; choose them with suffix = c("_data1", "_data2"). dplyr retains overlapping non-key columns with suffixes instead of Stata master values, creates no _merge, and does not enforce a declared 1:1 key constraint. Stata reference · R reference |
Reshape
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
tidyr
|
Wide to long Differs from Stata: Converts numeric suffixes to integer year values, matching reshape long without string. pivot_longer() returns a text year without names_transform and does not enforce reshape i()/j() uniqueness constraints. Stata reference · R reference |
|
tidyr
|
Long to wide Differs from Stata: Duplicate keys can create list-columns in pivot_wider(); Stata reshape wide rejects duplicate i()/j() combinations. Validate keys first. Stata reference · R reference |
|
stats
|
Reshape repeated measurements to long form with base
R Differs from Stata: Explicitly list the wide columns and time values. This fixed workflow uses var2000 and var2001; adapt those names to your data. Stata reference · R reference |
|
stats
|
Reshape repeated measurements to wide form with base
R Differs from Stata: Requires one row per id/year combination. R row ordering and attributes differ from Stata; compare keys and values explicitly. Stata reference · R reference |
|
tibble
|
Transpose the
data Stata reference · R reference |
Construct data
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
tidyr
|
Repeat each row n times Differs from Stata: uncount() drops n afterwards; add .remove = FALSE to keep it. uncount() drops the count column by default and zero counts remove rows; Stata expand keeps the count variable and retains observations when the count is below one. Stata reference · R reference |
|
tidyr
|
Add rows for every combination of values Differs from Stata: expand(data, x1, x2) returns only the combinations; expand_grid(x1 = 1:5, x2 = c("a", "b")) builds them from scratch. complete() adds combinations without the _fillin indicator created by Stata fillin; factor levels and missing-key combinations also need explicit decisions. Stata reference · R reference |
|
tibble
|
Type in a small
dataset Stata reference · R reference |
|
tibble
|
Start a dataset with a given number of
rows Stata reference · R reference |
Strings and dates
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
base
|
Create characters from ASCII codes Differs from Stata: Restricted to ASCII codes 1–127; extended-byte encodings are not Unicode code points. Stata reference · R reference |
|
lubridate
|
Text to a date-time Differs from Stata: R uses Date/POSIXct or tsibble calendar classes, not Stata numeric date/time counts from 1960; convert epochs and time zones when exchanging underlying numeric values. Stata reference · R reference |
|
base
|
Parse a date-time with an explicit UTC timezone Differs from Stata: POSIXct is seconds since 1970 with a timezone; Stata clock is milliseconds since 1960 without a timezone. Stata reference · R reference |
|
base
|
Convert R dates to Stata midnight millisecond codes Differs from Stata: Returns ordinary Stata %tc milliseconds since 1960, not a POSIXct object. Stata reference · R reference |
|
lubridate
|
Text to a date Differs from Stata: R uses Date/POSIXct or tsibble calendar classes, not Stata numeric date/time counts from 1960; convert epochs and time zones when exchanging underlying numeric values. Stata reference · R reference |
|
base
|
Parse day-month-year date strings Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
base
|
Parse month-day-year date strings Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
base
|
Parse year-month-day date strings Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
lubridate
|
Day of the
month Stata reference · R reference |
|
base
|
Extract day-of-month numbers Differs from Stata: Accepts an R Date column and returns the demonstrated calendar component; raw Stata date codes require conversion first. Stata reference · R reference |
|
lubridate
|
Get the number of days in each calendar month Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
base
|
Today's
date Stata reference · R reference |
|
base
|
Convert Stata millisecond datetimes to dates Differs from Stata: For ordinary Stata %tc values without leap-second encoding; UTC supplies a deterministic timezone. Stata reference · R reference |
|
tsibble
|
First day of a monthly period Differs from Stata: Here m is a tsibble::yearmonth() value. R uses Date/POSIXct or tsibble calendar classes, not Stata numeric date/time counts from 1960; convert epochs and time zones when exchanging underlying numeric values. Stata reference · R reference |
|
base
|
Convert Stata monthly codes to month-start dates Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
base
|
Convert Stata quarterly codes to quarter-start dates Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
base
|
Construct the first day of each year Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
lubridate
|
Day of the week wday() counts Sunday as 1; Stata's dow() counts Sunday as 0. Stata reference · R reference |
|
base
|
Extract weekday with Sunday coded zero Differs from Stata: Accepts an R Date column and returns the demonstrated calendar component; raw Stata date codes require conversion first. Stata reference · R reference |
|
base
|
Extract day-of-year numbers Differs from Stata: Accepts an R Date column and returns the demonstrated calendar component; raw Stata date codes require conversion first. Stata reference · R reference |
|
base
|
Find the first date of each calendar month Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
base
|
Display a date Dates keep their class; format() only changes how they print. Stata reference · R reference |
|
lubridate
|
Age or duration in years Differs from Stata: time_length(interval(...), "years") uses calendar-year lengths; dividing days by 365.25 is a fixed-length approximation and can give different ages. Stata reference · R reference |
|
base
|
Extract half-year numbers Differs from Stata: Accepts an R Date column and returns the demonstrated calendar component; raw Stata date codes require conversion first. Stata reference · R reference |
|
base
|
Extract the hour from a UTC timestamp Differs from Stata: Input is an R POSIXct timestamp; convert raw Stata %tc numbers before extracting components. Stata reference · R reference |
|
stringr
|
Lower case Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
lubridate
|
Date from year, month and day Differs from Stata: R uses Date/POSIXct or tsibble calendar classes, not Stata numeric date/time counts from 1960; convert epochs and time zones when exchanging underlying numeric values. Stata reference · R reference |
|
base
|
Construct a date from year, month and day columns Differs from Stata: R Date objects use a different numeric origin from Stata; use the object for calendar operations, not raw-code comparison. Stata reference · R reference |
|
base
|
Extract the minute from a UTC timestamp Differs from Stata: Input is an R POSIXct timestamp; uppercase %M means minute and lowercase %m means month. Stata reference · R reference |
|
tsibble
|
Monthly period from a date Differs from Stata: tsibble::yearquarter() is the quarterly version, like qofd(). R uses Date/POSIXct or tsibble calendar classes, not Stata numeric date/time counts from 1960; convert epochs and time zones when exchanging underlying numeric values. Stata reference · R reference |
|
base
|
Convert Date values to Stata monthly codes Differs from Stata: Returns numeric months since January 1960, explicitly using Stata monthly units. Stata reference · R reference |
|
lubridate
|
Month of a
date Stata reference · R reference |
|
base
|
Extract month numbers Differs from Stata: Accepts an R Date column and returns the demonstrated calendar component; raw Stata date codes require conversion first. Stata reference · R reference |
|
tsibble
|
Quarterly period from a date Differs from Stata: R uses Date/POSIXct or tsibble calendar classes, not Stata numeric date/time counts from 1960; convert epochs and time zones when exchanging underlying numeric values. Stata reference · R reference |
|
base
|
Convert Date values to Stata quarterly codes Differs from Stata: Returns numeric quarters since 1960q1, explicitly using Stata quarterly units. Stata reference · R reference |
|
base
|
Extract calendar quarter numbers Differs from Stata: Accepts an R Date column and returns the demonstrated calendar component; raw Stata date codes require conversion first. Stata reference · R reference |
|
base
|
Text to a number Differs from Stata: destring() from tidystata also strips value labels. as.numeric() warns for invalid text, unlike Stata real(); factors must be converted through their text levels before numeric conversion. Stata reference · R reference |
|
base
|
Parse a controlled decimal grammar with missing for invalid
text Differs from Stata: Deliberately limited grammar avoids accidental warnings; scientific notation and tagged missing require extension. Stata reference · R reference |
|
stringr
|
Match a regular expression Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Flag strings containing only ASCII digits Differs from Stata: This simple shared regex is portable; Stata and R regex engines differ for advanced patterns. Stata reference · R reference |
|
stringr
|
Replace the first regular-expression match Differs from Stata: str_replace_all() replaces every match, like ustrregexra(). R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Replace the first numeric run in text Differs from Stata: First-match regex replacement; advanced regex features differ across engines. Stata reference · R reference |
|
base
|
Replace all numeric runs in text Differs from Stata: StataNow regexreplaceall workflow with a simple ASCII pattern; older Stata versions use other functions. Stata reference · R reference |
|
stringr
|
Extract the matching text Differs from Stata: str_extract() returns NA for nonmatches; Stata generate ... if leaves empty strings in those rows. regexs() also depends on the preceding regexm() match. Stata reference · R reference |
|
stringr
|
Extract the first capturing group R returns the group directly without a prior global regex-match state; unmatched rows use NA. Stata reference · R reference |
|
tidyr
|
Split text into several
variables Stata reference · R reference |
|
tidyr
|
Split two numeric fields and convert their types Differs from Stata: Requires exactly two clean integer fields; resulting column names s1 and s2 are fixed. Stata reference · R reference |
|
base
|
Split two-component delimited strings Differs from Stata: Fixed two-field example with exactly one delimiter per row; generated stub part is fixed. Stata reference · R reference |
|
base
|
Extract seconds from a UTC timestamp Differs from Stata: Input is an R POSIXct timestamp; fractional-second precision depends on the platform and display settings. Stata reference · R reference |
|
base
|
Number to text Differs from Stata: tidystata's decode() uses value labels for labelled data; tostring() keeps the codes. as.character() follows R number formatting and NA handling; Stata string() uses numeric display formats and "." for numeric missing. Stata reference · R reference |
|
stringr
|
Collapse repeated spaces Differs from Stata: str_squish() also removes leading and trailing spaces. Stata reference · R reference |
|
base
|
Collapse repeated internal ASCII
spaces Stata reference · R reference |
|
stringr
|
Length of a string Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Count bytes rather than Unicode characters Differs from Stata: Byte length depends on encoding; this fixture is explicitly UTF-8. Stata reference · R reference |
|
stringr
|
Lower case Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Lowercase ASCII
text Stata reference · R reference |
|
base
|
Trim leading ASCII spaces
only Stata reference · R reference |
|
utils
|
Match a wildcard pattern Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Match a simple wildcard pattern Differs from Stata: Demonstrates * wildcard only; review escaping for more complicated patterns. Stata reference · R reference |
|
base
|
Format a number as zero-padded
text Stata reference · R reference |
|
stringr
|
Whether a string contains some text Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Locate a literal ASCII substring with zero for
absence Stata reference · R reference |
|
stringr
|
Title case Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
stringr
|
Capitalize words in English place names Differs from Stata: English locale example; punctuation and language-specific capitalization can differ. Stata reference · R reference |
|
base
|
Reverse plain ASCII
text Stata reference · R reference |
|
base
|
Trim trailing ASCII spaces
only Stata reference · R reference |
|
base
|
Turn text into a valid name Differs from Stata: janitor::clean_names(data) cleans every variable name at once. make.names() allows dots and follows R reserved-word rules; strtoname() follows Stata allowed-character and length limits. Stata reference · R reference |
|
base
|
Convert short ASCII text to Stata-style names Differs from Stata: Demonstrated short ASCII names only; R syntactic names and Stata reserved names follow different rules. Stata reference · R reference |
|
stringr
|
Remove leading and trailing spaces Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Trim leading and trailing ASCII
spaces Stata reference · R reference |
|
stringr
|
Upper case Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Uppercase ASCII
text Stata reference · R reference |
|
stringr
|
Replace text Differs from Stata: stringr treats patterns as regular expressions; fixed() matches the text literally, as subinstr() does. R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Replace every literal
occurrence Stata reference · R reference |
|
base
|
Replace only the first literal
occurrence Stata reference · R reference |
|
base
|
Replace a complete word in simple ASCII text Differs from Stata: Uses regular-expression word boundaries; delimiters and Unicode rules can differ from Stata. Stata reference · R reference |
|
stringr
|
Part of a string Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
stringr
|
Extract the last three ASCII
characters Stata reference · R reference |
|
base
|
Extract an ASCII prefix by
length Stata reference · R reference |
|
base
|
Extract ASCII text using start and length Stata takes a length; base R substr takes an inclusive ending position. Stata reference · R reference |
|
base
|
Create characters from Unicode code
points Stata reference · R reference |
|
stringr
|
Upper case Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Count Unicode code points Counts code points, not visible grapheme clusters. Stata reference · R reference |
|
stringr
|
Lowercase Unicode text with an explicit locale Differs from Stata: The locale is explicitly English; choose the relevant locale for language-sensitive casing. Stata reference · R reference |
|
stringi
|
Normalize canonically equivalent Unicode
text Stata reference · R reference |
|
stringi
|
Normalize compatibility Unicode
characters Stata reference · R reference |
|
base
|
Locate a Unicode substring by code-point
position Stata reference · R reference |
|
stringr
|
Unicode-aware regular expression, ignoring case Differs from Stata: stringr is Unicode-aware throughout, so the u- forms of Stata's string functions need no special version. R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
stringr
|
Detect Unicode letters Differs from Stata: ICU regex workflow; missing strings in R remain NA rather than empty Stata strings. Stata reference · R reference |
|
stringr
|
Replace every ICU regex
match Stata reference · R reference |
|
stringr
|
Replace the first ICU regex
match Stata reference · R reference |
|
stringi
|
Reverse Unicode code-point order Differs from Stata: Combining marks and grapheme clusters may require a different user-facing reversal rule. Stata reference · R reference |
|
stringr
|
Trim Unicode
whitespace Stata reference · R reference |
|
stringr
|
Uppercase Unicode text with an explicit locale Differs from Stata: Explicit English locale; locale-specific casing can differ from Stata defaults. Stata reference · R reference |
|
base
|
Extract one Unicode code point by position R character indexing follows code points; this does not count grapheme clusters. Stata reference · R reference |
|
stringr
|
The first word of a string Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Extract the second simple whitespace word Differs from Stata: Simple unquoted words with at least two tokens; Stata quoted-word parsing is not reproduced. Stata reference · R reference |
|
stringr
|
Number of words Differs from Stata: R Unicode, regular-expression and case rules can differ from non-ustr Stata string functions; Stata empty strings are missing whereas R distinguishes empty strings and NA. Stata reference · R reference |
|
base
|
Count simple whitespace-separated words Differs from Stata: Unquoted ASCII words only; quoted multiword phrases need a parser. Stata reference · R reference |
|
lubridate
|
Year of a date lubridate::month(), day() and wday() extract the other parts. Stata reference · R reference |
|
base
|
Extract calendar years Differs from Stata: Accepts an R Date column and returns the demonstrated calendar component; raw Stata date codes require conversion first. Stata reference · R reference |
|
base
|
Construct Stata monthly codes from year and month Differs from Stata: Requires valid integer months 1–12; output uses Stata months since January 1960. Stata reference · R reference |
|
base
|
Construct Stata quarterly codes from year and quarter Differs from Stata: Requires valid integer quarters 1–4; output uses quarters since 1960q1. Stata reference · R reference |
Loops and programming
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
utils
|
Update installed
packages Stata reference · R reference |
|
tidystata
|
Run code and keep its result without stopping on an
error Differs from Stata: Returns the expression's result on success; on error, emits a failure message and returns invisible NULL. quiet = TRUE suppresses the notice, warnings and messages, but keeps printed output. Use capture(data <- update(data)) to preserve an existing object if the update fails; data <- capture(update(data)) assigns NULL on error. Separate assignments in a captured block keep the last completed update; a single assignment around a failed pipeline keeps the original target. Earlier effects are not rolled back. This adapts Stata capture, which suppresses all output. Stata reference · R reference |
|
base
|
Remove every object Restarting R (Session > Restart R in RStudio) gives a truly clean start. Stata reference · R reference |
|
base
|
Clear the console In RStudio, Ctrl+L does the same. Stata reference · R reference |
|
stats
|
A stored
coefficient Stata reference · R reference |
|
stats
|
A stored standard
error Stata reference · R reference |
|
broom
|
Model statistics broom::tidy(fit) gives the coefficient table, and names(fit) lists every stored part. Stata reference · R reference |
|
dplyr
|
Same calculation for several variables across() replaces most variable loops; for other loops R has for (v in names) { ... }. Stata reference · R reference |
|
dplyr
|
Loop with a
condition Stata reference · R reference |
|
dplyr
|
Loop over variables numbered in their names A regular expression picks the names. varlist("x_[6-10]_*") works when only one number range is needed. Stata reference · R reference |
|
tibble
|
Hold another dataset R keeps any number of data frames as separate objects, so frames are built in. Stata reference · R reference |
|
base
|
Run code only if a condition holds Quote it: findit("if"), because if is a reserved word in R. Stata reference · R reference |
|
base
|
Store a list of variable names Use it with all_of(): select(data, all_of(vars)) or across(all_of(vars), ...). Stata reference · R reference |
|
base
|
List defined
objects Stata reference · R reference |
|
base
|
Create a
matrix Stata reference · R reference |
|
base
|
Keep a copy to return to R never changes data in place, so keep the original object and assign results to a new name; restore is data <- backup. Stata reference · R reference |
|
base
|
Write your own
command Stata reference · R reference |
|
stats
|
Run without printing Assigning a result never prints it; print(fit) or summary(fit) shows it later. Stata reference · R reference |
|
tidystata
|
See the results a command stored R results are ordinary objects: assign them and pick out parts, as in s <- summ(data, x); s$mean. Stata reference · R reference |
|
base
|
Store a single
number Stata reference · R reference |
|
base
|
Make random numbers reproducible Differs from Stata: set_seed(.fn, seed) sets the seed inside a pipe; see the sample rows. R and Stata use different random-number streams; the same numeric seed does not reproduce the same draws or selected rows. Stata reference · R reference |
|
base
|
Find where an error happened debug(f) or browser() steps through a function line by line. Stata reference · R reference |
|
base
|
A temporary file Temporary variables are not needed: intermediate columns can be dropped, or kept as separate objects. Stata reference · R reference |
|
tidystata
|
Time how long code
takes Stata reference · R reference |
|
base
|
Version control renv::snapshot() records package versions so a project can be reproduced later. Stata reference · R reference |
|
utils
|
Where a command comes
from Stata reference · R reference |
|
base
|
Repeat while a condition
holds Stata reference · R reference |
Models and tables
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
fixest
|
Regression absorbing one categorical variable Differs from Stata: Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
car
|
Added-variable
plots Stata reference · R reference |
|
sandwich
|
Bootstrap standard errors Differs from Stata: The R code estimates covariance for an existing fit; resampling units, centering and t/normal inference must match the Stata bootstrap/jackknife prefix options. Stata reference · R reference |
|
stats
|
K-means clustering Differs from Stata: R defaults to Hartigan-Wong k-means and random initial centers; Stata initialization and iteration defaults differ. Control the starting centers to compare clusters. Stata reference · R reference |
|
did
|
Staggered difference in differences Differs from Stata: Match control-group, anticipation and estimation-method settings; csdid and att_gt() defaults and aggregation/inference need not coincide. Stata reference · R reference |
|
fixest
|
Difference in differences (Stata 17+) Differs from Stata: The TWFE coefficient alone omits didregress default group-clustered standard errors and diagnostics; specify clustering and verify the DID design. Stata reference · R reference |
|
lmtest
|
Breusch-Pagan test for heteroskedasticity These options match Stata's default test against the fitted values. Stata reference · R reference |
|
stats
|
Information criteria Differs from Stata: Compare the same fitted sample and likelihood constants; R classes and Stata can count scale parameters and likelihood terms differently. Stata reference · R reference |
|
lmtest
|
RESET test for omitted
variables Stata reference · R reference |
|
stats
|
Variance-covariance
matrix Stata reference · R reference |
|
stats
|
Keep a model for later A fitted model is an ordinary object; keep as many as you like under different names. Stata reference · R reference |
|
modelsummary
|
Compare models side by
side Stata reference · R reference |
|
stats
|
Store a model for a
table Stata reference · R reference |
|
modelsummary
|
Regression
table Stata reference · R reference |
|
modelsummary
|
Table of the last model (Stata
17+) Stata reference · R reference |
|
stats
|
Generalised linear
model Stata reference · R reference |
|
sampleSelection
|
Heckman selection
model Stata reference · R reference |
|
fixest
|
Instrumental variables with robust errors Differs from Stata: fixest::fitstat(fit, ~ ivf + ivwald) reports first-stage statistics. Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
fixest
|
Instrumental variables (2SLS) Differs from Stata: Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
sandwich
|
Jackknife standard errors Differs from Stata: The R code estimates covariance for an existing fit; resampling units, centering and t/normal inference must match the Stata bootstrap/jackknife prefix options. Stata reference · R reference |
|
marginaleffects
|
Linear combination of coefficients Differs from Stata: hypotheses() uses the fitted R covariance and degrees-of-freedom defaults; Stata can use a different t, F or normal reference distribution. Stata reference · R reference |
|
broom
|
Logit model reported as odds ratios Differs from Stata: broom confidence intervals are model-specific; glm profile-likelihood intervals can differ from Stata default Wald intervals, even when odds ratios agree. Stata reference · R reference |
|
stats
|
Logit model Stata reference · R reference |
|
broom
|
Odds ratios Differs from Stata: broom confidence intervals are model-specific; glm profile-likelihood intervals can differ from Stata default Wald intervals, even when odds ratios agree. Stata reference · R reference |
|
lmtest
|
Likelihood-ratio test Differs from Stata: Compare the same fitted sample and likelihood constants; R classes and Stata can count scale parameters and likelihood terms differently. Stata reference · R reference |
|
marginaleffects
|
Predictive margins by group Differs from Stata: by = "group" averages within observed groups; margins group sets each level for every observation before averaging. Use counterfactual predictions for that Stata estimand. Stata reference · R reference |
|
marginaleffects
|
Average marginal effects Differs from Stata: avg_slopes() averages model derivatives; discrete factor changes, weights and covariance must match margins and the fitted-model context. Stata reference · R reference |
|
marginaleffects
|
Plot predictive
margins Stata reference · R reference |
|
lme4
|
Multilevel logit Differs from Stata: glmer() defaults to Laplace integration (nAGQ = 1); melogit defaults to adaptive quadrature, which can change estimates and likelihoods. Stata reference · R reference |
|
mice
|
Fit and combine models across imputations Differs from Stata: Rubin pooling still requires matching complete-data degrees of freedom and small-sample adjustments to mi estimate. Stata reference · R reference |
|
mice
|
Multiple imputation Differs from Stata: mice() chooses methods by R column type, often predictive mean matching; it does not default to the specified chained linear regressions. Match methods, predictors and m explicitly. Stata reference · R reference |
|
lme4
|
Multilevel (mixed) linear model Differs from Stata: lme4 reports no p-values; lmerTest::lmer() adds them. lmer() defaults to REML; Stata mixed defaults to ML. Use REML = FALSE for ML and select a separate method for fixed-effect p-values. Stata reference · R reference |
|
nnet
|
Multinomial logit Differs from Stata: multinom() needs a factor y for multinomial classification; reference outcome categories and optimizer defaults can differ from Stata mlogit. Stata reference · R reference |
|
MASS
|
Negative binomial model Differs from Stata: fixest::fenegbin() adds fixed effects. glm.nb() uses NB2 like default nbreg, but theta is the reciprocal of Stata alpha and likelihood/optimization reporting differs. Stata reference · R reference |
|
marginaleffects
|
Nonlinear combination of coefficients Differs from Stata: Standard errors use the delta method, as in Stata. hypotheses() uses the fitted R covariance and degrees-of-freedom defaults; Stata can use a different t, F or normal reference distribution. Stata reference · R reference |
|
oaxaca
|
Blinder-Oaxaca decomposition Differs from Stata: oaxaca() reports several reference-weight decompositions; explicitly select the reference coefficients and variance method used by Stata oaxaca. Stata reference · R reference |
|
MASS
|
Ordered logit Differs from Stata: Hess = TRUE lets summary() show standard errors. polr() uses ordered factor levels and a threshold parameterization; set the order explicitly and check the cutpoint sign convention against Stata. Stata reference · R reference |
|
MASS
|
Ordered probit Differs from Stata: polr() uses ordered factor levels and a threshold parameterization; set the order explicitly and check the cutpoint sign convention against Stata. Stata reference · R reference |
|
modelsummary
|
Regression table in a Word
file Stata reference · R reference |
|
stats
|
Poisson
model Stata reference · R reference |
|
fixest
|
Poisson model with fixed effects Differs from Stata: Poisson fixed-effect coefficient targets agree, but separation/singleton removal and covariance corrections can differ; check the retained sample and uncertainty. Stata reference · R reference |
|
stats
|
Fitted values Differs from Stata: residuals(fit) gives residuals for the rows used in the model. predict() depends on the R model: response/link scale, residual definition and prediction sample must match the Stata postestimation context. Stata reference · R reference |
|
stats
|
Predicted probabilities Differs from Stata: predict() depends on the R model: response/link scale, residual definition and prediction sample must match the Stata postestimation context. Stata reference · R reference |
|
stats
|
Residuals for every row Differs from Stata: predict() depends on the R model: response/link scale, residual definition and prediction sample must match the Stata postestimation context. Stata reference · R reference |
|
stats
|
Probit
model Stata reference · R reference |
|
flextable
|
Write a table to Word officer builds whole Word documents. Stata reference · R reference |
|
writexl
|
Write results to Excel openxlsx2 gives cell-level control over formatting. Stata reference · R reference |
|
quantreg
|
Median (quantile) regression Differs from Stata: rq() default standard-error methods depend on sample size and can differ from Stata qreg; choose the covariance/inference method explicitly. Stata reference · R reference |
|
rdrobust
|
Regression discontinuity Differs from Stata: The R and Stata implementations share the estimator; version, bandwidth, mass-point and variance settings must also match for finite-sample output. Stata reference · R reference |
|
fixest
|
High-dimensional fixed effects Differs from Stata: Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
stats
|
Linear regression summary(fit) shows the coefficient table; broom::tidy(fit) returns it as a data frame. Stata reference · R reference |
|
stats
|
Factor variables and interactions Differs from Stata: factor() plays the role of i.; x1 * x2 is c.x1##c.x2 and x1:x2 is c.x1#c.x2. factor() chooses its reference from R level order; Stata i.group uses its numeric base level. Set factor levels and contrasts explicitly. Stata reference · R reference |
|
stats
|
Choose the base
category Stata reference · R reference |
|
fixest
|
Regression with sampling weights Differs from Stata: For full survey designs with strata and clusters, see svyset. Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
fixest
|
Heteroskedasticity-robust standard errors Differs from Stata: Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
fixest
|
Clustered standard errors Differs from Stata: Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
MASS
|
Robust regression Differs from Stata: rlm() uses Huber M-estimation; Stata's rreg combines Huber and biweight steps, so estimates can differ slightly. rlm() defaults to Huber M-estimation; rreg screens outliers and combines Huber and biweight iterations, so estimates and inference can differ. Stata reference · R reference |
|
stats
|
Residuals against fitted
values Stata reference · R reference |
|
lavaan
|
Structural equation model Differs from Stata: lavaan treats observed exogenous predictors as fixed by default; match fixed.x and missing-data likelihood settings with Stata sem. Stata reference · R reference |
|
Synth
|
Synthetic control Synth::dataprep() builds prep from the panel first; tidysynth offers a tidier interface. Stata reference · R reference |
|
WeightIt
|
Inverse-probability
weighting Stata reference · R reference |
|
MatchIt
|
Propensity-score matching Estimate the effect on the matched data, for example lm(y ~ t, data = MatchIt::match.data(m), weights = weights). Stata reference · R reference |
|
marginaleffects
|
Test a hypothesis about coefficients Differs from Stata: hypotheses() uses the fitted R covariance and degrees-of-freedom defaults; Stata can use a different t, F or normal reference distribution. Stata reference · R reference |
|
AER
|
Censored (tobit)
regression Stata reference · R reference |
|
car
|
Variance inflation factors Differs from Stata: car::vif() gives generalized VIFs for multi-degree-of-freedom terms; Stata estat vif reports regressor-column VIFs, so factor-term tables differ. Stata reference · R reference |
|
plm
|
Dynamic panel (Arellano-Bond) Differs from Stata: pgmm() needs matching transformation, lag instruments, collapse and one/two-step choices; the formula alone does not reproduce xtabond default instruments or standard errors. Stata reference · R reference |
|
survival
|
Conditional (fixed-effects) logit Differs from Stata: fixest::feglm(y ~ x | id, family = binomial) is faster but estimates unconditional fixed effects. clogit() targets conditional fixed-effects logit; exact likelihood, weights and covariance settings must match xtlogit, fe rather than unconditional dummy-variable logit. Stata reference · R reference |
|
fixest
|
Fixed-effects Poisson Differs from Stata: Poisson fixed-effect coefficient targets agree, but separation/singleton removal and covariance corrections can differ; check the retained sample and uncertainty. Stata reference · R reference |
|
fixest
|
Panel fixed effects Differs from Stata: Match fixest covariance small-sample corrections and singleton handling with Stata; the same formula does not guarantee identical standard errors or retained observations. Stata reference · R reference |
|
plm
|
Panel random effects Differs from Stata: plm and xtreg, re default to different variance-component estimators; match random.method and the panel sample before comparing results. Stata reference · R reference |
Panel and time series
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
ARIMA model Differs from Stata: R and Stata ARIMA initialization and intercept parameterizations differ; match the likelihood method and transform intercepts before comparing coefficients. Stata reference · R reference |
|
tidyr
|
Carry the last observed value forward Differs from Stata: group_by(data, id) first to fill within each panel unit. fill() crosses panel boundaries unless grouped first; group_by(id) is needed for within-unit carryforward. Stata reference · R reference |
|
tidystata
|
First difference within each panel stata_diff(x, 2, time = year) is D2.x, the difference of differences. Stata reference · R reference |
|
tidystata
|
Lead within each panel Gaps in year give missing values, as in Stata. Stata reference · R reference |
|
tidystata
|
Lag within each panel Like Stata, gaps in year give missing values; dplyr::lag() shifts rows instead. Use stata_lag(x, 2, time = year) for L2.x and unit = "month" for monthly dates. Stata reference · R reference |
|
dplyr
|
Two-period lag within each panel Differs from Stata: lag(x, 2, order_by = year) shifts two observed rows; L2.x shifts two time units and returns missing across time gaps. Use stata_lag(x, 2, time = year) for that rule. Stata reference · R reference |
|
tsibble
|
Add rows for missing time points Differs from Stata: fill_gaps() fills each key's observed range by default; choose .full explicitly for common panel bounds and ensure the tsibble interval matches the Stata delta. Stata reference · R reference |
|
ggplot2
|
Time-series line
plot Stata reference · R reference |
|
tsibble
|
Declare time-series
data Stata reference · R reference |
|
dplyr
|
How many periods each panel unit
has Stata reference · R reference |
|
ggplot2
|
One line plot per panel unit aes(group = id) without facets draws all units in one plot, like the overlay option. Stata reference · R reference |
|
tsibble
|
Declare panel data tidystata needs no declaration: stata_lag(x, time = year) with .by = id, and fixest takes panel.id = ~id + year. Stata reference · R reference |
|
dplyr
|
Overall and within standard deviations The between part is the standard deviation of the id means: summarise(data, m = mean(x, na.rm = TRUE), .by = id) then sd(m). Stata reference · R reference |
Survival analysis
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
survival
|
Censored-outcome concordance after Cox regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Censoring weights and handling of tied risks/times affect the statistic. Stata reference · R reference |
|
survival
|
Cox proportional-hazards diagnostic Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Schoenfeld-residual implementation and default time transformations differ. Stata reference · R reference |
|
base
|
Actuarial life-table survival over fixed intervals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Uses the half-withdrawal actuarial adjustment and left-closed intervals; censoring is assumed uniform within each interval. Boundary conventions and intervals must match. Stata reference · R reference |
|
survival
|
Baseline Cox survival from cumulative hazard Fixed workflow; adapt the named data columns explicitly. Baseline refers to zero covariates; verify the intended reference profile. Stata basesurv uses a product-limit construction, so exp(-cumulative hazard) is an alternative estimate rather than exact numerical parity. Stata reference · R reference |
|
survival
|
Baseline cumulative hazard at zero covariates Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Cox baseline is centered at zero explicitly; Stata stores results on observation rows whereas R returns unique event/censoring times. Stata reference · R reference |
|
survival
|
Conditional median survival after loglogistic AFT Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Distribution-specific predicted survival quantiles; not the mean time. Stata reference · R reference |
|
survival
|
Deviance residuals after Cox regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Schoenfeld residuals have one row per event; score/influence residuals have one row per observation. Stata reference · R reference |
|
survival
|
Cox coefficient influence residuals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Schoenfeld residuals have one row per event; score/influence residuals have one row per observation. Stata reference · R reference |
|
survival
|
Martingale residuals after Cox regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Schoenfeld residuals have one row per event; score/influence residuals have one row per observation. Stata reference · R reference |
|
survival
|
Scaled Schoenfeld residuals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Schoenfeld residuals have one row per event; score/influence residuals have one row per observation. Stata reference · R reference |
|
survival
|
Event-specific Schoenfeld residuals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Schoenfeld residuals have one row per event; score/influence residuals have one row per observation. Stata reference · R reference |
|
survival
|
Cox score contributions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Schoenfeld residuals have one row per event; score/influence residuals have one row per observation. Stata reference · R reference |
|
survival
|
Cox-Snell expected-event quantities Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Centering is explicitly zero for relative predictions; expected-event quantities depend on each observed follow-up time. Stata reference · R reference |
|
survival
|
Cox relative-hazard scores Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Centering is explicitly zero for relative predictions; expected-event quantities depend on each observed follow-up time. Stata reference · R reference |
|
survival
|
Cox linear predictors Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Centering is explicitly zero for relative predictions; expected-event quantities depend on each observed follow-up time. Stata reference · R reference |
|
stats
|
Convert snapshots to intervals with covariates applying forward Fixed workflow; adapt the named data columns explicitly. The first snapshot defines interval entry, event indicators apply at interval exit, and ordinary covariates apply forward. This explicit workflow drops initial zero-duration rows; check Stata's retained baseline rows before matching row counts. Stata reference · R reference |
|
base
|
Keep baseline record for each subject Fixed workflow; adapt the named data columns explicitly. Record-selection workflow only; stbase may also transform survival-time fields. Stata reference · R reference |
|
survival
|
Median survival with confidence limits Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Median interpolation and confidence-limit conventions can differ. Stata reference · R reference |
|
survival
|
Restricted mean survival through time nine Differs from Stata: rmean="common" restricts the survival integral at the largest observed follow-up time, as Stata stci, rmean does; it does not extrapolate beyond follow-up. Match the analysis sample and censoring declaration. Stata reference · R reference |
|
survival
|
Cox proportional hazards model Differs from Stata: exp(coef(fit)) gives the hazard ratios that stcox reports. coxph() defaults to Efron handling of ties; Stata stcox defaults to Breslow. Set ties = "breslow" to match tied-event likelihoods. Stata reference · R reference |
|
survival
|
Cox treatment-covariate interaction Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Cox regression with Breslow ties Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Weighted Cox model with sandwich covariance Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Cox regression with Efron ties Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Cox regression with exact partial likelihood Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Shared gamma frailty Cox model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Stratified Cox baseline hazards Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Cluster-robust Cox inference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Cox time-varying log-time coefficient Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match ties, risk intervals, weights and reference inference explicitly. Stata reference · R reference |
|
survival
|
Fine-Gray subdistribution-hazard workflow Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Weighted expanded-data implementation; censoring weights and variance choices can differ. Stata reference · R reference |
|
base
|
Describe single-record survival data Fixed workflow; adapt the named data columns explicitly. Single-record, zero-entry fixture; multiple-record subjects require distinct-ID counting. Stata reference · R reference |
|
zoo
|
Carry observed covariates forward within survival
subjects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Requires correctly ordered non-overlapping spells. Leading missing values remain missing; later information is never carried backward. Stata reference · R reference |
|
stats
|
Mark subjects ever exposed during their observed survival
history Differs from Stata: Fixed workflow; adapt the named data columns explicitly. All observed spells contribute to the history. Missing exposure values require an explicit convention rather than treating NA as false. Stata reference · R reference |
|
survival
|
Lognormal regression for interval-censored outcomes Differs from Stata: Stata requires interval(lower upper). The Weibull time option selects AFT coefficients, matching survreg rather than Stata default PH coefficients. For interval2, equal endpoints are exact events, NA lower endpoints denote left censoring, and NA upper endpoints right censoring; encode Stata left-censoring bounds explicitly. Stata reference · R reference |
|
survival
|
Weibull regression for interval-censored outcomes Differs from Stata: Stata requires interval(lower upper). The Weibull time option selects AFT coefficients, matching survreg rather than Stata default PH coefficients. For interval2, equal endpoints are exact events, NA lower endpoints denote left censoring, and NA upper endpoints right censoring; encode Stata left-censoring bounds explicitly. Stata reference · R reference |
|
stats
|
Compare two incidence rates Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R gives a conditional exact test and interval; Stata default intervals may use a different method. Stata reference · R reference |
|
stats
|
Rejoin adjacent constant-covariate spells Fixed workflow; adapt the named data columns explicitly. Only valid when adjacent spells have identical covariates and no intervening event; inspect before collapsing. Stata reference · R reference |
|
base
|
Mantel-Haenszel stratified incidence-rate-ratio point estimate Fixed workflow; adapt the named data columns explicitly. Input is pre-aggregated failure counts and person-time by exposure/stratum. This supplies the rate-ratio point estimate only, not Stata's variance or trend tests. Stata reference · R reference |
|
base
|
Crude incidence rate from person-time Fixed workflow; adapt the named data columns explicitly. Assumes zero entry times and non-overlapping observation spells. Stata reference · R reference |
|
stats
|
Group-specific rates per thousand person-time units Fixed workflow; adapt the named data columns explicitly. Point-rate workflow; confidence intervals need a separate choice. Stata reference · R reference |
|
survival
|
Parametric survival model Differs from Stata: survreg() reports the accelerated failure-time form; Stata's Weibull default is the hazard form, so signs and scales differ. Stata reference · R reference |
|
survival
|
exponential accelerated-failure-time model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. survreg reports AFT coefficients; Weibull PH coefficients require sign and scale conversion. Stata reference · R reference |
|
survival
|
loglogistic accelerated-failure-time model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. survreg reports AFT coefficients; Weibull PH coefficients require sign and scale conversion. Stata reference · R reference |
|
survival
|
lognormal accelerated-failure-time model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. survreg reports AFT coefficients; Weibull PH coefficients require sign and scale conversion. Stata reference · R reference |
|
survival
|
weibull accelerated-failure-time model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. survreg reports AFT coefficients; Weibull PH coefficients require sign and scale conversion. Stata reference · R reference |
|
survival
|
loglogistic AFT model with group-specific scale Differs from Stata: factor(group) gives stratum-specific intercepts and strata(group) gives stratum-specific scales, as in Stata streg, strata(). survreg reports AFT coefficients; convert Weibull/exponential coefficients before comparing Stata hazard-ratio output. Stata reference · R reference |
|
survival
|
lognormal AFT model with group-specific scale Differs from Stata: factor(group) gives stratum-specific intercepts and strata(group) gives stratum-specific scales, as in Stata streg, strata(). survreg reports AFT coefficients; convert Weibull/exponential coefficients before comparing Stata hazard-ratio output. Stata reference · R reference |
|
survival
|
weibull AFT model with group-specific scale Differs from Stata: factor(group) gives stratum-specific intercepts and strata(group) gives stratum-specific scales, as in Stata streg, strata(). survreg reports AFT coefficients; convert Weibull/exponential coefficients before comparing Stata hazard-ratio output. Stata reference · R reference |
|
survival
|
Kaplan-Meier
curve Stata reference · R reference |
|
survival
|
Log-rank
test Stata reference · R reference |
|
survival
|
Kaplan-Meier survival curve data Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R returns curve data; confidence transformations and tied-event handling should be specified for comparisons. Stata reference · R reference |
|
survival
|
Group-specific Kaplan-Meier curves Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R returns curve data; confidence transformations and tied-event handling should be specified for comparisons. Stata reference · R reference |
|
survival
|
Nelson-Aalen cumulative hazard Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R returns curve data; confidence transformations and tied-event handling should be specified for comparisons. Stata reference · R reference |
|
survival
|
Cumulative failure probability Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R returns curve data; confidence transformations and tied-event handling should be specified for comparisons. Stata reference · R reference |
|
survival
|
Kaplan-Meier interval with plain transformation Fixed workflow; adapt the named data columns explicitly. Explicit R confidence transformation; Stata's displayed default may differ. Stata reference · R reference |
|
survival
|
Kaplan-Meier interval with log transformation Fixed workflow; adapt the named data columns explicitly. Explicit R confidence transformation; Stata's displayed default may differ. Stata reference · R reference |
|
survival
|
Kaplan-Meier interval with log-log transformation Fixed workflow; adapt the named data columns explicitly. Explicit R confidence transformation; Stata's displayed default may differ. Stata reference · R reference |
|
survival
|
Log-rank comparison of survival curves Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Unstratified two-group log-rank test. Stata reference · R reference |
|
survival
|
Declare survival-time data R has no declaration step: Surv(time, died) goes on the left of each model formula. Stata reference · R reference |
|
survival
|
Delayed-entry counting-process response Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Supply entry and exit explicitly; multiple spells require one row per risk interval. Stata reference · R reference |
|
survival
|
Right-censored survival response Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Creates a response object rather than declaring global dataset state. Stata reference · R reference |
|
survival
|
Split risk intervals at fixed cut points Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Returns expanded interval data; the episode variable is an interval index. Stata reference · R reference |
|
survival
|
Summary of survival
times Stata reference · R reference |
|
stats
|
Person-time and failure counts by group Fixed workflow; adapt the named data columns explicitly. Subset of stsum output; no survival quantiles are computed. Stata reference · R reference |
|
base
|
Sample nested case-control risk sets from a cohort Fixed workflow; adapt the named data columns explicitly. One-record cohort with no tied failures. Controls are sampled from those at risk for each failure and may recur across sets; tied-failure random ordering and multiple spells need a fuller implementation. Stata reference · R reference |
|
base
|
Check within-subject covariate variation and missingness Fixed workflow; adapt the named data columns explicitly. Returns per-subject flags rather than Stata's aggregate summary table; ignores sampling weights as stvary does. Stata reference · R reference |
Survey data
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
survey
|
Survey-weighted logit Differs from Stata: Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
|
srvyr
|
Survey-weighted mean Differs from Stata: Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
|
survey
|
Survey-weighted regression Differs from Stata: Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
|
srvyr
|
Survey-weighted proportions Differs from Stata: Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
|
srvyr
|
Subpopulation estimate Differs from Stata: Filtering a survey design keeps the full design for the variance, as subpop() does. Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
|
srvyr
|
Survey-weighted means by group Differs from Stata: Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
|
srvyr
|
Survey-weighted proportions with intervals Differs from Stata: Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
|
base
|
Describe the survey
design Stata reference · R reference |
|
srvyr
|
Declare a survey design Differs from Stata: Match design and missing-data exclusions first; singleton-PSU policy, degrees of freedom and confidence-interval transformations can differ between R and Stata. Stata reference · R reference |
Graphs
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
binsreg
|
Binned scatter plot Differs from Stata: statar::stat_binmean() adds binned means to a ggplot: ggplot(data, aes(x, y)) + statar::stat_binmean(n = 20). binsreg() defaults to data-driven bin selection and inference; binscatter defaults to fixed quantile bins and an OLS fit. Match bins and fit settings explicitly. Stata reference · R reference |
|
modelsummary
|
Coefficient plot Stata reference · R reference |
|
ggplot2
|
Show individual observations by category Differs from Stata: This uses horizontally jittered observations rather than Stata dot-stacking rules. Stata reference · R reference |
|
ggplot2
|
Bar chart of
counts Stata reference · R reference |
|
ggplot2
|
Bar chart of group
means Stata reference · R reference |
|
ggplot2
|
Box plot Differs from Stata: ggplot2 boxplot hinges use R quantile rules; Stata uses Stata percentiles, which may differ in small samples and with ties. Stata reference · R reference |
|
ggplot2
|
Save the last
graph Stata reference · R reference |
|
ggplot2
|
Pie
chart Stata reference · R reference |
|
patchwork
|
Combine plots With patchwork attached, p1 + p2 does the same. Stata reference · R reference |
|
ggplot2
|
Dot
chart Stata reference · R reference |
|
ggplot2
|
Horizontal bar
chart Stata reference · R reference |
|
ggplot2
|
Horizontal box plot Differs from Stata: ggplot2 boxplot hinges use R quantile rules; Stata uses Stata percentiles, which may differ in small samples and with ties. Stata reference · R reference |
|
graphics
|
Scatter-plot matrix GGally::ggpairs() draws a ggplot2 version. Stata reference · R reference |
|
base
|
Save a plot to edit
later Stata reference · R reference |
|
ggplot2
|
Plot group frequencies Differs from Stata: Reproduces the displayed count, percent or summary layer, rather than Stata graph display defaults. Match category order and missingness; ggplot themes, axis scales and bar annotations follow R conventions. Stata reference · R reference |
|
ggplot2
|
Plot group means as bars Differs from Stata: Reproduces the displayed count, percent or summary layer, rather than Stata graph display defaults. Match category order and missingness; ggplot themes, axis scales and bar annotations follow R conventions. Stata reference · R reference |
|
ggplot2
|
Label summary bars with their values Differs from Stata: Reproduces the displayed count, percent or summary layer, rather than Stata graph display defaults. Match category order and missingness; ggplot themes, axis scales and bar annotations follow R conventions. Stata reference · R reference |
|
ggplot2
|
Plot group medians as bars Differs from Stata: Reproduces the displayed count, percent or summary layer, rather than Stata graph display defaults. Match category order and missingness; ggplot themes, axis scales and bar annotations follow R conventions. Stata reference · R reference |
|
ggplot2
|
Plot group percentages Differs from Stata: Reproduces the displayed count, percent or summary layer, rather than Stata graph display defaults. Match category order and missingness; ggplot themes, axis scales and bar annotations follow R conventions. Stata reference · R reference |
|
ggplot2
|
Plot group totals as bars Differs from Stata: Reproduces the displayed count, percent or summary layer, rather than Stata graph display defaults. Match category order and missingness; ggplot themes, axis scales and bar annotations follow R conventions. Stata reference · R reference |
|
ggplot2
|
Compare distributions with box plots Differs from Stata: Box-plot hinges and whisker defaults should be checked when numerical parity is required. Stata reference · R reference |
|
ggplot2
|
Hide box-plot outlier markers Differs from Stata: Box-plot hinges and whisker defaults should be checked when numerical parity is required. Stata reference · R reference |
|
ggplot2
|
Plot group means as dots Differs from Stata: Reproduces the displayed count, percent or summary layer, rather than Stata graph display defaults. Match category order and missingness; ggplot themes, axis scales and bar annotations follow R conventions. Stata reference · R reference |
|
ggplot2
|
Draw horizontal box plots Differs from Stata: Box-plot hinges and whisker defaults should be checked when numerical parity is required. Stata reference · R reference |
|
ggplot2
|
Heat map of the mean of z over binned x and y Differs from Stata: Community command. Both average z within cells, but bin counts and boundaries differ; set bins explicitly (bins() in Stata, bins = in R) when comparing. Colour ramps follow each program's defaults. Stata reference · R reference |
|
ggplot2
|
Heat map of the mean of z over categories of x and y Differs from Stata: Community command. One tile per observed x-y combination, filled with the mean of z; empty combinations are left blank in both. Stata reference · R reference |
|
ggplot2
|
Histogram Differs from Stata: geom_histogram() defaults to counts and 30 bins; Stata histogram defaults to density with a different bin rule. Specify breaks/binwidth and the y statistic. Stata reference · R reference |
|
ggplot2
|
Compare histograms across groups Differs from Stata: Set boundaries and interval closure explicitly when matching Stata bin counts. Stata reference · R reference |
|
ggplot2
|
Histogram on the density scale Differs from Stata: Set boundaries and interval closure explicitly when matching Stata bin counts. Stata reference · R reference |
|
ggplot2
|
Histogram on the frequency scale Differs from Stata: Set boundaries and interval closure explicitly when matching Stata bin counts. Stata reference · R reference |
|
ggplot2
|
Histogram on the percentage scale Differs from Stata: Set boundaries and interval closure explicitly when matching Stata bin counts. Stata reference · R reference |
|
ggplot2
|
Choose histogram width and boundary Differs from Stata: Set boundaries and interval closure explicitly when matching Stata bin counts. Stata reference · R reference |
|
ggplot2
|
Histogram for integer-valued observations Differs from Stata: Set boundaries and interval closure explicitly when matching Stata bin counts. Stata reference · R reference |
|
ggplot2
|
Density plot Differs from Stata: Default kernel-density bandwidth rules differ; specify kernel, bandwidth and evaluation range before comparing curves. Stata reference · R reference |
|
ggplot2
|
Plot a kernel density estimate Differs from Stata: R and Stata bandwidth rules and local smoothing algorithms can differ; this is a graphical alternative, not an exact numerical replication. Stata reference · R reference |
|
ggplot2
|
Estimate a density for a subgroup Differs from Stata: R and Stata bandwidth rules and local smoothing algorithms can differ; this is a graphical alternative, not an exact numerical replication. Stata reference · R reference |
|
ggplot2
|
Specify a kernel bandwidth Differs from Stata: R and Stata bandwidth rules and local smoothing algorithms can differ; this is a graphical alternative, not an exact numerical replication. Stata reference · R reference |
|
ggplot2
|
Use a Gaussian density kernel Differs from Stata: R and Stata bandwidth rules and local smoothing algorithms can differ; this is a graphical alternative, not an exact numerical replication. Stata reference · R reference |
|
ggplot2
|
Line plot Differs from Stata: geom_line() sorts by x within groups; Stata line/connected uses observation order without the sort option. Stata reference · R reference |
|
ggplot2
|
Line plot sorted by the horizontal variable Differs from Stata: Maps the stated axes and layer; line sorts by x in ggplot while Stata uses sort here. Plot themes, axis expansion, missing-point warnings and facet scales follow R defaults. Stata reference · R reference |
|
ggplot2
|
Draw line plots in separate group panels Differs from Stata: Maps the stated axes and layer; line sorts by x in ggplot while Stata uses sort here. Plot themes, axis expansion, missing-point warnings and facet scales follow R defaults. Stata reference · R reference |
|
ggplot2
|
Set a line colour Differs from Stata: Maps the stated axes and layer; line sorts by x in ggplot while Stata uses sort here. Plot themes, axis expansion, missing-point warnings and facet scales follow R defaults. Stata reference · R reference |
|
ggplot2
|
Smoothed scatter plot Differs from Stata: LOESS local polynomials differ from Stata LOWESS smoothing, robustness iterations and bandwidth defaults; the fitted curves need not coincide. Stata reference · R reference |
|
ggplot2
|
Draw a local regression smooth Differs from Stata: R and Stata bandwidth rules and local smoothing algorithms can differ; this is a graphical alternative, not an exact numerical replication. Stata reference · R reference |
|
graphics
|
Compare empirical and chi-squared probabilities Differs from Stata: A diagnostic plotting workflow; plotting-position and standardization defaults can differ from Stata. Stata reference · R reference |
|
graphics
|
Assess a standardized normal P-P relationship Differs from Stata: A diagnostic plotting workflow; plotting-position and standardization defaults can differ from Stata. Stata reference · R reference |
|
graphics
|
Compare sample quantiles with chi-squared quantiles Differs from Stata: A diagnostic plotting workflow; plotting-position and standardization defaults can differ from Stata. Stata reference · R reference |
|
ggplot2
|
Normal quantile plot Differs from Stata: geom_qq() defaults to theoretical standard-normal quantiles; qnorm scales the normal axis by the sample mean and SD. Match axis scaling to compare points. Stata reference · R reference |
|
stats
|
Compare two empirical distributions with a Q-Q plot Differs from Stata: A diagnostic plotting workflow; plotting-position and standardization defaults can differ from Stata. Stata reference · R reference |
|
graphics
|
Plot ordered data against cumulative fractions Differs from Stata: A diagnostic plotting workflow; plotting-position and standardization defaults can differ from Stata. Stata reference · R reference |
|
ggplot2
|
Scatter
plot Stata reference · R reference |
|
ggplot2
|
Label the
points Stata reference · R reference |
|
ggplot2
|
Add a reference line geom_hline(yintercept = 0) is yline(). Stata reference · R reference |
|
ggplot2
|
Scatter plot with ggplot2 Differs from Stata: Maps the stated axes and layer; line sorts by x in ggplot while Stata uses sort here. Plot themes, axis expansion, missing-point warnings and facet scales follow R defaults. Stata reference · R reference |
|
ggplot2
|
Make the plotting panel square Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Separate scatter plots by group Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Jitter overlapping observations Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Hide a graph legend Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Set the marker colour Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Label each point with a variable Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Increase marker size Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Draw hollow circular markers Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Add a source note to a graph Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Use a monochrome-friendly theme Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Add a graph subtitle Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Add a graph title Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Choose horizontal axis breaks Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Add a vertical reference line Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Use a logarithmic predictor axis Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Label the horizontal axis Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Choose vertical axis breaks Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Add a horizontal reference line Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Use a logarithmic response axis Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Label the vertical axis Differs from Stata: The R example implements the graphical intent; size, jitter and theme scales are not numerically identical to Stata. Stata reference · R reference |
|
ggplot2
|
Plot supplied estimates and standard errors Differs from Stata: Here se is a supplied standard-error variable; Stata serrbar defaults to one standard error. Rename the variable to suit your data. Stata reference · R reference |
|
ggplot2
|
Change the look of every
graph Stata reference · R reference |
|
graphics
|
Plot spikes for the frequencies of distinct values Differs from Stata: Draws one spike for each observed value with its count. Axis ticks, spike widths, handling of missing values and graphics device styling differ from Stata spikeplot. Stata reference · R reference |
|
graphics
|
Check symmetry around the sample median Differs from Stata: A diagnostic plotting workflow; plotting-position and standardization defaults can differ from Stata. Stata reference · R reference |
|
ggplot2
|
Scatter plot with a fitted line Differs from Stata: geom_smooth(method = "lm") adds a confidence band by default; lfit has no band. Use se = FALSE for the same plotted layer. Stata reference · R reference |
|
ggplot2
|
Area
plot Stata reference · R reference |
|
ggplot2
|
Connected line plot Differs from Stata: geom_line() sorts by x within groups; Stata line/connected uses observation order without the sort option. Stata reference · R reference |
|
ggplot2
|
Shaded
range Stata reference · R reference |
|
ggplot2
|
Range plot with capped
spikes Stata reference · R reference |
|
ggplot2
|
Colour points by
group Stata reference · R reference |
|
ggplot2
|
Linear fit with a confidence
band Stata reference · R reference |
|
ggplot2
|
Quadratic
fit Stata reference · R reference |
|
ggplot2
|
One panel per
group Stata reference · R reference |
|
ggplot2
|
Overlay a linear fitted relationship Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Fill the area beneath a line Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Connect points in horizontal order Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw contour lines on a regular grid Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw points with drop lines Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Plot a linear fit with confidence limits Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw arrows between paired coordinates Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Connect paired coordinate endpoints Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Plot a quadratic fit with confidence limits Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw a shaded uncertainty band Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw bars spanning lower and upper values Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw capped uncertainty intervals Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Plot both endpoints of a range Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Show ranges with vertical lines Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw a two-variable scatter plot Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Draw vertical spikes from zero Differs from Stata: Graphical workflow; plotting defaults can differ. Stata reference · R reference |
|
ggplot2
|
Violin
plot Stata reference · R reference |
Programming utilities
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
utils
|
Inspect R version and platform information Reports R session metadata; Stata license and serial information have no R counterpart. Stata reference · R reference |
|
base
|
Inspect the package library search path R package libraries replace ado search directories; this only reads the current path. Stata reference · R reference |
|
base
|
Receive two positional arguments in a function R function arguments replace positional Stata macros; this is a fixed program example. Stata reference · R reference |
|
base
|
Skip the rest of one loop iteration Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Exit a loop early Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Inspect R version, platform, paths and numeric limits Returns R's own settings and constants, not Stata's c-class values. Stata reference · R reference |
|
base
|
Create reproducible R code for a small data example dput emits R reconstruction code, not Stata input code or forum markup. Share only data already approved for disclosure. Stata reference · R reference |
|
base
|
Raise a clear error from a function R conditions replace numeric Stata return codes; the check catches the deliberately raised error. Stata reference · R reference |
|
base
|
Return early from a function Function-level return only; quitting the R process would terminate the user's session. Stata reference · R reference |
|
utils
|
Inspect the R data-manipulation package version and
availability Reports the chosen R workflow dependency, dplyr; it does not inspect or compile a Stata Mata library. Stata reference · R reference |
|
base
|
Split the first simple token from the remaining text Differs from Stata: Simple unquoted whitespace tokens only; Stata quoting and bind rules are not reproduced. Stata reference · R reference |
|
base
|
Execute helper code in the current evaluation environment Only sources the controlled temporary R helper here; R syntax replaces the Stata do-file. Stata reference · R reference |
|
base
|
Create an inclusion marker from a
condition Stata reference · R reference |
|
base
|
Find the row range enclosing a selected sample Returns enclosing row endpoints only; selection can contain gaps and is not replaced by that interval. Stata reference · R reference |
|
base
|
Clear an inclusion marker when variables are
incomplete Stata reference · R reference |
|
base
|
Mark complete rows over supplied column names R receives column names explicitly; no Stata syntax parser state or if/in qualifiers are read. Stata reference · R reference |
|
base
|
Format a numeric matrix for display Differs from Stata: Returns a character matrix; R does not duplicate Stata's borders/equation headers. Stata reference · R reference |
|
base
|
Name matrix columns Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Create a matrix from selected numeric variables Differs from Stata: X is the fixed matrix object name; R row names need not match Stata r1, r2 labels. Stata reference · R reference |
|
base
|
Create a matrix after listwise missing
exclusion Stata reference · R reference |
|
base
|
Expand a numeric list with a fixed step Constructs this list directly; it does not parse arbitrary Stata numlist strings. Stata reference · R reference |
|
base
|
Expand a decreasing consecutive numeric list Direct R sequence workflow for the displayed Stata list. Stata reference · R reference |
|
base
|
Append one result observation Appends to the R accumulator; a separate save writes the final file. Stata reference · R reference |
|
base
|
Persist an accumulated result table Finalizes the R accumulator as RDS rather than closing a Stata postfile handle. Stata reference · R reference |
|
base
|
Initialize a typed result accumulator R accumulator workflow: append rows, then save separately; no disk handle is opened yet. Stata reference · R reference |
|
base
|
Inspect current R output settings Read-only R settings query; these are R-specific options rather than Stata parameter names. Stata reference · R reference |
|
base
|
Require an installed R workflow dependency Checks the R counterpart dependency dplyr; no package is installed and Stata package names do not translate automatically. Stata reference · R reference |
|
base
|
Require a minimum version of an R workflow dependency The R counterpart has its own version requirement; 1.1.0 supports the .by and relationship features used in these examples. Stata reference · R reference |
|
base
|
Pause execution using milliseconds converted to seconds R Sys.sleep takes seconds; no machine-speed timing assertion is made. Stata reference · R reference |
|
base
|
Convert matrix columns to named variables Differs from Stata: Creates a new table; merging with an existing dataset requires an explicit row/key alignment. Stata reference · R reference |
|
base
|
Validate a numeric column argument and an optional scalar Uses R formals and explicit checks; it does not parse Stata's command grammar. Stata reference · R reference |
|
base
|
Inspect R installation and temporary directories Shows R directories; Stata BASE/PLUS/PERSONAL directories have no one-to-one mapping. Stata reference · R reference |
|
base
|
Reserve a unique temporary path Differs from Stata: tempfile() reserves a name without creating a file; R does not guarantee Stata-style cleanup of each named file when a function exits. Stata reference · R reference |
|
base
|
Use a temporary scalar inside local scope Lexical scope supplies isolation rather than a unique Stata temporary object name. Stata reference · R reference |
|
base
|
Compute with a temporary vector in a local scope R local scope avoids adding a temporary dataset column; no Stata macro name is generated. Stata reference · R reference |
|
base
|
Tokenize a quoted phrase and a word Differs from Stata: Demonstrates basic double-quoted whitespace tokens; Stata compound quoting has no automatic equivalent. Stata reference · R reference |
|
base
|
Split simple whitespace-separated tokens Differs from Stata: R returns a character vector instead of positional local macros; quoted-token parsing differs. Stata reference · R reference |
|
base
|
Resolve an unambiguous abbreviated column name R partial matching must be requested explicitly; exact matches take precedence. Stata reference · R reference |
|
base
|
Expand a column-name prefix wildcard Handles the displayed simple prefix wildcard; this is not a complete Stata varlist parser. Stata reference · R reference |
|
base
|
Resolve a unique abbreviation among known R choices Illustrates explicit R-choice matching, not translation of Stata command abbreviations; Stata gen corresponds to generate. Stata reference · R reference |
|
base
|
Inspect the body of a named R function Reads an R function body rather than opening a Stata ado source editor. Stata reference · R reference |
Data management
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
dplyr
|
Append tables allowing different column sets Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
dplyr
|
Append only selected columns from the using
table Stata reference · R reference |
|
dplyr
|
Record origin while appending several
datasets Stata reference · R reference |
|
base
|
Assert a group attribute is constant for each
identifier Stata reference · R reference |
|
base
|
Assert that districts belong to one
region Stata reference · R reference |
|
base
|
Locate differing rows in a selected column Workflow inspects x only; compare each column for the complete verbose report. Stata reference · R reference |
|
base
|
Assert selected dataset values match Differs from Stata: Compares the supplied in-memory other table in row order; ignores metadata as cf does. Stata reference · R reference |
|
base
|
Copy a column and its
attributes Stata reference · R reference |
|
base
|
Describe observed count, distinct count and range Differs from Stata: Numeric codebook subset; does not reproduce Stata's variable-label and format report. Stata reference · R reference |
|
base
|
Compare value ordering and missingness Differs from Stata: Produces the principal comparison counts; not Stata's formatted difference summary. Stata reference · R reference |
|
base
|
Compare ordering inside a subset Differs from Stata: Returns ordering counts only; use a separate summary for difference magnitudes. Stata reference · R reference |
|
base
|
Reduce safe whole-number storage to R integers Manual whole-number optimization only. R has no Stata byte/int storage classes or general compress equivalent. Stata reference · R reference |
|
base
|
Count rows complete on selected
columns Stata reference · R reference |
|
base
|
Count missing
values Stata reference · R reference |
|
base
|
Count observed values above a
threshold Stata reference · R reference |
|
base
|
Count a row interval Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
dplyr
|
Form the Cartesian product of two datasets Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
dplyr
|
Create the empirical cumulative distribution of a
variable Differs from Stata: Missing values stay missing and are excluded from the denominator. By default Stata gives tied values distinct cumulatives in an arbitrary order; R breaks ties by row order. Weights and by() need an explicit grouped or weighted version. Stata reference · R reference |
|
dplyr
|
Cumulative distribution with equal values for ties Tied values share the largest cumulative proportion, as ecdf(x)(x) does; missing values stay missing. Stata reference · R reference |
|
base
|
Assert data match a stored R signature R-specific byte comparison; not interoperable with Stata .dtasig files. Stata reference · R reference |
|
base
|
Store an exact R serialization for later comparison R-specific serialized snapshot; not Stata's checksum algorithm, and R metadata is included. Stata reference · R reference |
|
base
|
Inspect storage types of selected
columns Stata reference · R reference |
|
base
|
Get dataset dimensions compactly Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Parse clean numeric
strings Stata reference · R reference |
|
base
|
Parse a decimal-comma
field Stata reference · R reference |
|
base
|
Parse numbers containing grouping
commas Stata reference · R reference |
|
base
|
Convert percentage text to
proportions Stata reference · R reference |
|
base
|
Drop a category of
rows Stata reference · R reference |
|
base
|
Drop rows missing a
value Stata reference · R reference |
|
tidyr
|
Drop rows incomplete on selected
columns Stata reference · R reference |
|
dplyr
|
Drop low values while retaining missing rows Differs from Stata: Stata numeric missing sorts above finite values; the explicit is.na branch preserves those rows. Stata reference · R reference |
|
base
|
Drop a row interval Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Remove selected
columns Stata reference · R reference |
|
base
|
Find columns outside an exclusion
list Stata reference · R reference |
|
base
|
Find names of numeric columns Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Find names of character columns Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Retain the first observation per duplicated
key Stata reference · R reference |
|
base
|
Inspect all members of duplicated
keys Stata reference · R reference |
|
base
|
Summarize copies, observations and duplicate
surplus Stata reference · R reference |
|
dplyr
|
Tag all group members with duplicate surplus
count Stata reference · R reference |
|
dplyr
|
Attach group means without collapsing
rows Stata reference · R reference |
|
dplyr
|
Attach group totals without collapsing
rows Stata reference · R reference |
|
base
|
Count listed values across
columns Stata reference · R reference |
|
base
|
Flag any listed value across
columns Stata reference · R reference |
|
base
|
Concatenate numeric and string columns Differs from Stata: Treats R NA strings as Stata empty strings; numeric formatting is simple decimal here. Stata reference · R reference |
|
base
|
Repeat the nonmissing count in a
column Stata reference · R reference |
|
base
|
Bin values and label bins by lower
endpoint Stata reference · R reference |
|
base
|
Flag differing values across two columns Differs from Stata: Ordinary missing is handled explicitly; extended Stata missing categories need separate comparison. Stata reference · R reference |
|
base
|
Repeat the first nonmissing
value Stata reference · R reference |
|
base
|
Encode combinations of group keys Differs from Stata: Combination IDs identify groups; exact numeric codes and string collation may differ from Stata. Stata reference · R reference |
|
base
|
Repeat the interquartile range Differs from Stata: Uses R quantile type 2 for Stata's default empirical percentile rule. Stata reference · R reference |
|
base
|
Repeat the last nonmissing
value Stata reference · R reference |
|
base
|
Repeat the maximum in a
column Stata reference · R reference |
|
base
|
Repeat the mean in a
column Stata reference · R reference |
|
base
|
Repeat the median in a
column Stata reference · R reference |
|
base
|
Repeat the minimum in a
column Stata reference · R reference |
|
base
|
Express values as percentages of the column total Requires a nonzero observed total; this is a share calculation, not survey estimation. Stata reference · R reference |
|
base
|
Repeat a specified empirical percentile Differs from Stata: Uses R quantile type 2 for Stata's default empirical percentile rule. Stata reference · R reference |
|
base
|
Rank observed values using average
ties Stata reference · R reference |
|
base
|
Rank highest value first with competition
ties Stata reference · R reference |
|
base
|
Find the available row
maximum Stata reference · R reference |
|
base
|
Average available values across
columns Stata reference · R reference |
|
base
|
Find the available row
minimum Stata reference · R reference |
|
base
|
Count missing cells in each
row Stata reference · R reference |
|
base
|
Count observed cells in each
row Stata reference · R reference |
|
base
|
Sum available values across
columns Stata reference · R reference |
|
base
|
Return missing for entirely missing row
totals Stata reference · R reference |
|
base
|
Repeat the sample standard deviation in a
column Stata reference · R reference |
|
base
|
Standardize using the sample standard
deviation Stata reference · R reference |
|
base
|
Tag the first observed row of each
group Stata reference · R reference |
|
base
|
Repeat the sum in a
column Stata reference · R reference |
|
base
|
Duplicate whole groups with fresh group identifiers Differs from Stata: Validates cluster membership and copy counts; the numeric assignment/order of new IDs may differ from Stata. Stata reference · R reference |
|
dplyr
|
Collapse means with the ftools public
helper Stata reference · R reference |
|
dplyr
|
Merge fcollapse group summaries back into original
rows Stata reference · R reference |
|
dplyr
|
Preserve missing for entirely missing group
sums Stata reference · R reference |
|
tidyr
|
Insert absent combinations of categorical keys Differs from Stata: Returns the rectangularized table without Stata's _fillin indicator; factor levels may add unused R categories. Stata reference · R reference |
|
tidyr
|
Mark rows inserted during categorical
rectangularization Stata reference · R reference |
|
base
|
Store observed categories from the ftools levels
helper Stata reference · R reference |
|
dplyr
|
Perform a validated ftools-style one-to-one merge Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
base
|
Read linked values dynamically without storing a copied column R accessor-function workflow, not an alias column: call get_score() each time; modifications belong in lookup. Stata reference · R reference |
|
base
|
Rename a linked value when copying it Value-copy workflow; frame linkage and Stata metadata are not carried into R. Stata reference · R reference |
|
base
|
Copy a value through an established table link Differs from Stata: Copies values using the precomputed link. Stata display formats and metadata require explicit copying in R. Stata reference · R reference |
|
base
|
Validate and construct a one-to-one table link link is a fixed R object name; unmatched keys produce NA. Rebuild after source changes. Stata reference · R reference |
|
base
|
Build a many-to-one row link to a lookup table R match indices are a snapshot and must be rebuilt after lookup row reordering. Stata reference · R reference |
|
base
|
Materialize a dynamically looked-up value as a column Materialize an ordinary R column snapshot. Requires data and lookup tables with matching id keys and a lookup score column; later lookup changes do not change this column. Stata reference · R reference |
|
dplyr
|
Collapse group means using the gcollapse
workflow Stata reference · R reference |
|
dplyr
|
Keep raw group row counts beside collapsed
means Stata reference · R reference |
|
dplyr
|
Add collapsed group means back to all original
rows Stata reference · R reference |
|
dplyr
|
Collapse group missing-value
counts Stata reference · R reference |
|
dplyr
|
Collapse group distinct-value counts on complete data Differs from Stata: Complete values in this fixture; treatment of missing categories is not asserted. Stata reference · R reference |
|
dplyr
|
Count jointly observed category
combinations Stata reference · R reference |
|
dplyr
|
Create category counts and percentages with
gcontract Stata reference · R reference |
|
base
|
Count distinct values separately for several
columns Stata reference · R reference |
|
base
|
Count distinct complete combinations
jointly Stata reference · R reference |
|
base
|
Keep the first row of each compound
key Stata reference · R reference |
|
dplyr
|
Tag all duplicates of compound
keys Stata reference · R reference |
|
base
|
Create identifiers for complete combinations of keys Differs from Stata: Complete numeric keys only; exact identifier ordering follows the demonstrated lexicographic keys. Stata reference · R reference |
|
base
|
Tag one observation in each nonmissing
group Stata reference · R reference |
|
dplyr
|
Attach group means using a gegen-style
workflow Stata reference · R reference |
|
dplyr
|
Number observations within sorted
groups Stata reference · R reference |
|
dplyr
|
Compute running totals within
groups Stata reference · R reference |
|
dplyr
|
Attach group row
counts Stata reference · R reference |
|
dplyr
|
Mark the first observation within sorted groups Differs from Stata: Sorts by id and year, then marks one first row per id, including a missing-id group. Ties in year use input order in R; add a tie-break variable for a reproducible cross-system choice. Stata reference · R reference |
|
base
|
Create a binary indicator retaining missing
values Stata reference · R reference |
|
base
|
Create a nonmissing
indicator Stata reference · R reference |
|
base
|
Create a running sum ignoring missing values Stata's generate sum() treats missing contributions as zero, unlike raw cumsum(). Stata reference · R reference |
|
base
|
Square a variable preserving missing
values Stata reference · R reference |
|
base
|
Repeat the total row
count Stata reference · R reference |
|
dplyr
|
Shift a column by row position Differs from Stata: Position-based shift; this does not use time-series spacing or tsset semantics. Stata reference · R reference |
|
base
|
Create row
numbers Stata reference · R reference |
|
base
|
Add columns with missing
propagation Stata reference · R reference |
|
base
|
Convert a matrix into named data columns Creates a new R table rather than importing from a separate Mata workspace; X is fixed. Stata reference · R reference |
|
base
|
Validate compound-key uniqueness allowing ordinary
missing Differs from Stata: Ordinary missing is allowed as a key value; extended Stata missing categories are not represented here. Stata reference · R reference |
|
base
|
Assert a unique complete identifier with
gisid Stata reference · R reference |
|
base
|
List distinct complete multi-column keys Differs from Stata: Returns a key table rather than a space-delimited local macro; fixture keys contain no missing values. Stata reference · R reference |
|
base
|
Store sorted distinct categories with
glevelsof Stata reference · R reference |
|
base
|
Assign four empirical quantile categories Differs from Stata: Unweighted distinct finite values; uses explicit R type-2 cutoffs and right-closed categories. Ties can prevent equal group sizes. Stata reference · R reference |
|
base
|
Return selected empirical percentile cutpoints Differs from Stata: Explicit R type-2 unweighted percentile workflow; no alternative-definition or weighted numerical parity is asserted. Stata reference · R reference |
|
tidyr
|
Gather explicitly named wide columns with
greshape Stata reference · R reference |
|
tidyr
|
Drop missing measurements while reshaping one stub Differs from Stata: Single-stub fixed workflow; for multiple stubs drop a row only when every reshaped value is missing. Stata reference · R reference |
|
tidyr
|
Spread text-keyed values into columns with
greshape Stata reference · R reference |
|
base
|
Sort descending with Stata missing first Numeric missing sorts first in Stata descending order; use na.last=FALSE deliberately. Stata reference · R reference |
|
dplyr
|
Sort by ascending group and descending
value Stata reference · R reference |
|
dplyr
|
Cap tails separately inside each group Differs from Stata: Groups use independent unweighted R type-2 cutoffs; all-missing groups require an explicit policy. Stata reference · R reference |
|
base
|
Cap both tails at explicitly selected empirical
quartiles Differs from Stata: Unweighted workflow with an explicit R type-2 empirical percentile rule; no cross-software numerical certification is claimed. Stata reference · R reference |
|
base
|
Set values outside empirical quartiles to missing Differs from Stata: Trimming sets tails to missing while retaining rows; percentile rule is explicit R type 2 and no weighted parity is asserted. Stata reference · R reference |
|
dplyr
|
Find the two most frequent complete categories Differs from Stata: Returns the leading categories and counts only; Stata cumulative/Other rows are not generated. gtop is an alias and is not counted separately. Stata reference · R reference |
|
base
|
Count unique complete row-key combinations Differs from Stata: Complete keys in this fixture; unlike gdistinct without joint, gunique treats all listed columns jointly. Stata reference · R reference |
|
dplyr
|
Attach distinct-value counts within each group Differs from Stata: Complete group and value columns in this example; no missing-category behavior is asserted. Stata reference · R reference |
|
base
|
Stably sort by ascending group and descending value Differs from Stata: Complete numeric keys only; R radix sort preserves original order for equal keys. No comparative speed claim is made. Stata reference · R reference |
|
base
|
Insert a missing row after a position Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Insert a missing row before a position Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Append two entirely missing observations Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Count signs and missing values Differs from Stata: Sign/missing counts only; Stata's histogram and integer diagnostic are not included. Stata reference · R reference |
|
base
|
Keep boundary missing values outside the interpolation
range Stata reference · R reference |
|
base
|
Assert a compound key uniquely identifies
rows Stata reference · R reference |
|
base
|
Assert a key is unique and
nonmissing Stata reference · R reference |
|
base
|
Allow one ordinary missing value in a unique
key Stata reference · R reference |
|
dplyr
|
Form every matching pair within
groups Stata reference · R reference |
|
dplyr
|
Keep unmatched master rows while forming group pairs Differs from Stata: Returns paired rows without the Stata _merge indicator. Stata reference · R reference |
|
base
|
Keep named columns in
order Stata reference · R reference |
|
base
|
Keep complete rows on selected
columns Stata reference · R reference |
|
dplyr
|
Filter to a category with
dplyr Stata reference · R reference |
|
base
|
Keep a set of
categories Stata reference · R reference |
|
base
|
Keep rows missing a
value Stata reference · R reference |
|
base
|
Keep nonempty strings Differs from Stata: Stata string missing is empty text; this excludes both empty text and R NA. Stata reference · R reference |
|
base
|
Keep observed values above a
threshold Stata reference · R reference |
|
base
|
Keep a row interval by position Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Store distinct observed numeric
categories Stata reference · R reference |
|
base
|
List distinct values including ordinary
missing Stata reference · R reference |
|
base
|
Inspect selected rows and
columns Stata reference · R reference |
|
utils
|
Show selected columns from the first
rows Stata reference · R reference |
|
utils
|
Show the last rows Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Search column names without case sensitivity Differs from Stata: Searches names only; include each column's label attribute to search variable labels too. Stata reference · R reference |
|
utils
|
Measure the memory occupied by one R table Reports one object's estimated memory, not Stata's process-wide memory allocation report. Stata reference · R reference |
|
dplyr
|
Record master-only, using-only and matched status Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
dplyr
|
Keep all master rows in a one-to-one merge Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
dplyr
|
Keep only matched keys in a one-to-one merge Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
dplyr
|
Limit using-table columns during merge Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
dplyr
|
Perform a validated one-to-one full merge Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
dplyr
|
Fill master missing values from matched using values Differs from Stata: Shows value update only; Stata update conflict status codes 4/5 are not generated. Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
dplyr
|
Expand unique master keys to multiple matching rows Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
dplyr
|
Attach unique group attributes to many rows Requires disjoint non-key column names unless update is explicitly shown. dplyr suffixes overlapping names; ordinary Stata merge preserves master values, including master missing values, on matched rows. Stata reference · R reference |
|
base
|
Drop rows missing on every selected numeric
variable Stata reference · R reference |
|
base
|
Drop entirely missing numeric columns Differs from Stata: Numeric-only fixture; Stata string missing is empty text and would require an additional R test for empty strings. Stata reference · R reference |
|
base
|
Report missing-value counts by numeric variable Differs from Stata: Numeric columns only. The R result includes zero counts; Stata report defaults to showing counts at least one. Stata reference · R reference |
|
base
|
Count numeric missing values within each
row Stata reference · R reference |
|
base
|
Count joint missingness patterns Differs from Stata: TRUE marks missing in the R pattern string; Stata's displayed symbols/order differ. Stata reference · R reference |
|
base
|
Count missing values for each selected
column Stata reference · R reference |
|
base
|
Convert multiple sentinel codes to
missing Stata reference · R reference |
|
haven
|
Convert a sentinel to tagged missing Differs from Stata: Tagged missing preserves the label but R comparisons still follow NA semantics. Stata reference · R reference |
|
base
|
Encode missing values with a
sentinel Stata reference · R reference |
|
haven
|
Encode one tagged missing
category Stata reference · R reference |
|
base
|
Alphabetize column order Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
dplyr
|
Move a column to the
end Stata reference · R reference |
|
dplyr
|
Move a column after
another Stata reference · R reference |
|
base
|
Move selected columns to the
front Stata reference · R reference |
|
base
|
Copy numeric columns into an R matrix R matrix workflow replaces the separate Mata workspace; X is a fixed matrix name. Stata reference · R reference |
|
base
|
Copy complete numeric rows into a matrix R matrix workflow replaces Mata; rows are removed jointly over the selected columns. Stata reference · R reference |
|
base
|
Create an evenly spaced grid including
endpoints Stata reference · R reference |
|
base
|
Attach a grid using the current row
count Stata reference · R reference |
|
base
|
Create a decreasing numeric
grid Stata reference · R reference |
|
base
|
Compute a mean over each closed numeric-key
neighborhood Differs from Stata: Small complete-data workflow with inclusive key offsets and self included; quadratic scanning is not intended for large datasets. Stata reference · R reference |
|
base
|
Exclude the current row from numeric-range means Differs from Stata: Excludes row identity rather than all tied keys. Every fixture neighborhood has another observation; empty neighborhoods need NA handling. Stata reference · R reference |
|
base
|
Compute a sum over each closed numeric-key
neighborhood Differs from Stata: Complete finite keys/values only in this fixture; missing bounds, by-groups and weights need explicit extensions. Stata reference · R reference |
|
base
|
Convert an integer column to
double Stata reference · R reference |
|
base
|
Store whole-number values as R integers Differs from Stata: Only use when values are whole numbers in R's integer range; Stata storage ranges differ. Stata reference · R reference |
|
base
|
Collapse integer categories to two groups Differs from Stata: Fixture values are integers 1 through 6; specify additional branches for values outside those ranges. Stata reference · R reference |
|
base
|
Recode selected values and retain all
others Stata reference · R reference |
|
base
|
Rename several columns
together Stata reference · R reference |
|
base
|
Lowercase all column names Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Uppercase all column names Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Replace a column-name prefix Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
dplyr
|
Rename a column with
dplyr Stata reference · R reference |
|
base
|
Replace empty text without replacing NA Differs from Stata: R distinguishes empty text from NA; this example targets empty text only. Stata reference · R reference |
|
base
|
Convert a sentinel to
missing Stata reference · R reference |
|
base
|
Replace numeric missing by
zero Stata reference · R reference |
|
base
|
Modify values only inside a
category Stata reference · R reference |
|
base
|
Fill missing values from another
column Stata reference · R reference |
|
tidyr
|
Reshape multiple parallel measurement stubs Fixed two-stub example; all name patterns and source names must be changed together. Stata reference · R reference |
|
tidyr
|
Convert a wide measurement stub to long rows Fixed x1/x2 stub example; source names, stub and output names must be changed together. Stata reference · R reference |
|
tidyr
|
Use text suffixes when widening measurements Differs from Stata: Fixed string-suffix workflow; pair keys must be unique. Stata reference · R reference |
|
tidyr
|
Convert unique long measurements to wide columns Differs from Stata: Requires unique id-wave pairs; duplicates must be resolved explicitly rather than silently aggregated. Stata reference · R reference |
|
base
|
Create group-specific copies of a numeric
column Stata reference · R reference |
|
base
|
Separate a column by a binary expression The generated stub z is fixed here; z0 and z1 are the false and true branches. Stata reference · R reference |
|
base
|
Leave remaining rows missing after a short integer
sequence Stata reference · R reference |
|
base
|
Create a specified integer sequence with a deliberate
gap Stata reference · R reference |
|
base
|
Restore a temporary data snapshot Restores an explicitly supplied RDS path rather than a numbered Stata snapshot. Stata reference · R reference |
|
base
|
Save a temporary on-disk data snapshot Uses an RDS file path rather than Stata's numbered interactive snapshot manager. Stata reference · R reference |
|
base
|
Sort lexicographically on two
columns Stata reference · R reference |
|
base
|
Keep original order within equal
keys Stata reference · R reference |
|
base
|
Sort a numeric column with missing
last Stata reference · R reference |
|
base
|
Assign a balanced random half-split Differs from Stata: Random assignments differ across R and Stata; this fixture has even sample size. Stata reference · R reference |
|
base
|
Assign three equal random subsamples Differs from Stata: Requires the fixture row count to be divisible by three; random assignments differ across systems. Stata reference · R reference |
|
base
|
Stack pairs of columns
together Stata reference · R reference |
|
base
|
Stack two columns vertically with a source
indicator Stata reference · R reference |
|
base
|
Format numeric identifiers with leading
zeros Stata reference · R reference |
|
base
|
Format numeric text to two decimal places Differs from Stata: R example omits field-width padding; values are rounded for display and stored as text. Stata reference · R reference |
|
tidystata
|
Create indicator variables omitting the lowest
category Differs from Stata: Keeps the original columns and omits the first observed category. Numeric categories are ordered by value; R factors follow their level order, which must match Stata's omitted category. Stata names indicators by category code; R numbers observed categories with .names="index". Use factor(g) in models; xi: interactions are not reproduced. Stata reference · R reference |
|
base
|
Transpose an entirely numeric table Differs from Stata: Numeric-only input; R output column names differ from Stata's v1, v2 names. Stata reference · R reference |
|
base
|
Transpose values while retaining original column
names Differs from Stata: Numeric-only input. Original names are copied into _varname; R transposed column names may differ. Stata reference · R reference |
Files and import/export
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
base
|
Normalize a text file to Unix newlines Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Write text using explicit Windows CRLF bytes Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
tools
|
Compute a file integrity digest MD5 is a workflow alternative: Stata checksum uses POSIX CRC, so digest values are not comparable. Stata reference · R reference |
|
tools
|
Save a file digest in a sidecar text file Writes an R MD5 sidecar, not a Stata .sum file; Stata cannot validate this format as its CRC sidecar. Stata reference · R reference |
|
base
|
Copy a local file to a new path src and dst are temporary paths in this runnable fixture; no network transfer is involved. Stata reference · R reference |
|
base
|
Overwrite a destination file with a local copy Demonstrates overwrite on newly created temporary files only. Stata reference · R reference |
|
base
|
List CSV files in a directory Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
List files including hidden dot files Differs from Stata: R all.files includes dot files; hidden-file conventions vary by operating system. Stata reference · R reference |
|
utils
|
Export CSV without variable
names Stata reference · R reference |
|
utils
|
Export selected columns to
CSV Stata reference · R reference |
|
utils
|
Export a tab-separated
table Stata reference · R reference |
|
writexl
|
Export selected columns to an Excel
workbook Stata reference · R reference |
|
haven
|
Export data in SAS XPORT version 5 format Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
haven
|
Export labelled values to an SPSS system file Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Read one line through a text connection Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Write and close a UTF-8 text connection The example closes its own temporary connection explicitly. Stata reference · R reference |
|
base
|
Replace literal text throughout a small file Differs from Stata: Line-oriented small-file workflow; binary patterns and large-file streaming are not covered. Stata reference · R reference |
|
base
|
Replace tab separators in a text file Differs from Stata: Literal small-text-file replacement; quoted delimiters in tabular data need a parser instead. Stata reference · R reference |
|
base
|
Find a named file inside a specified directory Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Inspect a file as hexadecimal byte values Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Count byte values in a binary file Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
utils
|
Import a CSV file with a header Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
utils
|
Read a selected range of text rows Differs from Stata: Row numbers refer to physical file rows including the header; R column names are fixed in this example. Stata reference · R reference |
|
utils
|
Preserve zero-padded identifiers during import Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
utils
|
Import a CSV file without a header Differs from Stata: R column names id and x are supplied explicitly; Stata would choose default names without further renaming. Stata reference · R reference |
|
utils
|
Import tab-separated values Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
readxl
|
List worksheet names before importing Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
readxl
|
Import a bounded Excel cell rectangle Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
readxl
|
Read one named Excel worksheet Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
haven
|
Import a SAS XPORT version 5 file Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
haven
|
Import an SPSS system file Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
utils
|
Recognize blank and period missing markers on import Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
utils
|
Import whitespace-separated numeric fields Free-format example with simple unquoted numeric fields. Stata reference · R reference |
|
utils
|
Import quoted text and numeric
fields Stata reference · R reference |
|
utils
|
Read adjacent fixed-width numeric
fields Stata reference · R reference |
|
utils
|
Read fixed-width fields while skipping a
spacer Stata reference · R reference |
|
DBI
|
Append controlled rows to an existing SQL table Requires an existing Stata DSN/JDBC connection for the shown Stata example. The controlled SQLite fixture verifies the SQL/table operation, not ODBC/JDBC driver connection; use an appropriate DBI backend in production. Stata reference · R reference |
|
DBI
|
Load an entire SQL table through a DBI backend Requires an existing Stata DSN/JDBC connection for the shown Stata example. The controlled SQLite fixture verifies the SQL/table operation, not ODBC/JDBC driver connection; use an appropriate DBI backend in production. Stata reference · R reference |
|
base
|
Create a directory The runnable fixture creates a new directory under R's temporary directory. Stata reference · R reference |
|
DBI
|
Inspect database table field names Requires an existing Stata DSN/JDBC connection for the shown Stata example. The controlled SQLite fixture verifies the SQL/table operation, not ODBC/JDBC driver connection; use an appropriate DBI backend in production. This row returns names only, not the Stata column-type report. Stata reference · R reference |
|
DBI
|
Load selected rows from a SQL query Requires an existing Stata DSN/JDBC connection for the shown Stata example. The controlled SQLite fixture verifies the SQL/table operation, not ODBC/JDBC driver connection; use an appropriate DBI backend in production. Stata reference · R reference |
|
DBI
|
Inspect available tables in a database Requires an existing Stata DSN/JDBC connection for the shown Stata example. The controlled SQLite fixture verifies the SQL/table operation, not ODBC/JDBC driver connection; use an appropriate DBI backend in production. Stata reference · R reference |
|
utils
|
Export comma-separated fields without a
header Stata reference · R reference |
|
utils
|
Export plain numeric fields with Stata-style missing
text Stata reference · R reference |
|
haven
|
Save a table as a current Stata DTA file Differs from Stata: R object names are not stored as Stata's active-data state; haven writes supported Stata metadata. Stata reference · R reference |
|
haven
|
Write a Stata 12-compatible DTA file Differs from Stata: Use names accepted by haven's older-format validation; this fixture uses names of at least two characters. Stata reference · R reference |
|
haven
|
Save the data as an SPSS file Differs from Stata: Community command. haven writes variable and value labels, but rejects Stata tagged missing values (.a, .b) with an error. Convert them explicitly to ordinary NA or to chosen SPSS user-missing codes with haven::labelled_spss() before writing. String widths and display formats may differ. Stata reference · R reference |
|
rprojroot
|
Locate a project root from a marker file Uses the explicit .here marker and a supplied starting path; the Stata command also supports other markers and stores a global macro. Stata reference · R reference |
|
base
|
Read lines from a UTF-8 text file Differs from Stata: Returns text lines; print or cat them for a console display. Stata reference · R reference |
|
base
|
Read only the beginning of a text file Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Convert a Latin-1 text file to UTF-8 Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
utils
|
Extract a ZIP archive into a chosen temporary
directory Differs from Stata: R extraction directory is explicit; Stata defaults to the current working directory. Stata reference · R reference |
|
haven
|
Read selected columns from a DTA
file Stata reference · R reference |
|
haven
|
Read the first observations from a DTA file Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
zip
|
Create a ZIP archive containing a text file Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
Labels and metadata
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
base
|
Inspect custom column characteristics Returns all R attributes, including any custom metadata. Stata reference · R reference |
|
base
|
Store a custom column characteristic R attributes serve as local metadata; many transformations do not preserve arbitrary attributes. Stata reference · R reference |
|
haven
|
Decode numeric value labels to
text Stata reference · R reference |
|
base
|
Encode nonempty categories in sorted order Differs from Stata: Creates integer codes only. Add a labelled vector or keep the factor to retain category labels; collation is locale-dependent. Stata reference · R reference |
|
base
|
Attach a dataset label Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Define a reusable value-label mapping R stores the mapping as a named vector; attach it separately to each labelled column. Stata reference · R reference |
|
base
|
Read a column's value-label mapping Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
haven
|
Remove value labels while preserving numeric
values Stata reference · R reference |
|
haven
|
Attach a numeric value-label
dictionary Stata reference · R reference |
|
base
|
Remove a variable
label Stata reference · R reference |
|
base
|
Attach a descriptive variable
label Stata reference · R reference |
|
base
|
Inspect value-label dictionaries by column Differs from Stata: Lists attached dictionaries; does not reproduce Stata's full multilingual label audit. Stata reference · R reference |
|
haven
|
Assign existing text values as numeric value labels Differs from Stata: Requires a unique text label per observed numeric code; this preserves supplied numeric codes rather than alphabetically encoding text. Stata reference · R reference |
|
base
|
Read notes attached to a column Reads a custom R notes attribute; preservation depends on subsequent transformations. Stata reference · R reference |
|
base
|
Attach a text note to a column R attribute workflow; numbered Stata note management is not recreated. Stata reference · R reference |
|
base
|
Prefix each label with its numeric code Fixed workflow example; adapt the object and column names together. Stata reference · R reference |
|
base
|
Remove a known numeric-code label prefix Differs from Stata: Targets the demonstrated positive-integer prefix format; other masks require a matching pattern. Stata reference · R reference |
|
base
|
Make a value-label dictionary table Uses an already imported labelled column. R has no separate Stata label-definition name; lname uses the column name. Stata reference · R reference |
Descriptive tables
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
dplyr
|
Replace rows with group nonmissing
counts Stata reference · R reference |
|
dplyr
|
Replace rows with group first values including
missing Stata reference · R reference |
|
dplyr
|
Replace rows with group first nonmissing
values Stata reference · R reference |
|
dplyr
|
Replace rows with group last values including
missing Stata reference · R reference |
|
dplyr
|
Replace rows with group last nonmissing
values Stata reference · R reference |
|
dplyr
|
Replace rows with group
maxima Stata reference · R reference |
|
stats
|
Collapse integer-frequency-weighted values to a mean Differs from Stata: Frequency-weighted mean only; no inference or weighted-variance formula is implied. Stata reference · R reference |
|
dplyr
|
Use common complete cases for group
summaries Stata reference · R reference |
|
dplyr
|
Replace rows with group
means Stata reference · R reference |
|
dplyr
|
Replace rows with group
medians Stata reference · R reference |
|
dplyr
|
Replace rows with group
minima Stata reference · R reference |
|
dplyr
|
Replace rows with group
totals Stata reference · R reference |
|
dplyr
|
Create category counts from integer frequency
weights Stata reference · R reference |
|
dplyr
|
Count observed combinations of two
categories Stata reference · R reference |
|
base
|
Include unobserved combinations with zero
frequency Stata reference · R reference |
|
dplyr
|
Replace observations with category
frequencies Stata reference · R reference |
|
dplyr
|
Create cumulative frequencies and
percentages Stata reference · R reference |
|
dplyr
|
Create category frequencies and
percentages Stata reference · R reference |
|
dplyr
|
Exclude missing categories before contracting Differs from Stata: Excludes both empty strings and R NA to match Stata's nonmissing string categories. Stata reference · R reference |
|
base
|
Get detailed empirical percentiles Differs from Stata: Percentile portion of summarize detail, using R type 2; skewness/kurtosis are not returned here. Stata reference · R reference |
|
base
|
Compute mean-only summary
components Stata reference · R reference |
|
base
|
Make separate one-way frequency
tables Stata reference · R reference |
|
base
|
Make each pairwise contingency
table Stata reference · R reference |
|
stats
|
Display a complete table of precomputed cell values Differs from Stata: Requires one row for every cell and unique keys; xtabs would otherwise sum duplicates or fill absent cells with zero. Stata reference · R reference |
|
base
|
Compare count, mean and spread across numeric
columns Stata reference · R reference |
|
dplyr
|
Summarize nonmissing counts and means by
category Stata reference · R reference |
|
base
|
Return the interquartile range as a descriptive
statistic Differs from Stata: Uses the Stata-default empirical percentile rule through R quantile type 2. Stata reference · R reference |
|
base
|
Return the maximum as a descriptive statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the mean as a descriptive statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the minimum as a descriptive statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the nonmissing count as a descriptive
statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the 25th percentile as a descriptive statistic Differs from Stata: Uses the Stata-default empirical percentile rule through R quantile type 2. Stata reference · R reference |
|
base
|
Return the median as a descriptive statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the 75th percentile as a descriptive statistic Differs from Stata: Uses the Stata-default empirical percentile rule through R quantile type 2. Stata reference · R reference |
|
base
|
Return the range as a descriptive statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the sample standard deviation as a descriptive
statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the standard error of the mean as a descriptive
statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the sum as a descriptive statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Return the sample variance as a descriptive statistic Differs from Stata: Unweighted descriptive statistic; no survey or sampling-design correction is applied. Stata reference · R reference |
|
base
|
Count a single categorical
variable Stata reference · R reference |
|
stats
|
Tabulate integer frequency
weights Stata reference · R reference |
|
base
|
Count a two-way contingency
table Stata reference · R reference |
|
base
|
Compute percentages of all table
cells Stata reference · R reference |
|
base
|
Compute percentages within each table
column Stata reference · R reference |
|
base
|
Compute percentages within each table
row Stata reference · R reference |
|
tidystata
|
Create a full set of category indicators Differs from Stata: Keeps all observations; a missing category gives NA in every dummy. R returns a separate data frame with category-based names; the Stata stub d is not a templated output name. Stata reference · R reference |
|
base
|
Include missing categories in a frequency table Differs from Stata: Maps R NA to an explicit table category; empty character strings remain a separate R value. Stata reference · R reference |
Models and tests
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Compare arithmetic, geometric and harmonic means Differs from Stata: Returns the three point estimates for positive nonmissing values; Stata also reports their confidence intervals. Stata reference · R reference |
|
VGAM
|
Fit jointly correlated binary probit equations Differs from Stata: Both binary equations share x and use a constant latent correlation; rho link parameterizations differ but fitted joint probabilities have the same model meaning. Stata reference · R reference |
|
boot
|
Estimate a median and bootstrap its confidence
interval Point-estimate correspondence; this uses a percentile bootstrap interval, whereas Stata centile defaults to a binomial order-statistic interval. Stata reference · R reference |
|
multcomp
|
Form group contrasts against the reference category Differs from Stata: Returns contrast estimates and covariance. Stata contrast defaults to unadjusted tests; summary(glht) defaults to single-step multiplicity adjustment. Use summary(result, test=multcomp::adjusted("none")) for unadjusted p-values. Stata reference · R reference |
|
VGAM
|
Fit a right-censored Poisson count model Differs from Stata: Fixed right-censoring limit 4; status is one for exact counts and zero for counts known to be at least 4. Censoring must not be treated as truncation. Stata reference · R reference |
|
glmnet
|
Fit cross-validated elasticnet linear prediction Prediction workflow: folds, standardization, penalty grids, loss scaling and lambda selection differ from Stata defaults; coefficients need not match. Stata reference · R reference |
|
effectsize
|
Estimate Cohen standardized mean differences for two independent
groups Differs from Stata: Uses pooled SD and first-group minus second-group direction; reverse the sign if the substantive contrast is reversed. Stata reference · R reference |
|
stats
|
Compute a pooled-SD effect size from group summaries Fixed summary-statistic workflow returns Cohen d only; confidence intervals and Hedges correction are not included. Stata reference · R reference |
|
psych
|
Estimate a one-way individual-measure intraclass
correlation Differs from Stata: Fixed balanced design has three measurements per target. R starts from wide repeated-measure columns; ICC1 is the one-way absolute-agreement individual-measure form. Stata reference · R reference |
|
glmnet
|
Fit cross-validated lasso linear prediction Prediction workflow: folds, standardization, penalty grids, loss scaling and lambda selection differ from Stata defaults; coefficients need not match. Stata reference · R reference |
|
stats
|
Test a factor term in a fitted multivariate model Differs from Stata: After fitting the corresponding MANOVA model. This R row extracts Pillai; Stata manovatest reports four multivariate statistics. Stata reference · R reference |
|
stats
|
Compare successively added regression blocks Differs from Stata: Compares these two nested OLS fits with a partial F test; it does not implement the general Stata prefix that sequences arbitrary model blocks. Stata reference · R reference |
|
stats
|
Orthogonalize centered predictor columns in their stated
order Differs from Stata: Unweighted QR gives an orthogonal basis with mean square one; signs can differ from Stata modified Gram-Schmidt output. Stata reference · R reference |
|
stats
|
Construct three orthogonal polynomial columns Differs from Stata: Rescales the R orthonormal basis to mean square one; polynomial signs and stored coefficient conventions may differ. Stata reference · R reference |
|
stats
|
Apply a nonlinear prediction transform with delta-method standard
errors Differs from Stata: Run after a logit GLM. This uses the derivative p*(1-p) and the fitted linear-index standard error. Stata reference · R reference |
|
stats
|
Compare all group pairs with Tukey simultaneous
intervals Differs from Stata: After the one-way equal-variance model y on g; R TukeyHSD is not a general replacement for adjusted margins in arbitrary models. Stata reference · R reference |
|
stats
|
Compare group means using Bonferroni-adjusted pooled
tests Differs from Stata: Uses a common pooled within-group variance and Bonferroni-adjusted pairwise t tests. The returned p-value matrix does not include Stata pairwise mean-difference confidence intervals. Stata reference · R reference |
|
car
|
Test equal group variances using median-centered Levene
inference Differs from Stata: Corresponds to robvar W50; Stata additionally reports mean-centered W0 and 10-percent-trimmed W10. Stata reference · R reference |
|
stats
|
Test whether a binary threshold sequence has random
runs Differs from Stata: Uses the large-sample uncorrected runs statistic, matching Stata default continuity convention; missing values must be removed before this workflow. Stata reference · R reference |
|
VGAM
|
Fit a rank-one stereotype multinomial logit model Differs from Stata: Uses the reduced-rank multinomial-logit form of the one-dimensional Anderson stereotype model. Category score identification, scale and sign conventions can differ. Stata reference · R reference |
|
stats
|
Test matched-table symmetry directly from cell counts Differs from Stata: For this 2-by-2 table the symmetry test is the uncorrected McNemar test. Stata also reports table summaries; this R result is an htest object. Stata reference · R reference |
|
VGAM
|
Fit zero-truncated NB2 regression Differs from Stata: Zero-truncated NB2 with constant size; VGAM size equals 1/alpha. Information-matrix and optimizer conventions can differ. Stata reference · R reference |
|
VGAM
|
Fit zero-truncated Poisson regression Differs from Stata: Zero-truncation only: fitted values are conditional positive-count means, while log-link coefficients parameterize the latent Poisson lambda. Stata reference · R reference |
|
VGAM
|
Fit a zero-left-truncated normal regression Differs from Stata: VGAM posnormal represents the special case of normal observations selected above zero; this example does not cover varying or upper truncation limits. Stata reference · R reference |
|
stats
|
Test a mean using a known population standard
deviation Differs from Stata: The value 3 is assumed known as a population SD, not estimated from the sample. Stata reference · R reference |
|
stats
|
Compare independent means from known-variance
summaries Differs from Stata: Treats the supplied standard deviations as known and uses a normal reference distribution. Returns the z statistic and two-sided p-value, without Stata confidence limits. Stata reference · R reference |
Statistical distributions
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Evaluate the F cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the F
density Stata reference · R reference |
|
stats
|
Evaluate the F upper-tail
probability Stata reference · R reference |
|
stats
|
Evaluate the beta
density Stata reference · R reference |
|
stats
|
Compute an inclusive binomial lower
tail Stata reference · R reference |
|
stats
|
Evaluate a binomial probability
mass Stata reference · R reference |
|
stats
|
Compute an inclusive binomial upper tail Stata includes k in the upper tail; R lower.tail=FALSE excludes its q argument, so use k-1. Stata reference · R reference |
|
mvtnorm
|
Evaluate a correlated bivariate normal probability Differs from Stata: Evaluates a bivariate normal probability using mvtnorm numerical integration. Integration tolerance and numerical rounding differ from the Stata distribution function. Stata reference · R reference |
|
stats
|
Evaluate the Cauchy cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the Cauchy
density Stata reference · R reference |
|
stats
|
Evaluate the Cauchy upper-tail
probability Stata reference · R reference |
|
stats
|
Evaluate the chi-squared cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the chi-squared
density Stata reference · R reference |
|
stats
|
Evaluate the chi-squared upper-tail
probability Stata reference · R reference |
|
MASS
|
Generate pseudo-data with exactly specified sample
moments Differs from Stata: empirical=TRUE imposes the sample mean and covariance; such pseudo-data are not independent random draws. Stata reference · R reference |
|
MASS
|
Draw independent standard normal columns jointly Differs from Stata: Random streams differ; R returns a data frame of generated columns. Stata reference · R reference |
|
stats
|
Evaluate the exponential cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the exponential
density Stata reference · R reference |
|
stats
|
Evaluate the exponential upper-tail
probability Stata reference · R reference |
|
stats
|
Evaluate the gamma
density Stata reference · R reference |
|
stats
|
Evaluate a shifted gamma
density Stata reference · R reference |
|
stats
|
Evaluate the gamma cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the gamma upper-tail
probability Stata reference · R reference |
|
stats
|
Compute an inclusive hypergeometric lower
tail Stata reference · R reference |
|
stats
|
Evaluate a hypergeometric probability
mass Stata reference · R reference |
|
stats
|
Evaluate the beta cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the beta upper-tail
probability Stata reference · R reference |
|
stats
|
Find the F 90th
percentile Stata reference · R reference |
|
stats
|
Find a F upper-tail critical
value Stata reference · R reference |
|
stats
|
Solve a binomial CDF for its success probability These Stata inverse functions solve for a distribution parameter, not a discrete outcome quantile. Stata reference · R reference |
|
stats
|
Solve an inclusive binomial tail for success probability These Stata inverse functions solve for a distribution parameter, not a discrete outcome quantile. Stata reference · R reference |
|
stats
|
Find the Cauchy 90th
percentile Stata reference · R reference |
|
stats
|
Find a Cauchy upper-tail critical
value Stata reference · R reference |
|
stats
|
Find the chi-squared 90th
percentile Stata reference · R reference |
|
stats
|
Find a chi-squared upper-tail critical
value Stata reference · R reference |
|
stats
|
Find the exponential 90th
percentile Stata reference · R reference |
|
stats
|
Find a exponential upper-tail critical
value Stata reference · R reference |
|
stats
|
Find the gamma 90th
percentile Stata reference · R reference |
|
stats
|
Find a gamma upper-tail critical
value Stata reference · R reference |
|
stats
|
Find the beta 90th
percentile Stata reference · R reference |
|
stats
|
Find a beta upper-tail critical
value Stata reference · R reference |
|
stats
|
Convert probability to log
odds Stata reference · R reference |
|
stats
|
Find the logistic 90th
percentile Stata reference · R reference |
|
stats
|
Find a logistic upper-tail critical
value Stata reference · R reference |
|
stats
|
Find a nF noncentral critical
value Stata reference · R reference |
|
stats
|
Find a nF noncentral upper-tail critical
value Stata reference · R reference |
|
stats
|
Solve a negative-binomial CDF for success probability These Stata inverse functions solve for a distribution parameter, not a discrete outcome quantile. Stata reference · R reference |
|
stats
|
Solve a negative-binomial tail for success probability These Stata inverse functions solve for a distribution parameter, not a discrete outcome quantile. Stata reference · R reference |
|
stats
|
Find a nchi2 noncentral critical
value Stata reference · R reference |
|
stats
|
Find a nchi2 noncentral upper-tail critical
value Stata reference · R reference |
|
stats
|
Find a nibeta noncentral critical
value Stata reference · R reference |
|
stats
|
Find the standard normal 90th
percentile Stata reference · R reference |
|
stats
|
Find a nt noncentral critical
value Stata reference · R reference |
|
stats
|
Find a nt noncentral upper-tail critical
value Stata reference · R reference |
|
stats
|
Solve a Poisson CDF for its mean These Stata inverse functions solve for a distribution parameter, not a discrete outcome quantile. Stata reference · R reference |
|
stats
|
Solve an inclusive Poisson tail for its mean These Stata inverse functions solve for a distribution parameter, not a discrete outcome quantile. Stata reference · R reference |
|
stats
|
Find the Student t 90th
percentile Stata reference · R reference |
|
stats
|
Find a Student t upper-tail critical
value Stata reference · R reference |
|
stats
|
Find a Tukey simultaneous-comparison critical value Differs from Stata: Uses the studentized-range quantile from qtukey. R and Stata implement different numerical approximations; tested inputs differed by about 2.5e-8, so compare within numerical tolerance rather than exact equality. Stata reference · R reference |
|
stats
|
Find the Weibull 90th
percentile Stata reference · R reference |
|
stats
|
Find a PH Weibull
percentile Stata reference · R reference |
|
stats
|
Find a PH Weibull upper-tail
quantile Stata reference · R reference |
|
stats
|
Find a Weibull upper-tail critical
value Stata reference · R reference |
|
stats
|
Evaluate a Cauchy log
density Stata reference · R reference |
|
stats
|
Evaluate an inverse-gamma log density Differs from Stata: Uses the reciprocal-gamma change of variables with its log-Jacobian. Match Stata shape and scale parameterization; numerical tail underflow can differ. Stata reference · R reference |
|
mvtnorm
|
Evaluate a multivariate normal log density Differs from Stata: Fixed example uses mean M=(0,0), covariance V=I(2), and evaluation vector X=(1,2). Stata reference · R reference |
|
stats
|
Compute a stable extreme normal log
probability Stata reference · R reference |
|
stats
|
Evaluate a normal log density with location and
scale Stata reference · R reference |
|
stats
|
Convert log odds to
probability Stata reference · R reference |
|
stats
|
Evaluate the logistic cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the logistic
density Stata reference · R reference |
|
stats
|
Evaluate the logistic upper-tail
probability Stata reference · R reference |
|
stats
|
Evaluate the nF noncentral
CDF Stata reference · R reference |
|
stats
|
Evaluate the nF noncentral
density Stata reference · R reference |
|
stats
|
Evaluate the nF noncentral upper
tail Stata reference · R reference |
|
stats
|
Evaluate the nibeta noncentral
density Stata reference · R reference |
|
stats
|
Compute an inclusive nbinomial lower
tail Stata reference · R reference |
|
stats
|
Evaluate a nbinomial probability
mass Stata reference · R reference |
|
stats
|
Compute an inclusive nbinomial upper tail Stata includes k in the upper tail; R lower.tail=FALSE excludes its q argument, so use k-1. Stata reference · R reference |
|
stats
|
Evaluate the nchi2 noncentral
CDF Stata reference · R reference |
|
stats
|
Evaluate the nchi2 noncentral
density Stata reference · R reference |
|
stats
|
Evaluate the nchi2 noncentral upper
tail Stata reference · R reference |
|
stats
|
Evaluate the nibeta noncentral
CDF Stata reference · R reference |
|
stats
|
Evaluate the standard normal cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the standard normal
density Stata reference · R reference |
|
stats
|
Evaluate a normal density with location and
scale Stata reference · R reference |
|
stats
|
Solve a noncentral F probability for noncentrality Differs from Stata: Numerically inverts the noncentral F CDF over the displayed bracket. Other inputs can require a different bracket; solver tolerances differ from Stata. Stata reference · R reference |
|
stats
|
Solve a noncentral chi-squared probability for
noncentrality Differs from Stata: Numerically inverts the noncentral chi-square CDF over the displayed noncentrality bracket. Other inputs may need a wider bracket; Stata performs its own domain validation and inversion. Stata reference · R reference |
|
stats
|
Solve a noncentral t probability for noncentrality Differs from Stata: Numerically inverts the noncentral t CDF over the displayed bracket. Negative or larger noncentralities require different bounds; solver tolerances differ from Stata. Stata reference · R reference |
|
stats
|
Evaluate the nt noncentral
CDF Stata reference · R reference |
|
stats
|
Evaluate the nt noncentral upper
tail Stata reference · R reference |
|
stats
|
Compute an inclusive poisson lower
tail Stata reference · R reference |
|
stats
|
Evaluate a poisson probability
mass Stata reference · R reference |
|
stats
|
Compute an inclusive poisson upper tail Stata includes k in the upper tail; R lower.tail=FALSE excludes its q argument, so use k-1. Stata reference · R reference |
|
stats
|
Simulate rbeta variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rbinomial variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rcauchy variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rchi2 variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rexponential variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rgamma variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rhypergeometric variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rlogistic variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rnbinomial variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rpoisson variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rt variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Simulate rweibull variates Differs from Stata: The same seed does not produce matching draws across Stata and R. Stata reference · R reference |
|
stats
|
Evaluate the Student t cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the Student t
density Stata reference · R reference |
|
stats
|
Evaluate the Student t upper-tail
probability Stata reference · R reference |
|
stats
|
Evaluate a studentized-range cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate a shifted Weibull cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the Weibull cumulative
probability Stata reference · R reference |
|
stats
|
Evaluate the Weibull
density Stata reference · R reference |
|
stats
|
Use the proportional-hazards Weibull
parameterization Stata reference · R reference |
|
stats
|
Evaluate a PH Weibull
density Stata reference · R reference |
|
stats
|
Evaluate a PH Weibull survivor
probability Stata reference · R reference |
|
stats
|
Evaluate the Weibull upper-tail
probability Stata reference · R reference |
Models and estimation
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
betareg
|
Fit beta regression with a cloglog mean link Differs from Stata: Uses ordinary ML with a log link for precision, matching Stata slink(log). Without link.phi="log", betareg reports constant phi on the identity scale while Stata reports ln(phi). Responses must lie strictly inside (0,1). Stata reference · R reference |
|
betareg
|
Fit beta regression with a logit mean link Differs from Stata: Uses ordinary ML with a log link for precision, matching Stata slink(log). Without link.phi="log", betareg reports constant phi on the identity scale while Stata reports ln(phi). Responses must lie strictly inside (0,1). Stata reference · R reference |
|
betareg
|
Fit beta regression with a probit mean link Differs from Stata: Uses ordinary ML with a log link for precision, matching Stata slink(log). Without link.phi="log", betareg reports constant phi on the identity scale while Stata reports ln(phi). Responses must lie strictly inside (0,1). Stata reference · R reference |
|
betareg
|
Model beta-regression precision using a covariate Differs from Stata: Uses a log link for precision; align Stata scale-link parameterization before numerical comparison. Stata reference · R reference |
|
stats
|
Fit binomial regression on the or scale Differs from Stata: Risk-ratio and risk-difference models can encounter boundary and convergence problems; inspect fitted probabilities. Stata reference · R reference |
|
stats
|
Fit binomial regression on the rd scale Differs from Stata: Risk-ratio and risk-difference models can encounter boundary and convergence problems; inspect fitted probabilities. Stata reference · R reference |
|
stats
|
Fit binomial regression on the rr scale Differs from Stata: Risk-ratio and risk-difference models can encounter boundary and convergence problems; inspect fitted probabilities. Stata reference · R reference |
|
MASS
|
Profile the Box-Cox response transformation parameter Profiles a grid of response-transform parameters; this does not implement all Stata boxcox predictor-transform models. Stata reference · R reference |
|
quantreg
|
Bootstrap quantile-regression inference Differs from Stata: Uses 99 bootstrap replications for quantile-regression inference. R and Stata random streams and resampling implementations differ, so bootstrap standard errors will not be identical. Stata reference · R reference |
|
stats
|
Fit cloglog regression Differs from Stata: R uses the complementary log-log link. Match the event category and complete cases; the GLM result object and convergence tolerances differ from Stata cloglog. Stata reference · R reference |
|
stats
|
Fit cloglog without an intercept Differs from Stata: R uses the complementary log-log link. Match the event category and complete cases; the GLM result object and convergence tolerances differ from Stata cloglog. Stata reference · R reference |
|
stats
|
Fit OLS with two coefficients constrained to equality Fixed workflow. First define constraint 1 x = z in Stata. Reparameterization imposes this fixed linear constraint; covariance reporting needs the corresponding coefficient transformation. Stata reference · R reference |
|
stats
|
Represent a linear equality constraint as a matrix Fixed workflow: L beta = 0 encodes equal x and z coefficients. A fitting routine must enforce the constraint. Stata reference · R reference |
|
stats
|
Correct a simple regression slope for known predictor
reliability Coefficient-only workflow for one error-prone predictor with known reliability and classical independent measurement error; no EIV standard errors are supplied. Stata reference · R reference |
|
sandwich
|
Fit fractional logit regression with sandwich
inference Differs from Stata: Quasi-binomial fit avoids a noninteger-success warning. Sandwich inference is explicit; finite-sample corrections can differ. Stata reference · R reference |
|
sandwich
|
Fit fractional probit regression with sandwich
inference Differs from Stata: Quasi-binomial fit avoids a noninteger-success warning. Sandwich inference is explicit; finite-sample corrections can differ. Stata reference · R reference |
|
stats
|
Fit a binomial complementary-log-log GLM Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a binomial logit-link GLM Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a binomial probit-link GLM Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a Poisson log-link GLM Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a Poisson identity-link GLM Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit grouped-binomial events and trials Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a gamma log-link model for positive outcomes Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a Gaussian identity-link GLM Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a Gaussian log-link GLM Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a gamma identity-link model Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit a gamma inverse-link model Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit an inverse Gaussian identity-link model Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
stats
|
Fit an inverse Gaussian log-link model Differs from Stata: The family and link are explicit. R and Stata can use different dispersion scaling and reference tests even when fitted means agree; align the sample and scale option before comparing standard errors. Stata reference · R reference |
|
nlme
|
Fit a normal mean model with multiplicative
heteroskedasticity Differs from Stata: nlme models SD as exp(theta*z), so the coefficient on z in Stata log variance is 2*theta. Stata reference · R reference |
|
survival
|
Fit normal regression to interval-valued outcomes Differs from Stata: Uses survreg as a Gaussian interval-likelihood engine for a cross-sectional outcome, without a time-to-event interpretation. Stata reference · R reference |
|
quantreg
|
Estimate slopes of the interquartile range Coefficient workflow only; obtain standard errors by jointly resampling both quantile fits. Stata reference · R reference |
|
stats
|
Report logistic odds ratios Differs from Stata: Exponentiates the binomial logit coefficients to odds ratios. Returns point estimates only, without the confidence intervals and tests printed by Stata logistic. Stata reference · R reference |
|
stats
|
Fit logit regression Differs from Stata: R uses a binomial GLM with the logit link and returns coefficients on the log-odds scale. Match binary coding and complete cases; Stata iteration diagnostics and stored result structure differ. Stata reference · R reference |
|
stats
|
Fit logit without an intercept Differs from Stata: R uses a binomial GLM with the logit link and returns coefficients on the log-odds scale. Match binary coding and complete cases; Stata iteration diagnostics and stored result structure differ. Stata reference · R reference |
|
stats
|
Maximize an explicitly defined normal likelihood Differs from Stata: R optimizes log sigma to enforce positivity; translate the scale parameter back using exp(). Stata reference · R reference |
|
nnet
|
Fit multinomial logit with a chosen reference outcome Differs from Stata: Relevels outcome category 4 to the first R factor level, matching baseoutcome(4). Coefficient labels and optimization criteria differ; keep the same observations and category support. Stata reference · R reference |
|
MASS
|
Fit NB2 negative-binomial regression Differs from Stata: Both use NB2 variance mu+alpha*mu^2; MASS theta is 1/alpha. Stata reference · R reference |
|
stats
|
Fit a nonlinear saturating response curve Differs from Stata: Fits this explicit nonlinear mean function from the supplied starting values. nls and Stata nl use different convergence controls and can reach different local solutions. Stata reference · R reference |
|
stats
|
Fit a nonlinear exponential mean curve Differs from Stata: Fits this explicit nonlinear mean function from the supplied starting values. nls and Stata nl use different convergence controls and can reach different local solutions. Stata reference · R reference |
|
MASS
|
Fit ordered ologit regression Differs from Stata: MASS uses cumulative link intercepts; compare cutpoint and slope sign conventions. Stata reference · R reference |
|
MASS
|
Fit ordered oprobit regression Differs from Stata: MASS uses cumulative link intercepts; compare cutpoint and slope sign conventions. Stata reference · R reference |
|
stats
|
Fit Poisson rates with exposure Differs from Stata: Uses the explicit log offset where shown; exposure must be strictly positive. R returns a glm object or exponentiated coefficients, rather than the Stata estimation table; align overdispersion and robust variance options. Stata reference · R reference |
|
stats
|
Report Poisson incidence-rate ratios Differs from Stata: Uses the explicit log offset where shown; exposure must be strictly positive. R returns a glm object or exponentiated coefficients, rather than the Stata estimation table; align overdispersion and robust variance options. Stata reference · R reference |
|
stats
|
Fit Poisson regression without an intercept Differs from Stata: Uses the explicit log offset where shown; exposure must be strictly positive. R returns a glm object or exponentiated coefficients, rather than the Stata estimation table; align overdispersion and robust variance options. Stata reference · R reference |
|
stats
|
Fit probit regression Differs from Stata: R uses the probit binomial GLM. Match binary coding and complete cases; the GLM result object and convergence tolerances differ from Stata probit. Stata reference · R reference |
|
stats
|
Fit probit without an intercept Differs from Stata: R uses the probit binomial GLM. Match binary coding and complete cases; the GLM result object and convergence tolerances differ from Stata probit. Stata reference · R reference |
|
quantreg
|
Fit conditional quantile 25 regression Differs from Stata: Fits the selected conditional quantile. rq and Stata qreg use different optimization and default covariance estimators; coefficient agreement does not establish standard-error parity. Stata reference · R reference |
|
quantreg
|
Fit conditional quantile 75 regression Differs from Stata: Fits the selected conditional quantile. rq and Stata qreg use different optimization and default covariance estimators; coefficient agreement does not establish standard-error parity. Stata reference · R reference |
|
stats
|
Fit a quadratic regression Differs from Stata: OLS coefficient correspondence requires the same complete-case sample, contrasts and weights. R returns an lm object; Stata coefficient tables and stored estimates have a different structure. Stata reference · R reference |
|
stats
|
Include two continuous main effects and their
interaction Differs from Stata: OLS coefficient correspondence requires the same complete-case sample, contrasts and weights. R returns an lm object; Stata coefficient tables and stored estimates have a different structure. Stata reference · R reference |
|
stats
|
Fit separate linear slopes by group Differs from Stata: OLS coefficient correspondence requires the same complete-case sample, contrasts and weights. R returns an lm object; Stata coefficient tables and stored estimates have a different structure. Stata reference · R reference |
|
stats
|
Adjust regression for a categorical predictor Differs from Stata: OLS coefficient correspondence requires the same complete-case sample, contrasts and weights. R returns an lm object; Stata coefficient tables and stored estimates have a different structure. Stata reference · R reference |
|
stats
|
Fit analytic-weighted least squares Differs from Stata: Weights are proportional inverse variances. Check scale and residual degrees of freedom before comparing software. Stata reference · R reference |
|
stats
|
Fit linear regression in a specified subgroup Differs from Stata: OLS coefficient correspondence requires the same complete-case sample, contrasts and weights. R returns an lm object; Stata coefficient tables and stored estimates have a different structure. Stata reference · R reference |
|
stats
|
Report standardized linear regression slopes Differs from Stata: OLS coefficient correspondence requires the same complete-case sample, contrasts and weights. R returns an lm object; Stata coefficient tables and stored estimates have a different structure. Stata reference · R reference |
|
stats
|
Fit linear regression through the origin Differs from Stata: OLS coefficient correspondence requires the same complete-case sample, contrasts and weights. R returns an lm object; Stata coefficient tables and stored estimates have a different structure. Stata reference · R reference |
|
sandwich
|
Use one-way clustered standard errors with cluster degrees of
freedom Differs from Stata: Only three clusters in this demonstration fixture; substantive applications need adequate independent clusters. Stata reference · R reference |
|
sandwich
|
Report HC2 heteroskedasticity-robust OLS inference Differs from Stata: Coefficient estimates are OLS; covariance correction is selected explicitly. Stata reference · R reference |
|
sandwich
|
Report HC3 heteroskedasticity-robust OLS inference Differs from Stata: Coefficient estimates are OLS; covariance correction is selected explicitly. Stata reference · R reference |
|
sandwich
|
Report HC1 heteroskedasticity-robust OLS inference Differs from Stata: Coefficient estimates are OLS; covariance correction is selected explicitly. Stata reference · R reference |
|
MASS
|
Fit a resistant bisquare regression Workflow equivalent: Stata rreg uses its own screening and iteration sequence, so coefficients need not match. Stata reference · R reference |
|
quantreg
|
Fit several conditional quantiles together This fits coefficients; Stata sqreg also bootstraps their joint covariance. Use a shared-resample bootstrap for joint inference. Stata reference · R reference |
|
AER
|
Fit a left-censored normal Tobit model Differs from Stata: Uses the explicit left and/or right censoring limits. AER returns a survreg-based Gaussian censored model; scale parameter reporting and coefficient-table inference differ from Stata. Stata reference · R reference |
|
AER
|
Fit a two-limit censored normal model Differs from Stata: Uses the explicit left and/or right censoring limits. AER returns a survreg-based Gaussian censored model; scale parameter reporting and coefficient-table inference differ from Stata. Stata reference · R reference |
|
AER
|
Fit a right-censored normal Tobit model Differs from Stata: Uses the explicit left and/or right censoring limits. AER returns a survreg-based Gaussian censored model; scale parameter reporting and coefficient-table inference differ from Stata. Stata reference · R reference |
|
pscl
|
Fit a zero-inflated NB2 count model Differs from Stata: Negative-binomial theta is reciprocal to Stata alpha in the NB2 component. Stata reference · R reference |
|
pscl
|
Fit zero-inflated Poisson with logit zero inflation Differs from Stata: Fits the stated zero-inflated Poisson model with separate count and inflation equations. Match the inflation link, offsets and complete cases; optimizers and coefficient labels differ. Stata reference · R reference |
|
pscl
|
Fit zero-inflated Poisson with probit zero inflation Differs from Stata: Fits the stated zero-inflated Poisson model with separate count and inflation equations. Match the inflation link, offsets and complete cases; optimizers and coefficient labels differ. Stata reference · R reference |
Postestimation and diagnostics
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Calculate the overall Brier mean probability score Differs from Stata: Returns the overall score only; Stata brier also reports decomposition components. Stata reference · R reference |
|
stats
|
Obtain standardized deletion influence on one slope Differs from Stata: Returns standardized coefficient-deletion diagnostics from dfbetas for x; coefficient ordering, missing rows and diagnostic naming must be aligned with the Stata model. Stata reference · R reference |
|
lmtest
|
Test heteroskedasticity against one predictor using a studentized
statistic Differs from Stata: Uses the studentized Koenker version of the Breusch-Pagan test, corresponding to the iid variant shown. Match the auxiliary regressors and estimation sample; the default bptest differs from default Stata hettest. Stata reference · R reference |
|
lmtest
|
Run the classical Breusch-Pagan heteroskedasticity
test Differs from Stata: studentize=FALSE selects the normal-theory version; default bptest uses the Koenker version. Stata reference · R reference |
|
stats
|
Compare penalized-likelihood model criteria R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
lmtest
|
Run a White-style auxiliary-regression heteroskedasticity test This covers the White heteroskedasticity component, not the complete information-matrix decomposition. Stata reference · R reference |
|
lmtest
|
Run Ramsey RESET using powers of fitted values Differs from Stata: Uses RESET powers two through four of the fitted values or regressors as shown. Regressor-factor expansion and rank-deficient auxiliary terms may differ from Stata. Stata reference · R reference |
|
lmtest
|
Run RESET using powers of regressors Differs from Stata: Uses RESET powers two through four of the fitted values or regressors as shown. Regressor-factor expansion and rank-deficient auxiliary terms may differ from Stata. Stata reference · R reference |
|
stats
|
Summarize variables in the actual estimation sample R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
stats
|
Extract the coefficient covariance matrix R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
stats
|
Extract correlations among coefficient estimates R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
car
|
Compute variance inflation factors after OLS Differs from Stata: car returns ordinary VIFs for one-degree-of-freedom terms and generalized VIFs for multi-parameter terms. Stata estat vif reports column-level VIFs, so factor-term output is not directly interchangeable. Stata reference · R reference |
|
stats
|
List stored model names R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
stats
|
Redisplay a fitted linear model summary R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
stats
|
Restore one model from a model collection R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
base
|
Save and reload a fitted model object Writes to an R temporary file; choose an explicit project path for persistent storage. Stata reference · R reference |
|
stats
|
Compare AIC across stored model objects R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
stats
|
Store a fitted model under a name R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
stats
|
Compare coefficients and standard errors across models R keeps fitted model objects; model names are fixed workflow labels. Stata reference · R reference |
|
stats
|
Estimate the sum of two slopes with its standard
error Differs from Stata: The contrast vector assumes coefficient order intercept, x, z. Returns the estimate and its covariance-based standard error only; Stata also prints tests and confidence limits. Stata reference · R reference |
|
stats
|
Estimate a difference of slopes with its standard
error Differs from Stata: The contrast vector assumes coefficient order intercept, x, z. Returns the estimate and its covariance-based standard error only; Stata also prints tests and confidence limits. Stata reference · R reference |
|
stats
|
Regress an outcome on fitted values and their square Shown for OLS; link tests after other model families must refit the appropriate family. Stata reference · R reference |
|
lmtest
|
Compare nested maximum-likelihood models Differs from Stata: Fixed workflow. Stata reference · R reference |
|
stats
|
Predict at specified covariate values Differs from Stata: At each x value, predictions are averaged over the observed distribution of z. Stata reference · R reference |
|
stats
|
Average a continuous-predictor marginal effect Differs from Stata: Uses the fitted GLM and its estimation data; reference grids and averaging rules should be chosen explicitly. Stata reference · R reference |
|
stats
|
Evaluate a marginal effect at mean covariates Differs from Stata: Returns the derivative at means; use a delta-method gradient if standard errors are needed. Stata reference · R reference |
|
stats
|
Average predictions on the linear-index scale Differs from Stata: Uses the fitted GLM and its estimation data; reference grids and averaging rules should be chosen explicitly. Stata reference · R reference |
|
car
|
Use the delta method for a ratio of slopes Differs from Stata: Uses the first-order delta method on named fitted coefficients. Returns the transformed estimate and standard error; Stata also prints reference tests and confidence limits. Stata reference · R reference |
|
car
|
Use the delta method for an exponentiated slope Differs from Stata: Uses the first-order delta method on named fitted coefficients. Returns the transformed estimate and standard error; Stata also prints reference tests and confidence limits. Stata reference · R reference |
|
stats
|
Obtain Cook influence distances Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Compute binary-model deviance residuals Differs from Stata: After fitting a binary-response GLM. Prediction options are model-specific. Stata reference · R reference |
|
stats
|
Obtain DFFITS influence statistics Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Obtain leverage values Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Compute binary-model Pearson residuals Differs from Stata: After fitting a binary-response GLM. Prediction options are model-specific. Stata reference · R reference |
|
stats
|
Predict logistic probabilities Differs from Stata: After fitting a binary-response GLM. Prediction options are model-specific. Stata reference · R reference |
|
stats
|
Obtain raw OLS residuals Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Obtain internally standardized residuals Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Obtain externally studentized residuals Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Obtain forecast standard errors including residual
variance Differs from Stata: Adds residual variance to the squared standard error of the fitted OLS mean. This is a standard error for a new individual prediction, not the fitted mean; assumes homoskedastic errors and matching model sample. Stata reference · R reference |
|
stats
|
Obtain standard errors of fitted means Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Obtain linear fitted values Differs from Stata: Run after fit <- lm(y ~ x + z, data=data). Stata reference · R reference |
|
stats
|
Predict logistic linear indices Differs from Stata: After fitting a binary-response GLM. Prediction options are model-specific. Stata reference · R reference |
|
pROC
|
Compare paired marker ROC areas using DeLong
inference Differs from Stata: Both markers must be measured on the same complete-case subjects for paired inference. Stata reference · R reference |
|
pROC
|
Estimate a nonparametric ROC area for a marker Differs from Stata: Explicit direction means larger markers indicate cases; fixing direction prevents data-driven reversal. Stata reference · R reference |
|
pROC
|
Tabulate sensitivity and specificity across ROC
thresholds Differs from Stata: Returns all pROC thresholds with sensitivity and specificity for explicit event direction. Threshold locations and endpoint conventions differ from Stata roctab detail cutpoints. Stata reference · R reference |
|
car
|
Test a single regression coefficient Differs from Stata: Tests the specified coefficient restriction on the existing fit. car selects its reference statistic from the model class; a GLM chi-square test differs from the OLS F test used by Stata regress postestimation. Stata reference · R reference |
|
car
|
Test equality of two regression slopes Differs from Stata: Tests the specified coefficient restriction on the existing fit. car selects its reference statistic from the model class; a GLM chi-square test differs from the OLS F test used by Stata regress postestimation. Stata reference · R reference |
|
car
|
Jointly test two regression coefficients Differs from Stata: Tests the specified coefficient restriction on the existing fit. car selects its reference statistic from the model class; a GLM chi-square test differs from the OLS F test used by Stata regress postestimation. Stata reference · R reference |
|
car
|
Test an exponentiated coefficient with a nonlinear Wald
test Differs from Stata: Forms a one-degree-of-freedom Wald chi-square from a first-order delta-method standard error. The R vector omits Stata coefficient and confidence-interval output. Stata reference · R reference |
|
car
|
Jointly test a categorical predictor Differs from Stata: The restrictions name the fitted factor coefficients explicitly. Different reference levels or contrasts require different coefficient names; this is not an automatic expansion of any Stata factor-variable expression. Stata reference · R reference |
Hypothesis tests and confidence intervals
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Test a binary success probability exactly Differs from Stata: Returns an exact two-sided binomial test. The code assumes the displayed binary sample has no missing values; Stata additionally prints lower- and upper-tail probabilities. Stata reference · R reference |
|
stats
|
Run an exact binomial test from counts Differs from Stata: Uses an exact two-sided binomial test from the supplied count and total. R reports one htest result; Stata additionally displays both one-sided probabilities. Stata reference · R reference |
|
stats
|
Compute a Student-t confidence interval for a mean Differs from Stata: Returns only the selected confidence limits, not Stata sample-size and point-estimate columns. Match nonmissing sample size, confidence level and the explicit interval method. Stata reference · R reference |
|
stats
|
Compute a Clopper-Pearson proportion interval Differs from Stata: Returns only the selected confidence limits, not Stata sample-size and point-estimate columns. Match nonmissing sample size, confidence level and the explicit interval method. Stata reference · R reference |
|
stats
|
Compute a Wilson score interval for a proportion Differs from Stata: Returns only the selected confidence limits, not Stata sample-size and point-estimate columns. Match nonmissing sample size, confidence level and the explicit interval method. Stata reference · R reference |
|
stats
|
Compute a normal-theory variance interval Differs from Stata: Returns only the selected confidence limits, not Stata sample-size and point-estimate columns. Match nonmissing sample size, confidence level and the explicit interval method. Stata reference · R reference |
|
stats
|
Compute a normal-theory standard-deviation interval Differs from Stata: Returns only the selected confidence limits, not Stata sample-size and point-estimate columns. Match nonmissing sample size, confidence level and the explicit interval method. Stata reference · R reference |
|
stats
|
Compute a mean interval from summary statistics Differs from Stata: Computes confidence limits from the displayed summary inputs. The R result omits Stata sample-size and point-estimate columns; the stated method and confidence level determine the interval. Stata reference · R reference |
|
stats
|
Compute an exact proportion interval from counts Differs from Stata: Computes confidence limits from the displayed summary inputs. The R result omits Stata sample-size and point-estimate columns; the stated method and confidence level determine the interval. Stata reference · R reference |
|
stats
|
Compare two empirical distribution functions Differs from Stata: The two-sample form uses a grouping variable; a one-sample test instead requires a fully specified reference CDF. Stata reference · R reference |
|
stats
|
Test Kendall rank association Differs from Stata: Uses the asymptotic Kendall test. Tie adjustments and the reported tau variant must match; R returns one htest object rather than Stata full concordance summaries. Stata reference · R reference |
|
stats
|
Test equality of distributions across groups Differs from Stata: Computes the tie-corrected Kruskal-Wallis chi-square approximation. R returns an htest object without Stata group rank-sum summaries. Stata reference · R reference |
|
stats
|
Run a two-group median test Differs from Stata: Tests independence of group and the above-pooled-median indicator. The example assigns observations tied at the median to the lower category; align Stata ties() handling before comparison. Stata reference · R reference |
|
stats
|
Test an ordered trend in proportions Differs from Stata: Illustrates aggregated successes and denominators at the three ordered group scores. Stata reference · R reference |
|
stats
|
Compare group means with Bonferroni adjustment Differs from Stata: Uses the ordinary equal-variance one-way model or pooled pairwise t tests as shown. R object layout differs and does not reproduce every Stata tabulate column or comparison display. Stata reference · R reference |
|
stats
|
Fit one-way analysis of variance Differs from Stata: Uses the ordinary equal-variance one-way model or pooled pairwise t tests as shown. R object layout differs and does not reproduce every Stata tabulate column or comparison display. Stata reference · R reference |
|
stats
|
Compute the partial correlation of y and x controlling
z Differs from Stata: This returns the y-x partial correlation; Stata pcorr also reports semipartial correlations for each listed predictor. Stata reference · R reference |
|
stats
|
Run an uncorrected large-sample one-proportion test Differs from Stata: Disables the R continuity correction for the normal-approximation proportion test. R reports a chi-square statistic whose square root is the absolute Stata z; signed direction requires the group order. Stata reference · R reference |
|
stats
|
Compare two proportions without continuity correction Differs from Stata: Disables the R continuity correction for the normal-approximation proportion test. R reports a chi-square statistic whose square root is the absolute Stata z; signed direction requires the group order. Stata reference · R reference |
|
stats
|
Compare proportions from aggregate sample sizes Differs from Stata: Disables continuity correction. R returns a chi-square test; Stata reports a signed z and one-sided probabilities, although the two-sided p-values correspond for the same counts. Stata reference · R reference |
|
stats
|
Compare independent distributions with the rank-sum
test Differs from Stata: Aligns the requested exact or uncorrected asymptotic Wilcoxon calculation. Tie handling, group ordering and reported rank-sum versus U-statistic conventions must be aligned. Stata reference · R reference |
|
stats
|
Use exact rank-sum inference without ties Differs from Stata: Aligns the requested exact or uncorrected asymptotic Wilcoxon calculation. Tie handling, group ordering and reported rank-sum versus U-statistic conventions must be aligned. Stata reference · R reference |
|
stats
|
Test one normal population standard deviation Differs from Stata: Uses a normal-theory variance-ratio or chi-square test. R returns test components in an htest object or vector; Stata also reports one-sided alternatives and additional confidence limits. Stata reference · R reference |
|
stats
|
Compare two unpaired sample variances Differs from Stata: Uses a normal-theory variance-ratio or chi-square test. R returns test components in an htest object or vector; Stata also reports one-sided alternatives and additional confidence limits. Stata reference · R reference |
|
stats
|
Compare variances of two independent normal samples Differs from Stata: Uses a normal-theory variance-ratio or chi-square test. R returns test components in an htest object or vector; Stata also reports one-sided alternatives and additional confidence limits. Stata reference · R reference |
|
stats
|
Compare variances from sample sizes and standard
deviations Differs from Stata: Computes the two-sided normal-theory variance-ratio test from the supplied summaries. The R vector omits Stata confidence intervals and one-sided probability columns. Stata reference · R reference |
|
stats
|
Use a paired signed-rank test with ties Differs from Stata: Uses the paired Wilcoxon asymptotic calculation without continuity correction. R omits zero differences; ties and small-sample variance conventions can affect the reference approximation. Stata reference · R reference |
|
stats
|
Test the median paired difference using signs Differs from Stata: Drops zero paired differences and applies an exact two-sided binomial test. The displayed R interval concerns the probability of a positive difference, not a confidence interval for the paired median. Stata reference · R reference |
|
stats
|
Test Spearman rank association with ties Differs from Stata: Uses the asymptotic Spearman test explicitly. R and Stata p-value approximations can differ, especially with ties; compare the rank correlation on the same complete pairs. Stata reference · R reference |
|
stats
|
Test univariate normality with Shapiro-Wilk Differs from Stata: Computes the Shapiro-Wilk W test; R permits 3 to 5000 nonmissing observations. Stata also displays transformed statistics and uses its own approximation and sample-size rules. Stata reference · R reference |
|
stats
|
Test symmetry in a matched binary table Differs from Stata: For a 2 by 2 table this is the uncorrected McNemar test; larger-table symmetry needs a different procedure. Stata reference · R reference |
|
stats
|
Run a Pearson test from immediate cell counts Differs from Stata: Builds the stated table by rows and disables continuity correction for Pearson chi-square. R returns an htest object rather than Stata contingency-table output. Stata reference · R reference |
|
stats
|
Test association in a two-way count table Differs from Stata: table excludes missing observations and unused factor levels can affect dimensions. The R htest object provides the selected Pearson or Fisher test without Stata row and column percentage displays. Stata reference · R reference |
|
stats
|
Run a Fisher exact test for a two-way table Differs from Stata: table excludes missing observations and unused factor levels can affect dimensions. The R htest object provides the selected Pearson or Fisher test without Stata row and column percentage displays. Stata reference · R reference |
|
stats
|
Test a mean against a specified value Differs from Stata: Selects pooled, Welch or paired inference explicitly. R returns an htest object and may reverse the reported difference when factor-level order differs; match group order and the nonmissing sample. Stata reference · R reference |
|
stats
|
Compute a 90 percent interval for a mean Differs from Stata: Selects pooled, Welch or paired inference explicitly. R returns an htest object and may reverse the reported difference when factor-level order differs; match group order and the nonmissing sample. Stata reference · R reference |
|
stats
|
Test paired mean differences Differs from Stata: Selects pooled, Welch or paired inference explicitly. R returns an htest object and may reverse the reported difference when factor-level order differs; match group order and the nonmissing sample. Stata reference · R reference |
|
stats
|
Compare two independent means with pooled variance Differs from Stata: Selects pooled, Welch or paired inference explicitly. R returns an htest object and may reverse the reported difference when factor-level order differs; match group order and the nonmissing sample. Stata reference · R reference |
|
stats
|
Compare two means using Welch unequal-variance
inference Differs from Stata: Selects pooled, Welch or paired inference explicitly. R returns an htest object and may reverse the reported difference when factor-level order differs; match group order and the nonmissing sample. Stata reference · R reference |
|
stats
|
Run a one-mean t test from summary statistics Differs from Stata: Computes the one-sample t statistic, degrees of freedom and two-sided p-value from the supplied summaries. The R vector omits the confidence interval and one-sided probabilities. Stata reference · R reference |
Multivariate and psychometric methods
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
psych
|
Estimate raw Cronbach alpha without reversing items Differs from Stata: asis disables Stata item-direction reversal; check.keys=FALSE makes the R direction rule explicit. Stata reference · R reference |
|
base
|
Generate a mean score from a reliability scale Differs from Stata: asis disables Stata item-direction reversal; check.keys=FALSE makes the R direction rule explicit. Stata reference · R reference |
|
psych
|
Assess reliability when each item is deleted Differs from Stata: asis disables Stata item-direction reversal; check.keys=FALSE makes the R direction rule explicit. Stata reference · R reference |
|
psych
|
Estimate standardized Cronbach alpha Differs from Stata: asis disables Stata item-direction reversal; check.keys=FALSE makes the R direction rule explicit. Stata reference · R reference |
|
MASS
|
Perform simple correspondence analysis of a contingency
table Differs from Stata: MASS returns standard coordinates; Stata ca defaults to normalize(symmetric), so plotted coordinates differ in scale. Singular values and inertias are comparable, while axes may reverse signs. The table retains category names. Stata reference · R reference |
|
MASS
|
Perform correspondence analysis of a supplied count
matrix Differs from Stata: MASS returns standard correspondence coordinates; Stata defaults to symmetric normalization. Singular values are comparable, but coordinate scaling and axis signs can differ. Stata reference · R reference |
|
MASS
|
Estimate canonical linear discriminant directions Differs from Stata: MASS lda supplies discriminant directions with equal class priors. This is a discriminant-analysis workflow, not the full Stata candisc canonical-test and normalization output. Stata reference · R reference |
|
stats
|
Estimate canonical correlations between two variable
sets Differs from Stata: Returns canonical correlations and coefficient matrices for the two variable blocks. Canonical signs and coefficient normalization are arbitrary; Stata also reports significance tests. Stata reference · R reference |
|
stats
|
Fit averagelinkage hierarchical clustering on standardized
variables Differs from Stata: Standardize variables before the analogous Stata call. Ward distance and squaring conventions require care. Stata reference · R reference |
|
stats
|
Fit centroidlinkage hierarchical clustering on standardized
variables Differs from Stata: Standardize variables before the analogous Stata call. Ward distance and squaring conventions require care. Stata reference · R reference |
|
stats
|
Fit completelinkage hierarchical clustering on standardized
variables Differs from Stata: Standardize variables before the analogous Stata call. Ward distance and squaring conventions require care. Stata reference · R reference |
|
stats
|
Cut a hierarchical cluster tree into three groups Differs from Stata: Cuts the existing hclust tree at three groups. The result is an integer membership vector; cluster labels are arbitrary and Stata generates a named dataset variable. Stata reference · R reference |
|
stats
|
Partition standardized observations into three k-means
clusters Differs from Stata: Algorithms, starts and random streams differ, so cluster numbering and local optima may differ. Stata reference · R reference |
|
stats
|
Fit medianlinkage hierarchical clustering on standardized
variables Differs from Stata: Standardize variables before the analogous Stata call. Ward distance and squaring conventions require care. Stata reference · R reference |
|
stats
|
Fit singlelinkage hierarchical clustering on standardized
variables Differs from Stata: Standardize variables before the analogous Stata call. Ward distance and squaring conventions require care. Stata reference · R reference |
|
stats
|
Fit wardslinkage hierarchical clustering on standardized
variables Differs from Stata: Standardize variables before the analogous Stata call. Ward distance and squaring conventions require care. Stata reference · R reference |
|
stats
|
Fit waveragelinkage hierarchical clustering on standardized
variables Differs from Stata: Standardize variables before the analogous Stata call. Ward distance and squaring conventions require care. Stata reference · R reference |
|
stats
|
Cluster a precomputed dissimilarity matrix Differs from Stata: Uses complete linkage on the supplied dissimilarity matrix. Dissimilarity definitions and tie breaking affect the tree; R returns an hclust object rather than a Stata named cluster solution. Stata reference · R reference |
|
class
|
Classify observations using five nearest neighbors Differs from Stata: Selects predictors by name and classifies the training observations. class::knn uses unweighted majority voting and random tie breaking; Stata defaults to equal class priors, which can change decisions for unbalanced classes. Use held-out data for predictive accuracy. Stata reference · R reference |
|
MASS
|
Fit LDA discriminant analysis Differs from Stata: Prior class probabilities and covariance estimation conventions should be specified before comparing results. Stata reference · R reference |
|
MASS
|
Classify using leave-one-out linear discriminant analysis Stata lootable requests leave-one-out classification; MASS CV=TRUE performs the corresponding prediction workflow. Stata reference · R reference |
|
MASS
|
Use equal prior class probabilities in LDA Differs from Stata: Equal class priors are explicit where shown. MASS coefficient normalization and class order can differ from Stata; compare posterior classifications after aligning priors and covariance estimates. Stata reference · R reference |
|
MASS
|
Fit QDA discriminant analysis Differs from Stata: Explicit equal priors are computed from classes remaining after complete-case filtering of the response and predictors, matching Stata discrim qda default priors(equal). MASS otherwise uses sample class proportions. Align covariance normalization and class labels before comparing posterior probabilities. Stata reference · R reference |
|
lavaan
|
Report confirmatory-factor model fit indices Differs from Stata: Selects six lavaan SEM fit indices. Model identification, likelihood scaling, missing-data estimation and baseline-model definitions must match; this is not every statistic in Stata stats(all). Stata reference · R reference |
|
psych
|
Assess factorability using Kaiser-Meyer-Olkin
measures Differs from Stata: Computes KMO measures from the supplied correlation matrix. R returns overall and per-variable measures in a list; match the same correlation and missing-data sample used for Stata factor. Stata reference · R reference |
|
lavaan
|
Inspect SEM modification indices Differs from Stata: Returns lavaan modification indices for admissible freed parameters. Align model constraints, information matrix and missing-data likelihood; candidate parameter sets can differ from Stata. Stata reference · R reference |
|
lavaan
|
Inspect residual correlations after SEM Differs from Stata: Uses raw observed-minus-implied covariance residuals, matching Stata default raw residuals. lavaan also returns standardized summaries with its own scaling, which are not the same Stata output columns. Stata reference · R reference |
|
stats
|
Compute squared multiple correlations for scale items Differs from Stata: Computes squared multiple correlations as one minus the reciprocal diagonal of the inverse correlation matrix. Requires a nonsingular correlation matrix and returns a vector rather than Stata display tables. Stata reference · R reference |
|
stats
|
Fit a one-factor maximum-likelihood factor model Differs from Stata: Matches the stated ML or principal-component extraction and factor count. Loading signs and rotations are indeterminate; psych principal-component scores and scaling need not reproduce Stata factor postestimation. Stata reference · R reference |
|
psych
|
Fit iterated principal-axis factors Differs from Stata: Principal-axis algorithms and convergence tolerances vary; do not assume identical loadings. Stata reference · R reference |
|
stats
|
Fit a two-factor maximum-likelihood factor model Differs from Stata: Matches the stated ML or principal-component extraction and factor count. Loading signs and rotations are indeterminate; psych principal-component scores and scaling need not reproduce Stata factor postestimation. Stata reference · R reference |
|
psych
|
Fit a principal-component factor solution Differs from Stata: Matches the stated ML or principal-component extraction and factor count. Loading signs and rotations are indeterminate; psych principal-component scores and scaling need not reproduce Stata factor postestimation. Stata reference · R reference |
|
stats
|
Fit maximum-likelihood factors from a correlation
matrix Differs from Stata: Fixed workflow. R is a fixed correlation-matrix object; sample size supplies likelihood-based fit statistics. Stata reference · R reference |
|
stats
|
Test a vector of means against zero with Hotelling T
squared Differs from Stata: Computes the one-sample Hotelling T-squared and its F transformation for these two variables. Assumes a complete sample and invertible covariance; Stata additionally displays mean summaries. Stata reference · R reference |
|
psych
|
Estimate unweighted Cohen kappa for two raters Differs from Stata: Returns unweighted Cohen kappa from the cross-tabulation. It omits Stata agreement summaries, standard errors and confidence intervals; align missing-value and category handling. Stata reference · R reference |
|
stats
|
Test multivariate group differences using Pillai Differs from Stata: Stata displays all four MANOVA statistics; this R example selects the named statistic. Stata reference · R reference |
|
stats
|
Fit multivariate analysis of covariance Differs from Stata: Fits the stated multivariate linear model. R summary defaults to Pillai while Stata displays several multivariate criteria; choose the same criterion, hypothesis and factor contrasts. Stata reference · R reference |
|
stats
|
Test multivariate group differences using Wilks Differs from Stata: Stata displays all four MANOVA statistics; this R example selects the named statistic. Stata reference · R reference |
|
stats
|
Test multivariate group differences using
Hotelling-Lawley Differs from Stata: Stata displays all four MANOVA statistics; this R example selects the named statistic. Stata reference · R reference |
|
stats
|
Test multivariate group differences using Roy Differs from Stata: Stata displays all four MANOVA statistics; this R example selects the named statistic. Stata reference · R reference |
|
MASS
|
Analyze multiple categorical variables through indicator
MCA Differs from Stata: MASS uses an indicator-matrix MCA; inertia normalization differs from adjusted and joint MCA. Stata reference · R reference |
|
stats
|
Fit classical metric multidimensional scaling Differs from Stata: Uses classical metric scaling of Euclidean distances. Stata mds defaults and stress criteria can differ; coordinates are comparable only after aligning distances, method, rotation and reflection. Stata reference · R reference |
|
MASS
|
Fit nonmetric multidimensional scaling Differs from Stata: Nonmetric optimization, stress definitions and starting configurations can differ. Stata reference · R reference |
|
stats
|
Scale an existing dissimilarity matrix Differs from Stata: Applies classical metric scaling to the supplied dissimilarity matrix. Match Stata metric method and eigenvalue treatment; coordinate rotations and reflections are arbitrary. Stata reference · R reference |
|
stats
|
Fit multivariate multiple regression Differs from Stata: Returns a multivariate lm fit on the common complete-case sample. Stata mvreg displays separate equations and cross-equation summaries; request the corresponding R summaries explicitly. Stata reference · R reference |
|
psych
|
Compute Mardia multivariate skewness and kurtosis
tests Differs from Stata: Finite-sample corrections may differ; this selects Mardia components rather than Stata default Doornik-Hansen. Stata reference · R reference |
|
stats
|
Fit correlation-matrix PCA Differs from Stata: Selects correlation or covariance PCA explicitly. Component signs are arbitrary; prcomp returns singular-value-based objects and scores whose scaling differs from Stata displays. Stata reference · R reference |
|
stats
|
Retain two principal components Differs from Stata: Selects correlation or covariance PCA explicitly. Component signs are arbitrary; prcomp returns singular-value-based objects and scores whose scaling differs from Stata displays. Stata reference · R reference |
|
stats
|
Fit covariance-matrix PCA Differs from Stata: Selects correlation or covariance PCA explicitly. Component signs are arbitrary; prcomp returns singular-value-based objects and scores whose scaling differs from Stata displays. Stata reference · R reference |
|
stats
|
Perform PCA directly on a correlation matrix Differs from Stata: Fixed workflow. Stata reference · R reference |
|
MASS
|
Predict posterior probabilities for all discriminant
classes Differs from Stata: Uses the existing discriminant fit and its class order. Returned labels or posterior-probability columns must match the fitted classes; R factor order need not match Stata category codes. Stata reference · R reference |
|
stats
|
Compute the first two principal-component scores Differs from Stata: Returns scores from the existing PCA fit. R score scaling and arbitrary component signs can differ from Stata predict, score; align normalization before comparing values. Stata reference · R reference |
|
MASS
|
Predict discriminant-analysis class membership Differs from Stata: Uses the existing discriminant fit and its class order. Returned labels or posterior-probability columns must match the fitted classes; R factor order need not match Stata category codes. Stata reference · R reference |
|
stats
|
Compute Bartlett-method factor scores Differs from Stata: Fixed measurement model with indicators q1-q6; output score names can be changed. Stata reference · R reference |
|
stats
|
Compute regression-method factor scores Differs from Stata: Fixed measurement model with indicators q1-q6; output score names can be changed. Stata reference · R reference |
|
GPArotation
|
Use the oblique oblimin loading-rotation criterion Differs from Stata: Rotates the supplied loading matrix only. Loading signs, axis order and normalization can differ from Stata; correlated-factor solutions also require comparing the factor-correlation matrix. Stata reference · R reference |
|
GPArotation
|
Use the orthogonal quartimax loading-rotation
criterion Differs from Stata: Rotates the supplied loading matrix only. Loading signs, axis order and normalization can differ from Stata; correlated-factor solutions also require comparing the factor-correlation matrix. Stata reference · R reference |
|
stats
|
Rotate factor loadings using promax Differs from Stata: Loadings are identified only up to sign and ordering; rotation normalization conventions may differ. Stata reference · R reference |
|
stats
|
Rotate factor loadings using varimax Differs from Stata: Loadings are identified only up to sign and ordering; rotation normalization conventions may differ. Stata reference · R reference |
|
stats
|
Rotate an externally supplied loading matrix Differs from Stata: Applies varimax to the supplied matrix. Match normalization and column ordering; equivalent rotated solutions may reverse column signs. Stata reference · R reference |
|
lavaan
|
Fit a three-factor confirmatory measurement model Differs from Stata: Latent-variable scale constraints and mean structures must be aligned when comparing estimates. Stata reference · R reference |
|
lavaan
|
Report standardized SEM parameters Differs from Stata: Fixed workflow. Stata reference · R reference |
|
polycor
|
Estimate a tetrachoric correlation by maximum
likelihood Differs from Stata: Each binary variable must have two observed levels; inference assumes latent bivariate normality. Stata reference · R reference |
Power and precision planning
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Calculate the anticipated full width of a mean
interval Anticipated-width workflow substituting the design SD for the future sample SD; interval width is upper minus lower. Stata also supports probability-of-width planning, which is not implemented here. Stata reference · R reference |
|
stats
|
Plan n for a target mean-interval width Anticipated-width workflow substituting the design SD for the future sample SD; interval width is upper minus lower. Stata also supports probability-of-width planning, which is not implemented here. Stata reference · R reference |
|
stats
|
Calculate a paired mean-difference interval width Anticipated-width workflow substituting the design SD for the future sample SD; interval width is upper minus lower. Stata also supports probability-of-width planning, which is not implemented here. Stata reference · R reference |
|
stats
|
Calculate an equal-variance difference-of-means interval
width Anticipated-width workflow substituting the design SD for the future sample SD; interval width is upper minus lower. Stata also supports probability-of-width planning, which is not implemented here. Stata reference · R reference |
|
pwr
|
Calculate correlation-test power at fixed n Differs from Stata: pwr uses its documented approximation and effect-size parameterization; numerical results need not equal Stata. Stata reference · R reference |
|
pwr
|
Plan sample size for detecting a correlation Differs from Stata: pwr uses its documented approximation and effect-size parameterization; numerical results need not equal Stata. Stata reference · R reference |
|
pwr
|
Find a detectable correlation at fixed n Differs from Stata: pwr uses its documented approximation and effect-size parameterization; numerical results need not equal Stata. Stata reference · R reference |
|
pwr
|
Calculate one-mean z-test power with known SD Differs from Stata: pwr reports the mean difference in SD units; knownsd distinguishes this from a t test. Stata reference · R reference |
|
pwr
|
Plan a one-mean z-test sample size with known SD Differs from Stata: pwr reports the mean difference in SD units; knownsd distinguishes this from a t test. Stata reference · R reference |
|
stats
|
Calculate power for a fixed-size onemean t test Differs from Stata: Computes the displayed normal-theory t-test or two-proportion power design. R two-sample n is per group, whereas Stata n() is total; alternative, allocation and strict two-sided rejection conventions must match. Stata reference · R reference |
|
stats
|
Calculate one-sided one-mean t-test power Differs from Stata: Computes the displayed normal-theory t-test or two-proportion power design. R two-sample n is per group, whereas Stata n() is total; alternative, allocation and strict two-sided rejection conventions must match. Stata reference · R reference |
|
stats
|
Plan the sample size for a onemean t test Differs from Stata: R reports n per group for an independent two-sample test; round sample sizes upward. Stata reference · R reference |
|
pwr
|
Find a detectable one-mean z-test effect Differs from Stata: pwr reports the mean difference in SD units; knownsd distinguishes this from a t test. Stata reference · R reference |
|
stats
|
Find the detectable difference for a onemean t test Differs from Stata: R returns a positive detectable difference; add it to the null mean to recover the alternative mean. Stata reference · R reference |
|
pwr
|
Approximate one-proportion power for a fixed sample Uses the arcsine effect h, an alternative to Stata default score-test calculations. Stata reference · R reference |
|
pwr
|
Approximate a one-proportion design using Cohen h Uses the arcsine effect h, an alternative to Stata default score-test calculations. Stata reference · R reference |
|
pwr
|
Calculate balanced one-way ANOVA power Differs from Stata: pwr uses its documented approximation and effect-size parameterization; numerical results need not equal Stata. Stata reference · R reference |
|
pwr
|
Plan balanced one-way ANOVA group size Differs from Stata: pwr uses its documented approximation and effect-size parameterization; numerical results need not equal Stata. Stata reference · R reference |
|
stats
|
Calculate power for a fixed-size pairedmeans t test Differs from Stata: Computes the displayed normal-theory t-test or two-proportion power design. R two-sample n is per group, whereas Stata n() is total; alternative, allocation and strict two-sided rejection conventions must match. Stata reference · R reference |
|
stats
|
Plan the sample size for a pairedmeans t test Differs from Stata: R reports n per group for an independent two-sample test; round sample sizes upward. Stata reference · R reference |
|
stats
|
Find the detectable difference for a pairedmeans t
test Differs from Stata: R returns a positive detectable difference; add it to the null mean to recover the alternative mean. Stata reference · R reference |
|
pwr
|
Calculate power for an overall three-predictor R squared
test Differs from Stata: f2=(R2_full-R2_reduced)/(1-R2_full); residual df is N minus all predictors minus one. Stata reference · R reference |
|
pwr
|
Plan total n for an overall R squared test Differs from Stata: f2=(R2_full-R2_reduced)/(1-R2_full); residual df is N minus all predictors minus one. Stata reference · R reference |
|
pwr
|
Calculate power for incremental explained variance Differs from Stata: f2=(R2_full-R2_reduced)/(1-R2_full); residual df is N minus all predictors minus one. Stata reference · R reference |
|
stats
|
Calculate power for a fixed-size twomeans t test Differs from Stata: Computes the displayed normal-theory t-test or two-proportion power design. R two-sample n is per group, whereas Stata n() is total; alternative, allocation and strict two-sided rejection conventions must match. Stata reference · R reference |
|
pwr
|
Calculate power with unequal independent group sizes Differs from Stata: Uses the pooled-variance standardized mean-difference model; this is not a Welch heteroskedastic design. Stata reference · R reference |
|
stats
|
Plan the sample size for a twomeans t test Differs from Stata: R reports n per group for an independent two-sample test; round sample sizes upward. Stata reference · R reference |
|
stats
|
Find the detectable difference for a twomeans t test Differs from Stata: R returns a positive detectable difference; add it to the null mean to recover the alternative mean. Stata reference · R reference |
|
stats
|
Calculate power for two fixed-size proportion samples Differs from Stata: Computes the displayed normal-theory t-test or two-proportion power design. R two-sample n is per group, whereas Stata n() is total; alternative, allocation and strict two-sided rejection conventions must match. Stata reference · R reference |
|
stats
|
Calculate one-sided two-proportion power Differs from Stata: Computes the displayed normal-theory t-test or two-proportion power design. R two-sample n is per group, whereas Stata n() is total; alternative, allocation and strict two-sided rejection conventions must match. Stata reference · R reference |
|
stats
|
Plan sample size for two independent proportions Differs from Stata: R reports sample size per group. Normal-approximation conventions and continuity corrections may differ. Stata reference · R reference |
|
stats
|
Find a detectable alternative proportion Differs from Stata: Computes the displayed normal-theory t-test or two-proportion power design. R two-sample n is per group, whereas Stata n() is total; alternative, allocation and strict two-sided rejection conventions must match. Stata reference · R reference |
Resampling and simulation
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Use Bayesian-bootstrap Dirichlet weights for a slope Fixed workflow. Independent exponential weights normalized to sum one are Dirichlet(1,...,1); common scaling does not change weighted least-squares coefficients. Stata reference · R reference |
|
boot
|
Bootstrap regression coefficients within fixed strata Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Bootstrap a difference between regression slopes Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
base
|
Bootstrap a mean by resampling complete clusters Fixed workflow. Resamples cluster identifiers, retaining every observation in each selected cluster. Three clusters are only a demonstration. Stata reference · R reference |
|
boot
|
Bootstrap the sample mean Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Compute a bias-corrected accelerated bootstrap interval Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Bootstrap the sample median Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Bootstrap the lower quartile Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Bootstrap the upper quartile Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Bootstrap the sample standard deviation Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Bootstrap a regression slope by resampling rows Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Bootstrap the sample variance Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
base
|
Draw a nonparametric row-bootstrap sample Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
base
|
Draw a stratified row-bootstrap sample Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
stats
|
Summarize stored bootstrap estimates, bias and standard error Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Compute a normal bootstrap interval Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
boot
|
Compute a percentile bootstrap interval Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
stats
|
Jackknife a regression slope Fixed workflow. The delete-one jackknife is deterministic; its variance uses (n-1)/n times the squared deviations of the replicate estimates. Stata reference · R reference |
|
base
|
Enumerate delete-one-cluster jackknife replicates Fixed workflow. Returns replicate count and retains deleted estimates. Unequal cluster-size variance corrections need an explicitly chosen jackknife design. Stata reference · R reference |
|
base
|
Generate jackknife pseudovalues for the sample mean Fixed workflow. The delete-one jackknife is deterministic; its variance uses (n-1)/n times the squared deviations of the replicate estimates. Stata reference · R reference |
|
stats
|
Jackknife the sample mean Fixed workflow. The delete-one jackknife is deterministic; its variance uses (n-1)/n times the squared deviations of the replicate estimates. Stata reference · R reference |
|
stats
|
Jackknife the sample standard deviation Fixed workflow. The delete-one jackknife is deterministic; its variance uses (n-1)/n times the squared deviations of the replicate estimates. Stata reference · R reference |
|
stats
|
Permute outcomes within fixed strata Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
stats
|
Generate a permutation distribution for a regression slope Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
stats
|
Generate a permutation distribution for a correlation Fixed workflow. Random streams and resampling defaults differ across software; a fixed R seed makes this workflow reproducible. Stata reference · R reference |
|
stats
|
Simulate the sampling distribution of a normal sample mean Fixed workflow. mymean is a user-defined Stata program drawing 40 normal(2,1) observations and returning their mean; this is a fixed workflow. Stata reference · R reference |
Model reporting
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
broom
|
Extract one-row model fit statistics Workflow alternative returning an R table; it does not reproduce Stata table formatting. Stata reference · R reference |
|
broom
|
Create a tidy coefficient table with uncertainty Fixed workflow. Workflow alternative returning an R table; it does not reproduce Stata table formatting. Stata reference · R reference |
|
broom
|
Attach fitted values, residuals and influence diagnostics Fixed workflow. Workflow alternative returning an R table; it does not reproduce Stata table formatting. Stata reference · R reference |
Spatial workflows
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
base
|
Balance a spatial panel by retaining common time
periods Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Requires unique unit/time pairs. Mirrors spbalance's choice to drop incomplete time periods while retaining spatial units; it does not fill missing outcomes. Stata reference · R reference |
|
base
|
Distance between two identified planar locations Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Planar Euclidean distance only; longitude/latitude require a geodesic calculation and explicit units. Stata reference · R reference |
|
base
|
Compute a spatially lagged covariate Differs from Stata: Fixed workflow; adapt the named data columns explicitly. W must use the identical unit ordering as data; this operation does not fit a spatial autoregressive model. Stata reference · R reference |
|
stats
|
Row-standardized inverse-distance spatial weights Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Planar distances, distinct non-coincident locations and matching row/column ID order are required. Stata defaults to spectral normalization, so row normalization is explicit. Stata reference · R reference |
|
sf
|
Declare planar point geometry and coordinate reference
system Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Creating an sf object does not set Stata dataset metadata. Coordinates and CRS must describe the actual data; do not assign a projected CRS to longitude/latitude. Stata reference · R reference |
Causal inference
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
fwildclusterboot
|
Null-imposed wild cluster bootstrap using rademacher
weights Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Small replication count is a runnable example, not an analysis recommendation. Align bootstrap variant, clustering and finite-sample correction. Installed fwildclusterboot emits a one-time seeding-change warning; both R and dqrng generators are explicitly seeded. fwildclusterboot 0.13 changed RNG seeding; seed-for-seed agreement with older versions is not expected. Stata reference · R reference |
|
fwildclusterboot
|
Null-imposed wild cluster bootstrap using webb
weights Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Small replication count is a runnable example, not an analysis recommendation. Align bootstrap variant, clustering and finite-sample correction. Installed fwildclusterboot emits a one-time seeding-change warning; both R and dqrng generators are explicitly seeded. fwildclusterboot 0.13 changed RNG seeding; seed-for-seed agreement with older versions is not expected. Stata reference · R reference |
|
MatchIt
|
Coarsened exact matching on a categorical covariate Fixed workflow; adapt the named data columns explicitly. Matching preprocessing only; categorical levels need no continuous cutpoints. For continuous variables, explicitly match cutpoints and estimand rather than relying on different software defaults. Stata reference · R reference |
|
stats
|
Average imputation treatment effect over treated observations Fixed workflow; adapt the named data columns explicitly. Point-estimation workflow only; untreated-outcome model, weighting and supported treated observations must be chosen explicitly. Stata reference · R reference |
|
stats
|
Untreated-outcome imputation effects by event time Fixed workflow; adapt the named data columns explicitly. Point-estimation illustration with unit/time effects learned only from untreated observations. Never-treated Stata cohort should be missing, whereas this R fixture uses an out-of-range sentinel. Does not reproduce did_imputation's influence-function variance, autosample or pretrend tests. Stata reference · R reference |
|
stats
|
Two-period panel doubly robust DiD ATT point estimate Fixed workflow; adapt the named data columns explicitly. Wide-data point-estimation workflow for the dripw variant: logistic propensity plus control-group outcome-change OLS. Stata expects long data. No influence-function variance or improved drimp estimator. Stata reference · R reference |
|
stats
|
Panel outcome-regression DiD ATT point estimate Fixed workflow; adapt the named data columns explicitly. Two-period wide-data regression-adjustment workflow; requires conditional parallel trends and no anticipation. No standard errors. Stata reference · R reference |
|
stats
|
Stabilized inverse-probability-weighted DiD ATT Fixed workflow; adapt the named data columns explicitly. Two-period wide-data point estimate; no influence-function variance and no repeated-cross-section implementation. Stata reference · R reference |
|
WeightIt
|
Entropy balancing treated/control covariate moments through order
1 Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors. Stata reference · R reference |
|
WeightIt
|
Entropy balancing treated/control covariate moments through order
2 Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors. Stata reference · R reference |
|
AER
|
IV weak-instrument and endogeneity diagnostics Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Wu-Hausman tests depend on model assumptions; exactly identified models have no overidentification test. Stata reference · R reference |
|
stats
|
First-stage instrument relevance regression Fixed workflow; adapt the named data columns explicitly. This is the full first-stage regression; a joint excluded-instrument F test may require a nested comparison. Stata reference · R reference |
|
fixest
|
Aggregate cohort-interacted post-treatment effects Fixed workflow; adapt the named data columns explicitly. ATT aggregation is an R postestimation step; match event-time/cohort weights rather than averaging coefficients unweighted. Stata reference · R reference |
|
fixest
|
Sun-Abraham cohort-interacted event-study estimation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Uses never-treated reference cohorts and -1 event-time reference. Match supported horizons, cohort-share aggregation and covariance conventions to eventstudyinteract. Stata reference · R reference |
|
stats
|
Create first-treatment cohorts including never-treated
units Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Uses zero as a never-treated category for cohort-based DiD. An absorbing treatment history and unique unit/time records are prerequisites; imputation estimators may instead require missing never-treatment times. Stata reference · R reference |
|
fixest
|
Instrumental variables with two absorbed effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output. Stata reference · R reference |
|
fixest
|
Cluster-robust absorbed-effects IV Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output. Stata reference · R reference |
|
fixest
|
Heteroskedasticity-robust absorbed-effects IV Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output. Stata reference · R reference |
|
fixest
|
Instrumental variables with individual fixed effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output. Stata reference · R reference |
|
AER
|
Formula-based instrumental-variable regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Separate structural regressors and instruments with the formula bar. Stata reference · R reference |
|
estimatr
|
Cluster-robust two-stage least squares Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Small-cluster reference degrees of freedom are explicit. Stata reference · R reference |
|
estimatr
|
Two-stage least squares with HC2 covariance Differs from Stata: Fixed workflow; adapt the named data columns explicitly. HC corrections differ; estimatr stata aliases HC1 for unclustered IV inference. Stata reference · R reference |
|
estimatr
|
Two-stage least squares with HC3 covariance Differs from Stata: Fixed workflow; adapt the named data columns explicitly. HC corrections differ; estimatr stata aliases HC1 for unclustered IV inference. Stata reference · R reference |
|
estimatr
|
Two-stage least squares with HC1 covariance Differs from Stata: Stata small requests the N/(N-K) HC1 correction and t-based inference. estimatr se_type="stata" aliases HC1 for unclustered IV. Without small, ivregress vce(robust) uses HC0 and normal reference inference, so it is a different default. Stata reference · R reference |
|
estimatr
|
Two-stage least squares with stata covariance Differs from Stata: Stata small requests the N/(N-K) HC1 correction and t-based inference. estimatr se_type="stata" aliases HC1 for unclustered IV. Without small, ivregress vce(robust) uses HC0 and normal reference inference, so it is a different default. Stata reference · R reference |
|
WeightIt
|
Entropy balancing treated/control covariate moments through order
1 Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors. Stata reference · R reference |
|
WeightIt
|
Entropy balancing treated/control covariate moments through order
2 Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors. Stata reference · R reference |
|
MatchIt
|
Exact matching on categorical covariates Fixed workflow; adapt the named data columns explicitly. Exact-match preprocessing; estimand and stratum normalization are explicit. Stata reference · R reference |
|
WeightIt
|
Inverse-probability weighting for the treated population Fixed workflow; adapt the named data columns explicitly. Weights only; outcome contrasts and propensity-estimation variance require a separate estimator. Stata reference · R reference |
|
MatchIt
|
Multivariate Mahalanobis matching Fixed workflow; adapt the named data columns explicitly. Explicit nearest-neighbor alternative to kmatch's kernel defaults; matching preprocessing only. Stata reference · R reference |
|
MatchIt
|
Propensity-score nearest-neighbor matching Fixed workflow; adapt the named data columns explicitly. Explicit nearest-neighbor alternative to kmatch's kernel defaults; matching preprocessing only. Stata reference · R reference |
|
MatchIt
|
Propensity-score nearest matching with replacement Fixed workflow; adapt the named data columns explicitly. Returns matching preprocessing, not psmatch2's outcome estimate or variance. Replacement, tie-breaking and match order must be explicit. Stata reference · R reference |
|
MatchIt
|
Matched ATT point contrast after propensity-score preprocessing Fixed workflow; adapt the named data columns explicitly. Point contrast only; variance is not estimated, and matching ties/order may differ. Stata reference · R reference |
|
MatchIt
|
Propensity-score matching with an absolute caliper Fixed workflow; adapt the named data columns explicitly. Absolute probability-scale caliper; MatchIt defaults to standardized calipers unless explicitly disabled. Outcome estimation remains separate. Stata reference · R reference |
|
MatchIt
|
Propensity-score nearest matching without replacement Fixed workflow; adapt the named data columns explicitly. Returns matching preprocessing, not psmatch2's outcome estimate or variance. Replacement, tie-breaking and match order must be explicit. Stata reference · R reference |
|
MatchIt
|
Mahalanobis matching with replacement Fixed workflow; adapt the named data columns explicitly. Matching preprocessing; covariance normalization and ties may differ from psmatch2. Stata reference · R reference |
|
cobalt
|
Standardized covariate balance before and after matching Fixed workflow; adapt the named data columns explicitly. Companion command supplied with psmatch2. Choose the same standardization denominator; cobalt's balance table does not reproduce every pstest t-test or omnibus summary. Stata reference · R reference |
|
rddensity
|
Bandwidth selection for density discontinuity Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Bandwidths optimize density-estimation criteria, not treatment-effect estimation. Stata reference · R reference |
|
rdrobust
|
RD bandwidth selection: cerrd Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria. Stata reference · R reference |
|
rdrobust
|
RD bandwidth selection: certwo Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria. Stata reference · R reference |
|
rdrobust
|
RD bandwidth selection: mserd Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria. Stata reference · R reference |
|
rdrobust
|
RD bandwidth selection: msetwo Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria. Stata reference · R reference |
|
rddensity
|
Density continuity at the treatment threshold Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Tests density continuity, not the RD identification assumptions as a whole. Stata reference · R reference |
|
rddensity
|
Density continuity with fixed bandwidths Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Tests density continuity, not the RD identification assumptions as a whole. Stata reference · R reference |
|
rddensity
|
Cubic local-polynomial density discontinuity Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Tests density continuity, not the RD identification assumptions as a whole. Stata reference · R reference |
|
rdrobust
|
Sharp local-linear RD Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
Coverage-error-optimal RD bandwidth Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
Separate MSE-optimal bandwidths by side Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
Cluster-robust RD inference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
Covariate-adjusted RD Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
Fuzzy regression discontinuity Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Requires an exclusion restriction, a treatment-probability discontinuity and a suitable monotonicity assumption. Stata reference · R reference |
|
rdrobust
|
RD with fixed symmetric bandwidth Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
RD with Epanechnikov kernel Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
RD with uniform kernel Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
RD with ninety-percent confidence intervals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
rdrobust
|
Local-quadratic RD Differs from Stata: Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim. Stata reference · R reference |
|
cobalt
|
Covariate balance before and after weighting Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Standardization denominator and binary-variable scaling must be aligned. Stata reference · R reference |
|
stats
|
Augmented inverse-probability ATE point estimate Differs from Stata: Fixed workflow; adapt the named data columns explicitly. No standard errors; double robustness still requires overlap and identifying assumptions. Stata reference · R reference |
|
WeightIt
|
Propensity-score weights targeting ATE Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults. Stata reference · R reference |
|
WeightIt
|
Propensity-score weights targeting ATC Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults. Stata reference · R reference |
|
WeightIt
|
Propensity-score weights targeting ATO Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults. Stata reference · R reference |
|
WeightIt
|
Normalized IPW point effect for ATE Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point estimate only; outcome-free weighting assumes conditional exchangeability and overlap. Weight-estimation uncertainty is not quantified. Stata reference · R reference |
|
WeightIt
|
Propensity-score weights targeting ATT Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults. Stata reference · R reference |
|
WeightIt
|
Normalized IPW point effect for ATT Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point estimate only; outcome-free weighting assumes conditional exchangeability and overlap. Weight-estimation uncertainty is not quantified. Stata reference · R reference |
|
stats
|
Inverse-probability-weighted outcome-regression ATE Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point estimation only; Stata jointly computes the estimating-equation variance. Stata reference · R reference |
|
MatchIt
|
Mahalanobis nearest-neighbor preprocessing Matches with replacement, as teffects does. MatchIt returns preprocessing weights and matches, not the treatment-effect estimate; tie handling, distance conventions, bias correction and Abadie-Imbens standard errors require separate alignment. Stata reference · R reference |
|
MatchIt
|
One-to-one nearest propensity-score matching Matches with replacement, as teffects does. MatchIt returns preprocessing weights and matches, not the treatment-effect estimate; tie handling, distance conventions, bias correction and Abadie-Imbens standard errors require separate alignment. Stata reference · R reference |
|
MatchIt
|
Matching with replacement Fixed workflow; adapt the named data columns explicitly. Preprocessing only; MatchIt does not reproduce teffects matching bias correction or Abadie-Imbens standard errors. Stata reference · R reference |
|
MatchIt
|
One-to-two nearest propensity-score matching Matches with replacement, as teffects does. MatchIt returns preprocessing weights and matches, not the treatment-effect estimate; tie handling, distance conventions, bias correction and Abadie-Imbens standard errors require separate alignment. Stata reference · R reference |
|
stats
|
Regression-adjustment average treatment effect Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point-estimate g-computation under correctly specified potential-outcome models; no causal identification is established by fitting alone. Stata reference · R reference |
|
stats
|
Regression-adjustment effect among treated units Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Averages counterfactual differences over the treated covariate distribution. Stata reference · R reference |
|
stats
|
Propensity-score overlap summary by treatment Fixed workflow; adapt the named data columns explicitly. Numeric overlap diagnostic; no density plot or automatic trimming. Stata reference · R reference |
|
fixest
|
Panel difference-in-differences with unit and period fixed
effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Homogeneous-effect two-group design with parallel trends and no anticipation. Under staggered timing and heterogeneous effects, TWFE is not a replacement for modern cohort-specific estimators; covariance finite-sample conventions can differ. Stata reference · R reference |
Panel data
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
plm
|
Hausman comparison of fixed and random effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Requires same regressors and compatible covariance assumptions. Stata reference · R reference |
|
lme4
|
Random-intercept panel cloglog Differs from Stata: Uses normal panel random intercepts and 12-point adaptive quadrature, matching Stata intpoints(12). Quadrature adaptation and convergence criteria remain package-specific. Stata reference · R reference |
|
plm
|
One-step difference GMM for a dynamic panel Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Supports the standard difference-GMM subset, with deliberately collapsed instruments. Stata xtdpd supports richer error processes; align instruments, initial weight matrices and finite-sample corrections before comparing. Stata reference · R reference |
|
plm
|
System GMM with level and differenced equations Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Additional level moment conditions require stronger initial-condition assumptions. Instrument collapsing, instrument ranges and weighting differ unless explicitly matched; no blanket parity with xtdpdsys defaults. Stata reference · R reference |
|
geepack
|
binomial GEE with ar1 working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
binomial GEE with exchangeable working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
binomial GEE with independence working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
poisson GEE with ar1 working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
poisson GEE with exchangeable working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
poisson GEE with independence working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
gaussian GEE with ar1 working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
gaussian GEE with exchangeable working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
geepack
|
gaussian GEE with independence working correlation Differs from Stata: Keep rows sorted in contiguous panels. geeglm defaults to sandwich robust standard errors (std.err="san.se"), corresponding to xtgee, vce(robust); Stata defaults to conventional model-based standard errors. Scale estimation, small-sample adjustments and correlation estimation may still differ. Stata reference · R reference |
|
nlme
|
Group-heteroskedastic panel GLS by maximum likelihood Fixed workflow; adapt the named data columns explicitly. Common slopes with independent residuals and group-specific residual variances; likelihood, variance normalization and convergence criteria can differ. Stata reference · R reference |
|
plm
|
Hausman-Taylor model with time-varying and invariant endogenous
covariates Differs from Stata: Fixed workflow; adapt the named data columns explicitly. The three-part R formula explicitly separates exogenous covariates and time-varying endogenous covariates. Identification of invariant endogenous effects requires sufficient exogenous time-varying instruments; these classifications need substantive justification. Stata reference · R reference |
|
plm
|
Fixed-effects instrumental-variable regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Instrument validity must be justified substantively; this fixture only verifies execution. Stata reference · R reference |
|
survival
|
Conditional fixed-effects logistic regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Conditions out group intercepts; groups without outcome variation contribute no coefficient information. Stata reference · R reference |
|
plm
|
Beck-Katz panel-corrected covariance Differs from Stata: vcovBK(cluster="time") allows contemporaneous cross-panel covariance, as required for PCSE. Balancedness, pairwise missing-data treatment, finite-sample normalization and reference tests can still differ from xtpcse. Stata reference · R reference |
|
lme4
|
Random-intercept panel Poisson Differs from Stata: Uses normal panel random intercepts and 12-point adaptive quadrature, matching the Stata integration-point default. xtpoisson requires re normal for this distribution; its plain re default is gamma. Quadrature adaptation and convergence criteria remain package-specific. Stata reference · R reference |
|
lme4
|
Random-intercept panel probit Differs from Stata: Uses normal panel random intercepts and 12-point adaptive quadrature, matching Stata intpoints(12). Quadrature adaptation and convergence criteria remain package-specific. Stata reference · R reference |
|
nlme
|
Random-coefficient panel model workflow All three coefficients (intercept, x and z) vary by panel. nlme fits a Gaussian mixed model by ML; xtrc uses Swamy random-coefficient GLS, so the estimators and covariance estimates differ. Stata reference · R reference |
|
plm
|
Individual and time fixed effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. First-difference and pooled rows are explicit benchmarks; match estimator and effects. Stata reference · R reference |
|
plm
|
Between-unit regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. First-difference and pooled rows are explicit benchmarks; match estimator and effects. Stata reference · R reference |
|
plm
|
Individual fixed effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. First-difference and pooled rows are explicit benchmarks; match estimator and effects. Stata reference · R reference |
|
plm
|
Fit a within-panel fixed-effects regression Both commands fit individual fixed effects using the within transformation. plm reports the transformed-model coefficient vector without Stata reported intercept; residual degrees of freedom and covariance scaling must be aligned separately. Stata reference · R reference |
|
plm
|
Cluster-robust panel standard errors Differs from Stata: Stata xtreg, fe vce(robust) equals vce(cluster id). plm HC1 uses N/(N-K) with K counting within-model coefficients and coeftest uses residual degrees of freedom; Stata also applies its cluster correction and uses G-1 reference degrees of freedom. These standard errors and p-values are not exact Stata finite-sample parity. Stata reference · R reference |
|
plm
|
Cluster-robust within-panel standard errors Differs from Stata: Stata xtreg, fe vce(robust) equals vce(cluster id). plm HC1 uses N/(N-K) with K counting within-model coefficients and coeftest uses residual degrees of freedom; Stata also applies its cluster correction and uses G-1 reference degrees of freedom. These standard errors and p-values are not exact Stata finite-sample parity. Stata reference · R reference |
|
plm
|
Pooled panel regression benchmark Under independent working correlation, population-averaged Gaussian GEE and pooled OLS have the same coefficients. xtreg, pa defaults to conventional model-based GEE covariance (not robust unless requested); pooled plm uses OLS residual scaling, so reported standard errors can differ. Stata reference · R reference |
|
plm
|
Random-effects panel regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. First-difference and pooled rows are explicit benchmarks; match estimator and effects. Stata reference · R reference |
|
plm
|
Random effects with swar variance components Fixed workflow; adapt the named data columns explicitly. These are named alternative variance-component estimators; only matching methods justify comparing estimates. Stata reference · R reference |
|
plm
|
Random effects with walhus variance components Walhus is an R alternative variance-component estimator with no corresponding xtreg option. Stata xtreg, re uses its default estimator or sa for Swamy-Arora; the Stata line does not select Walhus and numerical parity is not claimed. Stata reference · R reference |
|
plm
|
Random effects with amemiya variance components Amemiya is an R alternative variance-component estimator with no corresponding xtreg option. Stata xtreg, re uses its default estimator or sa for Swamy-Arora; the Stata line does not select Amemiya and numerical parity is not claimed. Stata reference · R reference |
|
plm
|
Random effects with nerlove variance components Nerlove is an R alternative variance-component estimator with no corresponding xtreg option. Stata xtreg, re uses its default estimator or sa for Swamy-Arora; the Stata line does not select Nerlove and numerical parity is not claimed. Stata reference · R reference |
|
nlme
|
Random intercept with AR(1) residual correlation Fixed workflow; adapt the named data columns explicitly. Likelihood-based mixed-model workflow differs from xtregar's estimator. Stata reference · R reference |
|
plm
|
Driscoll-Kraay covariance Differs from Stata: Requires the community command xtscc (ssc install xtscc); xtreg has no vce(dkraay) option. Both use a within estimator with lag-2 Driscoll-Kraay covariance; finite-sample scaling and reference degrees of freedom differ. Stata reference · R reference |
|
plm
|
Breusch-Pagan test of individual random effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's boundary-adjusted mixture distribution can differ from plm's chi-square reference. Stata reference · R reference |
|
plm
|
Panel unit-root test: madwu Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Hadri reverses the null to stationarity; deterministic terms and lag rules must match. Stata reference · R reference |
|
plm
|
Panel unit-root test: hadri Differs from Stata: The null is panel stationarity. Hcons=TRUE selects the heteroskedasticity-robust Hadri statistic, corresponding to Stata robust; plm ignores lag selections for Hadri and provides no Bartlett HAC kernel correction. Stata reference · R reference |
|
plm
|
Panel unit-root test: ips Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Hadri reverses the null to stationarity; deterministic terms and lag rules must match. Stata reference · R reference |
|
plm
|
Panel unit-root test: levinlin Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Hadri reverses the null to stationarity; deterministic terms and lag rules must match. Stata reference · R reference |
Time series and forecasting
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
stats
|
Autocorrelation function Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R returns numeric correlations; request plotting separately. Stata reference · R reference |
|
tseries
|
GARCH(1,1) conditional-variance model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Fit a mean model separately; optimization and initialization differ. Stata reference · R reference |
|
tseries
|
ARCH(1) conditional-variance model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. tseries::garch models zero-mean observations; remove or explicitly model the conditional mean first. Stata reference · R reference |
|
fracdiff
|
Fractionally integrated ARMA estimation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. fracdiff uses approximate likelihood and a different MA sign convention. Stata reference · R reference |
|
fracdiff
|
Fractional-ARMA order comparison Fixed workflow; adapt the named data columns explicitly. Approximate-likelihood order-selection workflow; no numerical parity claim. Stata reference · R reference |
|
stats
|
ARMAX with external regressor Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
Seasonally differenced moving average Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
Seasonal autoregression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
MA(1) with intercept Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
Integrated moving-average model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
AR(1) with intercept Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
State-space maximum-likelihood estimation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
Zero-mean autoregression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
ARMA(1,1) Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
ARMA estimation using ML Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Explicit likelihood setting avoids relying on R's default CSS-ML initialization. Stata reference · R reference |
|
stats
|
ARMA estimation using CSS Fixed workflow; adapt the named data columns explicitly. Conditional sum of squares is a workflow alternative, not Stata's default likelihood. Stata reference · R reference |
|
stats
|
ARIMA with first difference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Parameterization, initialization and likelihood conventions differ; compare selected model, not default output. Stata reference · R reference |
|
stats
|
ARMA information-criterion grid Fixed workflow; adapt the named data columns explicitly. Comparable-sample model-selection workflow; R and Stata likelihood constants may differ. Stata reference · R reference |
|
stats
|
Autocorrelation and partial-autocorrelation table Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R returns numeric correlations; request plotting separately. Stata reference · R reference |
|
stats
|
Cumulative spectral distribution Fixed workflow; adapt the named data columns explicitly. Computes curve data; confidence bands are not included. Stata reference · R reference |
|
urca
|
DF-GLS unit-root test with trend Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Lag-selection and finite-sample critical values may differ. Stata reference · R reference |
|
urca
|
DF-GLS unit-root test with constant Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Lag-selection and finite-sample critical values may differ. Stata reference · R reference |
|
urca
|
ADF unit-root test with drift and 0 augmentation lags Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match deterministic terms, sample window and lag selection; critical-value implementations can differ. Stata reference · R reference |
|
urca
|
ADF unit-root test with none and 0 augmentation lags Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match deterministic terms, sample window and lag selection; critical-value implementations can differ. Stata reference · R reference |
|
urca
|
ADF unit-root test with trend and 0 augmentation lags Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match deterministic terms, sample window and lag selection; critical-value implementations can differ. Stata reference · R reference |
|
urca
|
ADF unit-root test with drift and 2 augmentation lags Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match deterministic terms, sample window and lag selection; critical-value implementations can differ. Stata reference · R reference |
|
urca
|
ADF unit-root test with none and 2 augmentation lags Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match deterministic terms, sample window and lag selection; critical-value implementations can differ. Stata reference · R reference |
|
urca
|
ADF unit-root test with trend and 2 augmentation lags Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match deterministic terms, sample window and lag selection; critical-value implementations can differ. Stata reference · R reference |
|
stats
|
Iterated bivariate VAR point forecasts Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point forecasts only; no system forecast-error covariance or interval calculation. Stata reference · R reference |
|
forecast
|
Eight-period ARIMA forecast Fixed workflow; adapt the named data columns explicitly. Single-equation forecasting workflow; forecast system identities are not translated. Stata reference · R reference |
|
forecast
|
Forecast with ninety-percent prediction intervals Fixed workflow; adapt the named data columns explicitly. Single-equation forecasting workflow; forecast system identities are not translated. R produces analytic 90% prediction intervals; the Stata example instead simulates forecast standard deviations, requiring a separate interval calculation. Stata reference · R reference |
|
forecast
|
One-step fitted values from ARIMA Fixed workflow; adapt the named data columns explicitly. In-sample one-step prediction workflow; Stata's forecast model setup is separate. Stata reference · R reference |
|
base
|
Reduced-form VAR(1) impulse-response matrices Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Unit reduced-form innovation responses; orthogonalized structural responses require an identification scheme. Stata reference · R reference |
|
base
|
Cholesky-orthogonalized VAR responses Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Recursive ordering is y then x; covariance divisor and identifying assumptions matter. Stata reference · R reference |
|
AER
|
Instrumental-variable local-projection point responses Fixed workflow; adapt the named data columns explicitly. Horizonwise 2SLS workflow; instrument validity, normalization and HAC inference require separate decisions. Stata reference · R reference |
|
stats
|
Local-projection dynamic response to an external impulse Fixed workflow; adapt the named data columns explicitly. Simple horizonwise point-estimation workflow; HAC inference and system restrictions must be added for research use. Stata reference · R reference |
|
sandwich
|
Newey-West HAC coefficient inference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Explicit bandwidth, prewhitening and finite-sample correction; align those choices. Stata reference · R reference |
|
stats
|
Partial autocorrelation function Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R returns numeric correlations; request plotting separately. Stata reference · R reference |
|
stats
|
Raw periodogram Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Normalization and default tapering can differ. Stata reference · R reference |
|
urca
|
Phillips-Perron Z-tau test with constant Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata reports several statistics together; R selects one statistic. Kernel and deterministic terms must be matched. Stata reference · R reference |
|
urca
|
Phillips-Perron Z-alpha test with constant Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata reports several statistics together; R selects one statistic. Kernel and deterministic terms must be matched. Stata reference · R reference |
|
urca
|
Phillips-Perron Z-tau test with trend Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata reports several statistics together; R selects one statistic. Kernel and deterministic terms must be matched. Stata reference · R reference |
|
urca
|
Phillips-Perron Z-alpha test with trend Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata reports several statistics together; R selects one statistic. Kernel and deterministic terms must be matched. Stata reference · R reference |
|
stats
|
Dynamic ARIMA forecast and standard errors Fixed workflow; adapt the named data columns explicitly. Single-equation forecasting workflow; forecast system identities are not translated. Stata reference · R reference |
|
stats
|
Parametric AR(1) spectral density Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Frequency and density normalization conventions must be reconciled. Stata reference · R reference |
|
stats
|
Expanding-window recursive regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Uses a fixed first observation and increasing estimation endpoint. Stata reference · R reference |
|
zoo
|
Rolling-window regression coefficients Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Output rows correspond to complete right-aligned windows; failures need explicit handling in production. Stata reference · R reference |
|
zoo
|
Rolling sample volatility Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Sample standard deviation, not model-implied conditional volatility. Stata reference · R reference |
|
stats
|
Local-linear-trend state-space model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Specific local-linear-trend model; initialization can differ. Stata reference · R reference |
|
stats
|
Local-level state-space model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Specific local-level model equivalent; sspace supports a much wider model class. Stata reference · R reference |
|
stats
|
Baxter-King approximate band-pass cycle Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Symmetric finite-order band-pass filter loses endpoint observations. Stata reference · R reference |
|
base
|
Hodrick-Prescott trend and cycle decomposition Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Complete regular series; this direct penalized least-squares solution uses the two-sided HP filter. Stata reference · R reference |
|
base
|
Locate missing time periods Fixed workflow; adapt the named data columns explicitly. Assumes integer unit-spaced time; date calendars need the intended interval definition. Stata reference · R reference |
|
stats
|
Simple exponential smoothing Fixed workflow; adapt the named data columns explicitly. Initial values, endpoints and trend formulations differ; align before comparing. Stata reference · R reference |
|
stats
|
Holt trend smoothing workflow Fixed workflow; adapt the named data columns explicitly. Initial values, endpoints and trend formulations differ; align before comparing. Stata reference · R reference |
|
stats
|
Centered five-term moving average Fixed workflow; adapt the named data columns explicitly. Initial values, endpoints and trend formulations differ; align before comparing. Stata reference · R reference |
|
stats
|
Trailing four-term moving average Fixed workflow; adapt the named data columns explicitly. Initial values, endpoints and trend formulations differ; align before comparing. Stata reference · R reference |
|
stats
|
Running-median nonlinear smoother Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Endpoint rules should be checked separately before comparing. Stata reference · R reference |
|
stats
|
Additive seasonal Holt-Winters smoothing Fixed workflow; adapt the named data columns explicitly. Initial values, endpoints and trend formulations differ; align before comparing. Stata reference · R reference |
|
stats
|
Unobserved components: level Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R supports selected structural models; Stata ucm permits additional components and constraints. Stata reference · R reference |
|
stats
|
Unobserved components: trend Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R supports selected structural models; Stata ucm permits additional components and constraints. Stata reference · R reference |
|
stats
|
Unobserved components: BSM Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R supports selected structural models; Stata ucm permits additional components and constraints. Stata reference · R reference |
|
stats
|
Unrestricted bivariate VAR(1) by equation OLS Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Coefficient equivalent for an unrestricted common-sample VAR; system covariance reporting differs. Stata reference · R reference |
|
stats
|
VAR with deterministic time trend Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Trend origin affects intercepts; compare the same sample and trend indexing. Stata reference · R reference |
|
stats
|
Zero-intercept bivariate VAR Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Specify identical lag matrices and deterministic terms. Stata reference · R reference |
|
lmtest
|
Test whether x Granger-predicts y Differs from Stata: Fit var y x, lags(1) before vargranger; Stata VAR otherwise defaults to lags(1 2). grangertest uses an F reference distribution, whereas vargranger reports a Wald chi-square; match direction and sample, and do not interpret predictability as structural causation. Stata reference · R reference |
|
lmtest
|
Test whether y Granger-predicts x Differs from Stata: Fit var y x, lags(1) before vargranger; Stata VAR otherwise defaults to lags(1 2). grangertest uses an F reference distribution, whereas vargranger reports a Wald chi-square; match direction and sample, and do not interpret predictability as structural causation. Stata reference · R reference |
|
base
|
Eigenvalues of the VAR(1) companion matrix Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stability requires all companion roots strictly inside the unit circle. Stata reference · R reference |
|
urca
|
Rank-one vector error-correction model Differs from Stata: urca ecdet="const" matches Stata trend(rconstant); ecdet="none" includes an unrestricted intercept and matches trend(constant); ecdet="trend" matches trend(rtrend). ca.jo does not provide Stata trend(none) or trend(trend). Match cointegrating-vector normalization before comparing coefficients. Stata reference · R reference |
|
urca
|
Test cointegration rank with an unrestricted
intercept Differs from Stata: urca ecdet="const" matches Stata trend(rconstant); ecdet="none" includes an unrestricted intercept and matches trend(constant); ecdet="trend" matches trend(rtrend). ca.jo does not provide Stata trend(none) or trend(trend). Match cointegrating-vector normalization before comparing coefficients. Stata reference · R reference |
|
urca
|
Test cointegration rank with an unrestricted
intercept Differs from Stata: urca ecdet="const" matches Stata trend(rconstant); ecdet="none" includes an unrestricted intercept and matches trend(constant); ecdet="trend" matches trend(rtrend). ca.jo does not provide Stata trend(none) or trend(trend). Match cointegrating-vector normalization before comparing coefficients. Stata reference · R reference |
|
urca
|
Johansen trace rank test with a restricted constant Differs from Stata: urca ecdet="const" matches Stata trend(rconstant); ecdet="none" includes an unrestricted intercept and matches trend(constant); ecdet="trend" matches trend(rtrend). ca.jo does not provide Stata trend(none) or trend(trend). Match cointegrating-vector normalization before comparing coefficients. Stata reference · R reference |
|
urca
|
Johansen maximum-eigenvalue rank test with a restricted
constant Differs from Stata: urca ecdet="const" matches Stata trend(rconstant); ecdet="none" includes an unrestricted intercept and matches trend(constant); ecdet="trend" matches trend(rtrend). ca.jo does not provide Stata trend(none) or trend(trend). Match cointegrating-vector normalization before comparing coefficients. Stata reference · R reference |
|
urca
|
Johansen trace rank test with a restricted trend Differs from Stata: urca ecdet="const" matches Stata trend(rconstant); ecdet="none" includes an unrestricted intercept and matches trend(constant); ecdet="trend" matches trend(rtrend). ca.jo does not provide Stata trend(none) or trend(trend). Match cointegrating-vector normalization before comparing coefficients. Stata reference · R reference |
|
urca
|
Johansen maximum-eigenvalue rank test with a restricted
trend Differs from Stata: urca ecdet="const" matches Stata trend(rconstant); ecdet="none" includes an unrestricted intercept and matches trend(constant); ecdet="trend" matches trend(rtrend). ca.jo does not provide Stata trend(none) or trend(trend). Match cointegrating-vector normalization before comparing coefficients. Stata reference · R reference |
|
stats
|
Ljung-Box test after AR(1) estimation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R explicitly deducts the estimated AR parameter from the reference degrees of freedom. Stata reference · R reference |
|
stats
|
Ljung-Box serial-correlation portmanteau test Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Use fitdf for tests on estimated-model residuals. Stata reference · R reference |
|
stats
|
Cross-correlation at positive and negative lags Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Check lag sign conventions before interpreting lead-lag direction. Stata reference · R reference |
Complex survey analysis
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
survey
|
Coefficient of variation of a survey mean Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Relative standard error is unstable when the estimated mean is near zero. Stata reference · R reference |
|
survey
|
Design effect of a survey mean Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design effects depend on the SRS comparison, finite-population correction and weight scaling. Stata reference · R reference |
|
survey
|
Survey mean with bootstrap replicate variance Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point means agree with sampling weights; replication variance depends on the chosen scheme. Stata reference · R reference |
|
survey
|
Survey mean with BRR replicate variance Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point means agree with sampling weights; replication variance depends on the chosen scheme. Stata reference · R reference |
|
survey
|
Survey mean with JKn replicate variance Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point means agree with sampling weights; replication variance depends on the chosen scheme. Stata reference · R reference |
|
survey
|
Survey subpopulation mean Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Subset the design, preserving the sampling structure, rather than rebuilding a design after filtering. Stata reference · R reference |
|
survey
|
Survey gamma log-link model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Quasi families retain the mean/variance structure without non-integer count warnings; align design degrees of freedom. Stata reference · R reference |
|
survey
|
Survey logistic regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Quasi families retain the mean/variance structure without non-integer count warnings; align design degrees of freedom. Stata reference · R reference |
|
survey
|
Survey-weighted mean Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Joint means and covariance matrix Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Domain-specific means Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Survey Poisson mean model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Quasi families retain the mean/variance structure without non-integer count warnings; align design degrees of freedom. Stata reference · R reference |
|
survey
|
Survey probit regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Quasi families retain the mean/variance structure without non-integer count warnings; align design degrees of freedom. Stata reference · R reference |
|
survey
|
Survey-weighted category proportions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Survey proportion interval using logit Fixed workflow; adapt the named data columns explicitly. Different interval constructions are intentional alternatives; match Stata's selected transformation. Stata reference · R reference |
|
survey
|
Survey proportion interval using likelihood Fixed workflow; adapt the named data columns explicitly. Different interval constructions are intentional alternatives; match Stata's selected transformation. Stata reference · R reference |
|
survey
|
Survey proportion interval using asin Fixed workflow; adapt the named data columns explicitly. Different interval constructions are intentional alternatives; match Stata's selected transformation. Stata reference · R reference |
|
survey
|
Survey proportion interval using beta Fixed workflow; adapt the named data columns explicitly. Different interval constructions are intentional alternatives; match Stata's selected transformation. Stata reference · R reference |
|
survey
|
Survey proportion interval using mean Fixed workflow; adapt the named data columns explicitly. Different interval constructions are intentional alternatives; match Stata's selected transformation. Stata reference · R reference |
|
survey
|
Survey proportion interval using xlogit Fixed workflow; adapt the named data columns explicitly. Different interval constructions are intentional alternatives; match Stata's selected transformation. Stata reference · R reference |
|
survey
|
Domain-specific proportions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Survey ratio of totals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Survey linear regression Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Quasi families retain the mean/variance structure without non-integer count warnings; align design degrees of freedom. Stata reference · R reference |
|
survey
|
Weighted contingency-table counts Differs from Stata: Returns weighted cell proportions, the default display of svy: tabulate twoway. This table alone does not provide Stata design-based standard errors, confidence intervals or adjusted association tests. Stata reference · R reference |
|
survey
|
Survey column proportions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Design-based categorical association: F Fixed workflow; adapt the named data columns explicitly. Rao-Scott and Wald choices have distinct reference distributions; choose the intended test explicitly. Stata reference · R reference |
|
survey
|
Design-based categorical association: Chisq Fixed workflow; adapt the named data columns explicitly. Rao-Scott and Wald choices have distinct reference distributions; choose the intended test explicitly. Stata reference · R reference |
|
survey
|
Design-based categorical association: Wald Fixed workflow; adapt the named data columns explicitly. Rao-Scott and Wald choices have distinct reference distributions; choose the intended test explicitly. Stata reference · R reference |
|
survey
|
Design-based categorical association: adjWald Fixed workflow; adapt the named data columns explicitly. Rao-Scott and Wald choices have distinct reference distributions; choose the intended test explicitly. Stata reference · R reference |
|
survey
|
Survey row proportions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Survey-weighted population total Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Joint population totals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Domain-specific population totals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Design-based variance uses the full sampling design; population totals require correctly scaled weights. Stata reference · R reference |
|
survey
|
Survey design degrees of freedom and cluster counts Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Counts observed records by stratum; PSU count is distinct from observation count. Stata reference · R reference |
|
survey
|
Independent unequal-probability sample Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Survey objects carry design metadata; do not substitute ordinary regression weights. Stata reference · R reference |
|
survey
|
Stratified cluster survey design Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Survey objects carry design metadata; do not substitute ordinary regression weights. Stata reference · R reference |
|
survey
|
Finite-population correction in a clustered design Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Survey objects carry design metadata; do not substitute ordinary regression weights. Stata reference · R reference |
|
survey
|
Poststratify survey weights to population category
totals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Population categories must cover the sample; weighting adjustments are part of the variance design. Stata reference · R reference |
|
survey
|
Rake sample weights to known category margins Fixed workflow; adapt the named data columns explicitly. Survey calibration workflow; Stata's exact calibration syntax depends on svyset options/version. Stata reference · R reference |
|
survey
|
Survey bootstrap replicate-weight design Fixed workflow; adapt the named data columns explicitly. Illustrative replication count; specific survey bootstrap schemes and scales can differ. Stata reference · R reference |
|
survey
|
Balanced repeated replication for paired-PSU strata Differs from Stata: Fixed workflow; adapt the named data columns explicitly. BRR requires exactly two PSUs per stratum unless a deliberate design adjustment is made. Stata reference · R reference |
|
survey
|
Fay balanced repeated replication Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Match Fay's perturbation parameter and replicate scaling conventions. Stata reference · R reference |
|
survey
|
Stratified delete-one jackknife replicates Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Survey objects carry design metadata; do not substitute ordinary regression weights. Stata reference · R reference |
Meta-analysis
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
metafor
|
Rank-correlation small-study-effects test Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Rank-correlation and small-sample p-value conventions may differ. Stata reference · R reference |
|
metafor
|
Egger regression asymmetry test Differs from Stata: Assumes the Stata meta declaration is its default random(reml). model="rma" regresses the effects on their standard errors with additive REML heterogeneity; model="lm" would instead use multiplicative dispersion. Small-study effects alone do not establish publication bias. Stata reference · R reference |
|
metafor
|
Log odds ratios and variances Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Use treatment/control cell ordering consistently and select continuity corrections deliberately. Stata reference · R reference |
|
metafor
|
Log risk ratios and variances Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Use treatment/control cell ordering consistently and select continuity corrections deliberately. Stata reference · R reference |
|
metafor
|
Risk differences and variances Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Use treatment/control cell ordering consistently and select continuity corrections deliberately. Stata reference · R reference |
|
metafor
|
Freeman-Tukey transformed proportions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Transformation definitions and back-transformation choices, especially double-arcsine, require care. Stata reference · R reference |
|
metafor
|
Logit-transformed study proportions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Transformation definitions and back-transformation choices, especially double-arcsine, require care. Stata reference · R reference |
|
metafor
|
Raw study proportions and variances Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Transformation definitions and back-transformation choices, especially double-arcsine, require care. Stata reference · R reference |
|
metafor
|
Uncorrected Cohen standardized mean differences Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Sampling-variance estimators for standardized effects must be matched. Stata reference · R reference |
|
metafor
|
Bias-corrected standardized mean differences Differs from Stata: metafor SMD uses the exact gamma-function Hedges correction. Stata hedgesg uses its approximation by default; specify esize(hedgesg, exact) to align that correction, and also match the sampling-variance formula. Stata reference · R reference |
|
metafor
|
Unstandardized mean differences Differs from Stata: vtype="HO" uses the pooled within-group variance, matching Stata esize(mdiff) default equal-variance sampling variance. metafor default vtype="LS" instead uses separate group variances; use it with Stata unequal. Stata reference · R reference |
|
metafor
|
Raw correlations and sampling variances Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Correlations must be within (-1,1); sampling variance depends on transformation. Stata reference · R reference |
|
metafor
|
Fisher-z transformed correlations Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Correlations must be within (-1,1); sampling variance depends on transformation. Stata reference · R reference |
|
metafor
|
Meta-regression on centered publication year Differs from Stata: Uses year on its original scale, so the intercept refers to year zero as in the Stata command. Assumes the Stata declared model is random(REML); match its model declaration and standard-error options. Stata reference · R reference |
|
metafor
|
Categorical meta-regression with Knapp-Hartung
inference Differs from Stata: Uses ordinary normal-reference REML meta-regression, as shown by the Stata command without se(khartung). Knapp-Hartung would require an explicit option in both systems. Moderator associations are study-level, not causal subgroup effects. Stata reference · R reference |
|
metafor
|
Random-effects meta-regression with moderator Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Meta-regression relates study-level summaries, not individual-level effects. Stata reference · R reference |
|
metafor
|
Declare generic effect sizes and sampling variances Differs from Stata: Both examples take standard errors as sei; metafor stores their squares as vi. escalc creates effect-size data but does not persist a Stata-style meta declaration, labels or a default analysis model. Stata reference · R reference |
|
metafor
|
Cumulative fixed-effect meta-analysis by year Differs from Stata: Assumes meta set used its default random(reml) declaration; metafor explicitly selects REML. A prior Stata common/fixed/random declaration changes the target. Match study order, missingness and heterogeneity estimation before comparing summaries. Stata reference · R reference |
|
metafor
|
Exponentiate a pooled log-effect and interval Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Only appropriate when effects are on a log-ratio scale. Stata reference · R reference |
|
metafor
|
Inverse-variance meta-analysis using FE Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Between-study variance estimators and confidence procedures must be matched; some R estimator names differ from Stata's names. Stata reference · R reference |
|
metafor
|
Leave-one-study-out pooled estimates Differs from Stata: Assumes meta set used its default random(reml) declaration; metafor explicitly selects REML. A prior Stata common/fixed/random declaration changes the target. Match study order, missingness and heterogeneity estimation before comparing summaries. Stata reference · R reference |
|
metafor
|
Inverse-variance meta-analysis using DL Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Between-study variance estimators and confidence procedures must be matched; some R estimator names differ from Stata's names. Stata reference · R reference |
|
metafor
|
Inverse-variance meta-analysis using EB Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Between-study variance estimators and confidence procedures must be matched; some R estimator names differ from Stata's names. Stata reference · R reference |
|
metafor
|
Inverse-variance meta-analysis using HE Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Between-study variance estimators and confidence procedures must be matched; some R estimator names differ from Stata's names. Stata reference · R reference |
|
metafor
|
Inverse-variance meta-analysis using ML Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Between-study variance estimators and confidence procedures must be matched; some R estimator names differ from Stata's names. Stata reference · R reference |
|
metafor
|
Inverse-variance meta-analysis using REML Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Between-study variance estimators and confidence procedures must be matched; some R estimator names differ from Stata's names. Stata reference · R reference |
|
metafor
|
Random-effects pooled inference using z Fixed workflow; adapt the named data columns explicitly. Only knha corresponds to a Knapp-Hartung correction; z/t are explicit inference alternatives. Stata reference · R reference |
|
metafor
|
Prediction interval for a new study's true effect Differs from Stata: The true-effect prediction interval differs from the pooled-mean confidence interval. Stata uses t(K-2); metafor defaults to a normal quantile. For Stata endpoints compute mu +/- qt(.975,K-2)*sqrt(tau2+se^2); changing metafor test="t" uses K-p degrees of freedom and is not the same correction. Stata reference · R reference |
|
metafor
|
Random-effects pooled inference using knha Fixed workflow; adapt the named data columns explicitly. Only knha corresponds to a Knapp-Hartung correction; z/t are explicit inference alternatives. Stata reference · R reference |
|
metafor
|
Random-effects pooled inference using t Fixed workflow; adapt the named data columns explicitly. Only knha corresponds to a Knapp-Hartung correction; z/t are explicit inference alternatives. Stata reference · R reference |
|
metafor
|
Inverse-variance meta-analysis using SJ Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Between-study variance estimators and confidence procedures must be matched; some R estimator names differ from Stata's names. Stata reference · R reference |
|
metafor
|
Separate random-effects estimates by study subgroup Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Fits separate heterogeneity parameters; not the same as a shared-tau subgroup model. Stata reference · R reference |
|
metafor
|
Trim-and-fill sensitivity analysis Differs from Stata: Assumes meta set used its default random(reml) declaration; metafor explicitly selects REML. A prior Stata common/fixed/random declaration changes the target. Match study order, missingness and heterogeneity estimation before comparing summaries. Stata reference · R reference |
Multiple imputation
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
mice
|
Stack imputations including original data Fixed workflow; adapt the named data columns explicitly. R mids metadata and storage structures differ from Stata MI data styles. Stata reference · R reference |
|
mice
|
Describe multiple-imputation metadata Fixed workflow; adapt the named data columns explicitly. R mids metadata and storage structures differ from Stata MI data styles. Stata reference · R reference |
|
mice
|
Pooled estimates with ninety-percent intervals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Uses mice's pooled small-sample degrees-of-freedom rules. Stata reference · R reference |
|
mice
|
Pool logistic-regression coefficients Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Pool on the log-odds scale before exponentiating. Stata reference · R reference |
|
mice
|
Rubin pooling of an imputed continuous mean Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Within-imputation mean variances and complete-data sample sizes are explicit. Stata reference · R reference |
|
mice
|
Pool Poisson-regression coefficients Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Pool log-rate coefficients; assess overdispersion separately. Stata reference · R reference |
|
mice
|
Rubin pooling of linear-regression coefficients Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Pools within- and between-imputation variance; complete-data degrees of freedom must be appropriate. Stata reference · R reference |
|
mitools
|
Pool coefficient vectors and covariance matrices
directly Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Alternative low-level Rubin pooling; degrees-of-freedom assumptions should be specified for small samples. Stata reference · R reference |
|
mice
|
Extract first completed dataset Fixed workflow; adapt the named data columns explicitly. R mids metadata and storage structures differ from Stata MI data styles. Stata reference · R reference |
|
mice
|
Binary logistic chained-equation imputation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Set categorical types before imputation and match the model family; random draws are not cross-software identical. Stata reference · R reference |
|
mice
|
Unordered-category chained-equation imputation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Set categorical types before imputation and match the model family; random draws are not cross-software identical. Stata reference · R reference |
|
mice
|
Ordered-category chained-equation imputation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Set categorical types before imputation and match the model family; random draws are not cross-software identical. Stata reference · R reference |
|
mice
|
Customize the imputation predictor matrix Fixed workflow; adapt the named data columns explicitly. A workflow for per-variable models; the R predictor matrix is not inferred automatically from Stata syntax. Stata reference · R reference |
|
mice
|
Chained-equation imputation using pmm Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Imputation algorithms and random draws differ; specify predictor matrix and model types deliberately. Stata reference · R reference |
|
mice
|
Chained-equation imputation using norm Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Imputation algorithms and random draws differ; specify predictor matrix and model types deliberately. Stata reference · R reference |
|
mice
|
Derive a nonlinear variable consistently in each completed
dataset Fixed workflow; adapt the named data columns explicitly. Post-imputation derivation is appropriate when the transform is not needed as an imputation predictor; otherwise use passive imputation within the chain. Stata reference · R reference |
|
mice
|
Combine repeated complete-data Wald tests D1 pools coefficient estimates and covariance matrices for a multivariate MI Wald test, as Stata mi test does. Use the same coefficient ordering and complete-data degrees of freedom; D2 pools test statistics and is a different rule. Stata reference · R reference |
|
mice
|
Pooled multivariate Wald comparison Differs from Stata: Fixed workflow; adapt the named data columns explicitly. D1 combines nested-model Wald information; coefficients must have consistent ordering. Stata reference · R reference |
|
mice
|
Identify variables varying across imputations Fixed workflow; adapt the named data columns explicitly. R mids metadata and storage structures differ from Stata MI data styles. Stata reference · R reference |
|
mice
|
Inspect imputed-variable distributions in each dataset Fixed workflow; adapt the named data columns explicitly. R mids metadata and storage structures differ from Stata MI data styles. Stata reference · R reference |
Multilevel models
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
lme4
|
Random-intercept intraclass correlation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. ICC is constant only for a random-intercept Gaussian model; random slopes make it covariate-dependent. Stata reference · R reference |
|
lme4
|
Random-effects covariance matrix Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Estimated covariance conditional on the chosen random-effects structure. Stata reference · R reference |
|
lme4
|
Variance components as standard deviations and
correlations Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Includes residual standard deviation and random-effect correlation. Stata reference · R reference |
|
lme4
|
Complementary-log-log random-intercept model with Laplace
approximation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
lme4
|
Complementary-log-log random-intercept model with adaptive
quadrature Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
lme4
|
Generalized mixed model with cloglog link Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Explicit family/link choice; defaults and integration accuracy differ. Stata reference · R reference |
|
lme4
|
Generalized mixed model with logit link Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Explicit family/link choice; defaults and integration accuracy differ. Stata reference · R reference |
|
lme4
|
Generalized mixed model with probit link Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Explicit family/link choice; defaults and integration accuracy differ. Stata reference · R reference |
|
lme4
|
Logistic random-intercept model with Laplace
approximation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
lme4
|
Logistic random-intercept model with adaptive
quadrature Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
glmmTMB
|
Negative-binomial mixed model with quadratic mean
variance Differs from Stata: glmmTMB uses Laplace integration; Stata menbreg defaults to intpoints(7) adaptive quadrature and needs intpoints(1) for a comparable integration approximation. Match NB2 dispersion versus its inverse before comparing ancillary parameters; identical integration does not itself guarantee estimator parity. Stata reference · R reference |
|
nlme
|
Nonlinear exponential growth with random asymptote
coefficient Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Nonlinear mixed-model workflow; Stata menl syntax/parameter definitions must match the desired model. Stata reference · R reference |
|
ordinal
|
Random-intercept cumulative-logit model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Threshold signs and quadrature defaults must be aligned. Stata reference · R reference |
|
ordinal
|
Random-intercept cumulative-probit model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Latent residual variance is fixed by the probit link. Stata reference · R reference |
|
lme4
|
Poisson random-intercept model with Laplace
approximation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
lme4
|
Poisson random-intercept model with adaptive
quadrature Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
lme4
|
Probit random-intercept model with Laplace
approximation Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
lme4
|
Probit random-intercept model with adaptive
quadrature Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata's integration settings must be matched; one Laplace point differs from adaptive quadrature. Stata reference · R reference |
|
lme4
|
Quadratic fixed trend with random intercept Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R default REML differs from Stata mixed default ML; explicitly select the target likelihood. Stata reference · R reference |
|
lme4
|
REML random-intercept model Differs from Stata: REML=FALSE explicitly matches Stata mixed default ML. lme4 does not print Stata large-sample fixed-effect z tests by default; match covariance structures and request the intended inference separately. Stata reference · R reference |
|
lme4
|
Independent random intercept and slope Differs from Stata: REML=FALSE explicitly matches Stata mixed default ML. lme4 does not print Stata large-sample fixed-effect z tests by default; match covariance structures and request the intended inference separately. Stata reference · R reference |
|
lme4
|
Correlated random intercept and slope Differs from Stata: REML=FALSE explicitly matches Stata mixed default ML. lme4 does not print Stata large-sample fixed-effect z tests by default; match covariance structures and request the intended inference separately. Stata reference · R reference |
|
lme4
|
ML random-intercept model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R default REML differs from Stata mixed default ML; explicitly select the target likelihood. Stata reference · R reference |
|
lme4
|
Conditional fitted values including random effects Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Prediction level is explicit; population and cluster-specific predictions have different interpretations. Stata reference · R reference |
|
lme4
|
Conditional mixed-model residuals Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Prediction level is explicit; population and cluster-specific predictions have different interpretations. Stata reference · R reference |
|
lme4
|
Empirical Bayes random intercepts and slopes Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Prediction level is explicit; population and cluster-specific predictions have different interpretations. Stata reference · R reference |
|
lme4
|
Fixed-effects-only predictions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Prediction level is explicit; population and cluster-specific predictions have different interpretations. Stata reference · R reference |
|
lme4
|
Sensitivity of mixed-logit estimates to quadrature points Fixed workflow; adapt the named data columns explicitly. Manual quadrature sensitivity check; not an automatic convergence guarantee. Stata reference · R reference |
|
ordinal
|
Random-intercept cumulative-logit model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Threshold signs and quadrature defaults must be aligned. Stata reference · R reference |
|
ordinal
|
Random-intercept cumulative-probit model Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Latent residual variance is fixed by the probit link. Stata reference · R reference |
Epidemiology
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
base
|
Case-control cross-product odds ratio Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Odds ratio is identified under case-control sampling; absolute disease risk is not. Stata reference · R reference |
|
stats
|
Exact conditional odds-ratio inference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Conditional estimate and two-sided p-value conventions can differ. Stata reference · R reference |
|
stats
|
Approximate log-odds Wald interval Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Requires nonzero counts; no automatic continuity correction is applied. Stata reference · R reference |
|
base
|
Case-control cross-product odds ratio Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Odds ratio is identified under case-control sampling; absolute disease risk is not. Stata reference · R reference |
|
stats
|
Exact conditional odds-ratio inference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Conditional estimate and two-sided p-value conventions can differ. Stata reference · R reference |
|
stats
|
Approximate log-odds Wald interval Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Requires nonzero counts; no automatic continuity correction is applied. Stata reference · R reference |
|
base
|
Risk ratio and risk difference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point measures assume a cohort with comparable follow-up; case-control sampling does not identify risk. Stata reference · R reference |
|
base
|
Exposed and population attributable fractions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Causal interpretation additionally requires exchangeability and correct study sampling. Stata reference · R reference |
|
stats
|
Fisher exact association test for cohort table Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R reports a conditional maximum-likelihood odds ratio; Stata also reports sample cross-product measures. Stata reference · R reference |
|
stats
|
Woolf odds-ratio interval in cohort table Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Woolf approximation requires positive cell counts. Stata reference · R reference |
|
base
|
Risk ratio and risk difference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Point measures assume a cohort with comparable follow-up; case-control sampling does not identify risk. Stata reference · R reference |
|
base
|
Exposed and population attributable fractions Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Causal interpretation additionally requires exchangeability and correct study sampling. Stata reference · R reference |
|
stats
|
Fisher exact association test for cohort table Differs from Stata: Fixed workflow; adapt the named data columns explicitly. R reports a conditional maximum-likelihood odds ratio; Stata also reports sample cross-product measures. Stata reference · R reference |
|
stats
|
Woolf odds-ratio interval in cohort table Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Woolf approximation requires positive cell counts. Stata reference · R reference |
|
base
|
Direct standardization of stratum-specific rates Fixed workflow; adapt the named data columns explicitly. Fixed one-population calculation; standard weights must represent the intended reference population. Stata reference · R reference |
|
base
|
Incidence-rate ratio and rate difference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Counts and person-time denominators, not risks. Stata reference · R reference |
|
stats
|
Exact comparison of two Poisson incidence rates Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata ir/iri default mid-p differs; this example requests exact inference. Stata reference · R reference |
|
base
|
Incidence-rate ratio and rate difference Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Counts and person-time denominators, not risks. Stata reference · R reference |
|
stats
|
Exact comparison of two Poisson incidence rates Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Stata ir/iri default mid-p differs; this example requests exact inference. Stata reference · R reference |
|
base
|
Indirect standardization and mortality ratio Fixed workflow; adapt the named data columns explicitly. Point estimates only; reference strata and person-time units must match. Stata reference · R reference |
|
stats
|
McNemar comparison of matched binary exposures Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Uncorrected asymptotic statistic; exact or continuity-corrected alternatives differ. Stata reference · R reference |
|
base
|
Matched odds ratio from discordant pairs Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Concordant pairs do not inform the matched odds ratio. Stata reference · R reference |
|
stats
|
McNemar comparison of matched binary exposures Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Uncorrected asymptotic statistic; exact or continuity-corrected alternatives differ. Stata reference · R reference |
|
base
|
Matched odds ratio from discordant pairs Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Concordant pairs do not inform the matched odds ratio. Stata reference · R reference |
|
stats
|
Mantel-Haenszel common odds ratio Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Table orientation determines the odds-ratio direction; assumes a common stratum effect. Stata reference · R reference |
|
stats
|
Odds of disease by exposure category Fixed workflow; adapt the named data columns explicitly. Computes category odds only; no adjusted trend test. Stata reference · R reference |
Bayesian analysis
| Stata | R | Purpose, qualifications and sources |
|---|---|---|
|
MCMCpack
|
Bayesian Gaussian regression with normal and inverse-gamma
priors Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Simple normal-regression model only; samplers and initialization differ. Short chains demonstrate syntax, not convergence. Stata reference · R reference |
|
MCMCpack
|
Posterior mean Gaussian regression response Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Conditional mean prediction; observation noise is integrated to zero. Stata reference · R reference |
|
MCMCpack
|
Replicated outcomes from a Gaussian posterior predictive
distribution Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Includes posterior parameter uncertainty and observation noise; no prediction files are written. Stata reference · R reference |
|
coda
|
Effective MCMC sample size Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Spectral-density ESS estimator differs from some Stata autocorrelation/batch calculations. Stata reference · R reference |
|
coda
|
Posterior means, standard deviations and quantiles Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Summarizes supplied posterior draws; Monte Carlo errors differ by estimator. Stata reference · R reference |
|
coda
|
Posterior summary of a transformed coefficient Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Transform draws before summarizing; exp(E[b]) differs from E[exp(b)]. Stata reference · R reference |
|
coda
|
Ninety-percent highest-posterior-density interval Differs from Stata: Fixed workflow; adapt the named data columns explicitly. HPD algorithms and multimodality handling can differ. Stata reference · R reference |
|
base
|
Posterior probability of a positive slope Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Monte Carlo probability of an interval hypothesis; not a frequentist p-value. Stata reference · R reference |
|
base
|
Posterior probability within a substantive effect
interval Differs from Stata: Fixed workflow; adapt the named data columns explicitly. Choose the substantive interval before inspecting posterior results. Stata reference · R reference |
R functions by package
| R | Package | Stata | Description |
|---|---|---|---|
ivreg()
|
AER | ivregress | Instrumental-Variable Regression |
tobit()
|
AER | Tobit (censored) regression | |
dbAppendTable()
|
DBI | jdbc | Insert rows into a table |
dbDisconnect()
|
DBI | odbc | Disconnect (close) a connection |
dbGetQuery()
|
DBI | odbc | Retrieve results from a query |
dbListFields()
|
DBI | odbc | List field names of a remote table |
dbListTables()
|
DBI | odbc | List remote tables |
dbReadTable()
|
DBI | jdbc | Read database tables as data frames |
oblimin()
|
GPArotation | rotate | Rotations Functions Using Gradient Projection Algorithms |
quartimax()
|
GPArotation | rotate | Rotations Functions Using Gradient Projection Algorithms |
boxcox()
|
MASS | boxcox | Box-Cox Transformations for Linear Models |
corresp()
|
MASS | ca | Simple Correspondence Analysis |
glm.nb()
|
MASS | Negative binomial regression | |
isoMDS()
|
MASS | mds | Kruskal's Non-metric Multidimensional Scaling |
lda()
|
MASS | discrim | Linear Discriminant Analysis |
mca()
|
MASS | mca | Multiple Correspondence Analysis |
mvrnorm()
|
MASS | drawnorm | Simulate from a Multivariate Normal Distribution |
polr()
|
MASS | Ordered logit or probit | |
qda()
|
MASS | discrim | Quadratic Discriminant Analysis |
rlm()
|
MASS | Robust regression | |
MCMCregress()
|
MCMCpack | bayesmh | Markov Chain Monte Carlo for Gaussian Linear Regression |
match_data()
|
MatchIt | psmatch2 | Construct a matched dataset from a matchit object |
matchit()
|
MatchIt | Matching for causal inference | |
synth()
|
Synth | Synthetic control | |
SurvS4()
|
VGAM | cpoisson | Create a Survival Object |
binom2.rho()
|
VGAM | biprobit | Bivariate Probit Regression |
cens.poisson()
|
VGAM | cpoisson | Censored Poisson Family Function |
multinomial()
|
VGAM | slogit | Multinomial Logit Model |
posnegbinomial()
|
VGAM | tnbreg | Positive Negative Binomial Distribution Family Function |
posnormal()
|
VGAM | truncreg | Positive Normal Distribution Family Function |
pospoisson()
|
VGAM | tpoisson | Positive Poisson Distribution Family Function |
rrvglm()
|
VGAM | slogit | Fitting Reduced-Rank Vector Generalized Linear Models (RR-VGLMs) and Doubly Constrained RR-VGLMs (DRR-VGLMs) |
vglm()
|
VGAM | tpoisson | Fitting Vector Generalized Linear Models |
weightit()
|
WeightIt | Balancing weights, such as inverse-probability weights | |
.libPaths()
|
base | adopath | Search Paths for Packages |
I()
|
base | regress | Inhibit Interpretation/Conversion of Objects |
Mod()
|
base | psdensity | Complex Numbers and Basic Functionality |
R.home()
|
base | sysdir | Return the R Home Directory |
Sys.Date()
|
base | Today's date | |
Sys.sleep()
|
base | sleep | Suspend Execution for a Time Interval |
Sys.time()
|
base | c(current_time) | Current date and time |
abs()
|
base | abs() | Absolute value |
all()
|
base | assert | Whether all values are TRUE |
any()
|
base | count if | Whether any value is TRUE |
anyDuplicated()
|
base | gisid | Determine Duplicate Elements |
anyNA()
|
base | gisid | Not Available / Missing Values |
apply()
|
base | egen rowtotal() | Apply a function over rows or columns |
as.Date()
|
base | Convert to a date | |
as.POSIXct()
|
base | clock | Date-time Conversion Functions |
as.character()
|
base | Convert to text | |
as.data.frame()
|
base | getmata | Coerce to a Data Frame |
as.double()
|
base | Convert to double-precision numbers | |
as.factor()
|
base | encode | Convert to a factor |
as.integer()
|
base | Convert to whole numbers | |
as.matrix()
|
base | cf | Matrices |
as.numeric()
|
base | Convert to numbers | |
as.vector()
|
base | margins | Vectors - Creation, Coercion, etc |
attr()
|
base | Get or set an attribute of an object | |
attributes()
|
base | char | Object Attribute Lists |
body()
|
base | viewsource | Access to and Manipulation of the Body of a Function |
c()
|
base | Combine values into a vector | |
cat()
|
base | Print text without quotes | |
cbind()
|
base | merge 1:1 _n | Put side by side (base R) |
ceiling()
|
base | Round up | |
charToRaw()
|
base | changeeol | Convert to or from (Bit/Packed) Raw Vectors |
character()
|
base | tokenize | Character Vectors |
chol()
|
base | irf | The Cholesky Decomposition |
class()
|
base | describe | Class of an object |
close()
|
base | file | Functions to Manipulate Connections (Files, URLs, ...) |
col()
|
base | spmatrix | Column Indexes |
colMeans()
|
base | margins | Form Row and Column Sums and Means |
colSums()
|
base | missings | Form Row and Column Sums and Means |
colnames()
|
base | ds | Column names |
crossprod()
|
base | tsfilter | Matrix Cross-Product |
cumprod()
|
base | generate | Running product |
cumsum()
|
base | Running sum | |
cut()
|
base | Cut numbers into intervals | |
data.frame()
|
base | range | Data Frames |
diag()
|
base | Diagonal of a matrix | |
diff()
|
base | D. | Differences between neighbouring values |
dim()
|
base | describe | Numbers of rows and columns |
dir()
|
base | List files in a folder | |
dir.create()
|
base | mkdir | Create a folder |
do.call()
|
base | program | Call a function with a list of arguments |
double()
|
base | postfile | Double-Precision Vectors |
dput()
|
base | dataex | Write an Object to a File or Recreate it |
drop()
|
base | lincom | Drop Redundant Extent Information |
droplevels()
|
base | label define | Drop unused factor levels |
duplicated()
|
base | gegen | Determine Duplicate Elements |
eigen()
|
base | varstable | Spectral Decomposition of a Matrix |
environment()
|
base | include | Environment Access |
exp()
|
base | exp() | Exponential |
expand.grid()
|
base | arimasoc | Create a Data Frame from All Combinations of Factor Variables |
factor()
|
base | Categorical variable with labelled levels | |
file()
|
base | file | Functions to Manipulate Connections (Files, URLs, ...) |
file.copy()
|
base | copy | File Manipulation |
file.exists()
|
base | confirm file | Whether a file exists |
file.info()
|
base | hexdump | Extract File Information |
file.path()
|
base | global path | Build a file path |
floor()
|
base | Round down | |
format()
|
base | Format values for display | |
formatC()
|
base | string(x, "%9.2f") | Format numbers with width and padding |
getwd()
|
base | Show the working directory | |
grep()
|
base | unab | Pattern Matching and Replacement |
grepl()
|
base | Whether text matches a pattern | |
gsub()
|
base | subinstr() | Replace every match |
iconv()
|
base | unicode | Convert Character Vector between Encodings |
identical()
|
base | cf | Test Objects for Exact Equality |
ifelse()
|
base | cond() | Vectorised if-else (base R) |
integer()
|
base | gdistinct | Integer Vectors |
interaction()
|
base | egen group() | Combine factors into one |
invisible()
|
base | exit | Change the Print Mode to Invisible |
is.character()
|
base | confirm string variable | Whether a vector holds text |
is.infinite()
|
base | gencohort | Finite, Infinite and NaN Numbers |
is.na()
|
base | Whether values are missing | |
is.nan()
|
base | egen | Finite, Infinite and NaN Numbers |
is.numeric()
|
base | confirm numeric variable | Whether a vector holds numbers |
lapply()
|
base | foreach | Apply a function to each element, returning a list |
length()
|
base | count | Number of elements |
lengths()
|
base | wordcount | Lengths of List or Vector Elements |
levels()
|
base | Categories of a factor | |
library()
|
base | ssc install | Attach a package |
list()
|
base | A list of objects | |
list.files()
|
base | dir | Files in a folder |
load()
|
base | use | Load objects from an .RData file |
local()
|
base | tempvar | Evaluate an (Unevaluated) Expression |
log()
|
base | Logarithm (natural by default) | |
log10()
|
base | log10() | Base-10 logarithm |
logical()
|
base | missings | Logical Vectors |
ls()
|
base | List objects in memory | |
make.names()
|
base | Turn text into valid names | |
mapply()
|
base | arimasoc | Apply a Function to Multiple List or Vector Arguments |
match()
|
base | rename | Value Matching |
match.arg()
|
base | unabcmd | Argument Verification Using Partial Matching |
matrix()
|
base | Create a matrix | |
max()
|
base | Largest value | |
mean()
|
base | Mean | |
merge()
|
base | merge | Merge two data frames (base R) |
message()
|
base | display | Print a message |
min()
|
base | Smallest value | |
names()
|
base | Names of an object, such as column names | |
nchar()
|
base | strlen() | Number of characters |
ncol()
|
base | describe | Number of columns |
nlevels()
|
base | levelsof | Number of factor levels |
normalizePath()
|
base | findfile | Express File Paths in Canonical Form |
nrow()
|
base | Number of rows | |
numeric()
|
base | rangestat | Numeric Vectors |
options()
|
base | set | Set global options |
order()
|
base | sort | Positions that would sort a vector |
paste()
|
base | Join text with a separator | |
paste0()
|
base | Join text without a separator | |
plot()
|
base | Basic plot | |
pmatch()
|
base | unab | Partial String Matching |
pmax()
|
base | max(a, b) | Element-wise maximum of several vectors |
pmin()
|
base | min(a, b) | Element-wise minimum of several vectors |
print()
|
base | Print an object | |
prop.table()
|
base | Turn counts into proportions | |
proportions()
|
base | tabulate, row | Turn a table into proportions |
qr()
|
base | orthog | The QR Decomposition of a Matrix |
qr.Q()
|
base | orthog | Reconstruct the Q, R, or X Matrices from a QR Object |
range()
|
base | summarize | Minimum and maximum |
rank()
|
base | Ranks, with ties averaged | |
rbind()
|
base | append | Stack rows (base R) |
readBin()
|
base | hexdump | Transfer Binary Data To and From Connections |
readLines()
|
base | changeeol | Read Text Lines from a Connection |
readRDS()
|
base | use | Read an R object file (.rds) |
regexpr()
|
base | strpos | Pattern Matching and Replacement |
rep()
|
base | expand | Repeat values |
rep_len()
|
base | Repeat values to a given length | |
replace()
|
base | generate | Replace Values in a Vector |
replicate()
|
base | bootstrap | Apply a Function over a List or Vector |
requireNamespace()
|
base | ftools | Loading and Unloading Name Spaces |
return()
|
base | exit | Function Definition |
rev()
|
base | gsort | Reverse the order |
rm()
|
base | Remove objects from memory | |
round()
|
base | Round to a number of decimals | |
row()
|
base | spmatrix | Row Indexes |
rowMeans()
|
base | egen | Form Row and Column Sums and Means |
rowSums()
|
base | Sum across columns in each row | |
sample()
|
base | sample | Random sample of values |
sample.int()
|
base | bsample | Random Samples and Permutations |
sapply()
|
base | foreach | Apply a function to each element and simplify |
save()
|
base | save | Save objects to an .RData file |
saveRDS()
|
base | Save one R object to a file | |
scale()
|
base | egen std() | Standardise columns |
scan()
|
base | tokenize | Read Data Values |
seq()
|
base | Sequence of numbers | |
seq_along()
|
base | _n | Positions of the elements of a vector |
seq_len()
|
base | _n | Whole numbers from 1 to n |
serialize()
|
base | datasignature | Simple Serialization Interface |
set.seed()
|
base | Make random numbers reproducible | |
setwd()
|
base | Change the working directory | |
sign()
|
base | compare | Sign Function |
signif()
|
base | round() | Round to significant digits |
sin()
|
base | tsfilter | Trigonometric Functions |
sink()
|
base | Send console output to a file | |
solve()
|
base | estat | Solve a System of Equations |
sort()
|
base | Sort a vector | |
source()
|
base | Run an R script | |
split()
|
base | by | Split data into groups |
sprintf()
|
base | Format numbers and text with a template | |
sqrt()
|
base | Square root | |
stop()
|
base | exit 198 | Stop with an error |
stopifnot()
|
base | Stop if a condition is not TRUE | |
strsplit()
|
base | split | Split strings |
sub()
|
base | regexr() | Replace the first match |
subset()
|
base | keep if | Rows meeting a condition (base R) |
substr()
|
base | substr() | Part of a string by position |
sum()
|
base | Sum | |
summary()
|
base | Summary of an object, such as a model | |
sys.source()
|
base | include | Parse and Evaluate Expressions from a File |
t()
|
base | Transpose a matrix | |
table()
|
base | Count values | |
tapply()
|
base | bysort g: egen | Apply a function within groups |
tempdir()
|
base | sysdir | Create Names for Temporary Files |
tempfile()
|
base | Name for a temporary file | |
tolower()
|
base | strlower() | Lower case |
toupper()
|
base | strupper() | Upper case |
traceback()
|
base | Show where the last error happened | |
transform()
|
base | expandcl | Transform an Object, for Example a Data Frame |
trimws()
|
base | strtrim() | Remove leading and trailing spaces |
trunc()
|
base | int() | Drop the decimals |
try()
|
base | capture | Run code and continue after an error |
tryCatch()
|
base | capture | Handle errors and warnings |
typeof()
|
base | describe | Storage type |
unclass()
|
base | rotate | Object Classes |
unique()
|
base | Distinct values | |
unname()
|
base | cf | Remove names or dimnames |
unsplit()
|
base | permute | Divide into Groups and Reassemble |
vapply()
|
base | gdistinct | Apply a Function over a List or Vector |
vector()
|
base | irf | Vectors - Creation, Coercion, etc |
warning()
|
base | display as error | Give a warning |
which()
|
base | list if | Positions where a condition is TRUE |
with()
|
base | Evaluate code with the columns of a data frame | |
writeBin()
|
base | changeeol | Transfer Binary Data To and From Connections |
writeLines()
|
base | checksum | Write Lines to a Connection |
xor()
|
base | egen | Logical Operators |
betareg()
|
betareg | betareg | Beta Regression for Rates and Proportions |
binsreg()
|
binsreg | Binned scatter plot and estimation | |
boot()
|
boot | centile | Bootstrap Resampling |
boot.ci()
|
boot | centile | Nonparametric Bootstrap Confidence Intervals |
augment()
|
broom | predict | Add fitted values and residuals to the data |
glance()
|
broom | One-row summary of model statistics | |
tidy()
|
broom | Coefficient table as a data frame | |
Anova()
|
car | anova | Type II and III ANOVA tables |
avPlots()
|
car | Added-variable plots | |
deltaMethod()
|
car | nlcom | Estimate and Standard Error of a Nonlinear Function of Estimated Regression Coefficients |
leveneTest()
|
car | robvar | Levene's Test |
linearHypothesis()
|
car | test | Test linear restrictions on coefficients |
vif()
|
car | Variance inflation factors | |
knn()
|
class | discrim | k-Nearest Neighbour Classification |
bal.tab()
|
cobalt | pstest | Display Balance Statistics in a Table |
HPDinterval()
|
coda | bayesstats | Highest Posterior Density intervals |
effectiveSize()
|
coda | bayesstats | Effective sample size for estimating the mean |
fread()
|
data.table | import delimited | Fast reading of large text files |
fwrite()
|
data.table | export delimited | Fast writing of large text files |
winsorize()
|
datawizard | Winsorise extreme values | |
att_gt()
|
did | Staggered difference in differences (Callaway-Sant'Anna) | |
across()
|
dplyr | Apply the same calculation to several columns | |
add_count()
|
dplyr | bysort g: generate n = _N | Add a column with group counts |
all_of()
|
dplyr | keep `vars' | Select columns named in a character vector |
anti_join()
|
dplyr | Keep rows of the first table with no match in the second | |
any_of()
|
dplyr | capture keep | Select listed columns that exist |
arrange()
|
dplyr | Sort rows | |
between()
|
dplyr | Whether values lie within a range | |
bind_cols()
|
dplyr | Put tables side by side | |
bind_rows()
|
dplyr | Stack tables on top of each other | |
c_across()
|
dplyr | egen rowtotal() | Combine columns inside rowwise() |
case_match()
|
dplyr | recode | Recode values by matching them |
case_when()
|
dplyr | Several if-else conditions in one step | |
coalesce()
|
dplyr | First non-missing value across vectors | |
consecutive_id()
|
dplyr | tsspell | Number runs of identical values |
contains()
|
dplyr | Select columns whose names contain some text | |
count()
|
dplyr | Count rows in each group | |
cross_join()
|
dplyr | Every combination of rows from two tables | |
cumall()
|
dplyr | sum() | Running all(): TRUE until the first FALSE |
cume_dist()
|
dplyr | cumul | Cumulative distribution |
cur_group()
|
dplyr | by | Keys of the current group |
cur_group_id()
|
dplyr | Number of the current group | |
dense_rank()
|
dplyr | egen group() | Ranks without gaps |
desc()
|
dplyr | Sort in descending order inside arrange() | |
distinct()
|
dplyr | Keep unique rows | |
ends_with()
|
dplyr | Select columns whose names end with some text | |
everything()
|
dplyr | _all | Select all columns |
filter()
|
dplyr | Keep rows that meet a condition | |
first()
|
dplyr | x[1] | First value |
full_join()
|
dplyr | Merge keeping all rows of both tables | |
glimpse()
|
dplyr | describe | Compact view of all columns |
group_by()
|
dplyr | Group rows so later steps work within groups | |
group_split()
|
dplyr | by | Split a table into one table per group |
group_vars()
|
dplyr | by | Names of the grouping variables |
if_all()
|
dplyr | egen rowmin() | Whether a condition holds in all of several columns |
if_any()
|
dplyr | egen anymatch() | Whether a condition holds in any of several columns |
if_else()
|
dplyr | One value if a condition holds, another if not | |
inner_join()
|
dplyr | Merge keeping only matched rows | |
intersect()
|
dplyr | merge, keep(match) | Rows in both tables |
join_by()
|
dplyr | joinby | Join keys, including inequality and range joins |
lag()
|
dplyr | Value from the previous row | |
last()
|
dplyr | x[_N] | Last value |
last_col()
|
dplyr | order | The last column |
lead()
|
dplyr | Value from the next row | |
left_join()
|
dplyr | Merge keeping all rows of the first table | |
matches()
|
dplyr | Select columns whose names match a regular expression | |
min_rank()
|
dplyr | egen rank(), track | Ranks with ties given the lowest rank |
mutate()
|
dplyr | Create or change columns | |
n()
|
dplyr | Number of rows in the current group | |
n_distinct()
|
dplyr | distinct | Number of distinct values |
na_if()
|
dplyr | Turn one value into missing | |
near()
|
dplyr | reldif() | Compare numbers with a tolerance |
nth()
|
dplyr | x[5] | Value at a given position |
ntile()
|
dplyr | xtile | Split into n groups of nearly equal size |
num_range()
|
dplyr | keep x1-x5 | Select x1, x2 and so on by number |
percent_rank()
|
dplyr | egen rank() | Rank rescaled to 0-1 |
pick()
|
dplyr | varlist | Select columns inside mutate() or summarise() |
pull()
|
dplyr | Extract one column as a vector | |
reframe()
|
dplyr | collapse | Summarise to any number of rows per group |
relocate()
|
dplyr | Move columns to a new position | |
rename()
|
dplyr | Rename columns (new = old) | |
rename_with()
|
dplyr | Rename columns with a function, such as toupper | |
right_join()
|
dplyr | Merge keeping all rows of the second table | |
row_number()
|
dplyr | Row number | |
rows_update()
|
dplyr | merge, update replace | Update rows from another table |
rowwise()
|
dplyr | egen rowmean() | Compute row by row |
select()
|
dplyr | Keep or drop columns | |
semi_join()
|
dplyr | Keep rows of the first table that have a match in the second | |
setdiff()
|
dplyr | merge, keep(master) | Rows in the first table only |
slice()
|
dplyr | Keep rows by position | |
slice_head()
|
dplyr | bysort g: keep if _n <= 3 | First rows of each group |
slice_max()
|
dplyr | gsort -x; keep in 1/5 | Rows with the largest values |
slice_min()
|
dplyr | sort x; keep in 1/5 | Rows with the smallest values |
slice_sample()
|
dplyr | Random sample of rows | |
slice_tail()
|
dplyr | bysort g: keep if _n > _N - 3 | Last rows of each group |
starts_with()
|
dplyr | Select columns whose names start with some text | |
summarise()
|
dplyr | Reduce each group to one row of statistics | |
summarize()
|
dplyr | collapse | Same as summarise() |
tally()
|
dplyr | count | Count rows |
transmute()
|
dplyr | keep | Create columns and keep only those |
ungroup()
|
dplyr | Remove grouping | |
union()
|
dplyr | append | Rows in either table, without duplicates |
where()
|
dplyr | ds, has(type numeric) | Select columns by type, such as where(is.numeric) |
cohens_d()
|
effectsize | esize | Cohen's d and Other Standardized Differences |
iv_robust()
|
estimatr | ivregress | Two-Stage Least Squares Instrumental Variables Regression |
coefplot()
|
fixest | coefplot | Coefficient plot for fixest models |
etable()
|
fixest | esttab | Regression table for fixest models |
feglm()
|
fixest | xtlogit | GLM, such as logit, with fixed effects |
fenegbin()
|
fixest | xtnbreg | Negative binomial model with fixed effects |
feols()
|
fixest | Linear regression with fixed effects, clustering and IV | |
fepois()
|
fixest | Poisson regression with fixed effects | |
fitstat()
|
fixest | estat firststage | Fit statistics, including the first-stage F |
sunab()
|
fixest | eventstudyinteract | Sun and Abraham interactions |
flextable()
|
flextable | Formatted table for Word or PowerPoint | |
save_as_docx()
|
flextable | Save tables to a Word file | |
fct_collapse()
|
forcats | recode | Combine levels into groups |
fct_count()
|
forcats | tabulate | Count each level |
fct_drop()
|
forcats | label define | Drop unused levels |
fct_infreq()
|
forcats | tabulate x, sort | Order levels by frequency |
fct_lump_n()
|
forcats | recode | Lump rare levels into Other |
fct_na_value_to_level()
|
forcats | tabulate x, missing | Make missing values a level |
fct_recode()
|
forcats | label define, modify | Rename factor levels |
fct_relevel()
|
forcats | ib3.x | Move factor levels to the front |
fct_reorder()
|
forcats | graph bar, sort | Order levels by another variable |
fct_rev()
|
forcats | label define | Reverse the order of levels |
Arima()
|
forecast | forecast | Fit ARIMA model to univariate time series |
forecast()
|
forecast | forecast | Objects exported from other packages |
fracdiff()
|
fracdiff | arfima | ML Estimates for Fractionally-Differenced ARIMA (p,d,q) models |
boottest()
|
fwildclusterboot | boottest | Fast wild cluster bootstrap inference |
geeglm()
|
geepack | xtgee | Fit Generalized Estimating Equations (GEE) |
aes()
|
ggplot2 | Map variables to x, y, colour and other plot features | |
after_stat()
|
ggplot2 | histogram | Control aesthetic evaluation |
annotate()
|
ggplot2 | text() | Add one annotation, such as text |
coord_cartesian()
|
ggplot2 | xscale(range()) | Zoom in without dropping data |
coord_flip()
|
ggplot2 | Swap the x and y axes | |
coord_polar()
|
ggplot2 | Polar coordinates, used for pie charts | |
facet_grid()
|
ggplot2 | by() | Panels by two variables |
facet_wrap()
|
ggplot2 | One panel per group | |
geom_abline()
|
ggplot2 | function | Line with a given slope and intercept |
geom_area()
|
ggplot2 | Area plot | |
geom_bar()
|
ggplot2 | Bar chart of counts | |
geom_boxplot()
|
ggplot2 | Box plot | |
geom_col()
|
ggplot2 | graph bar (asis) | Bars with given heights |
geom_contour()
|
ggplot2 | twoway | 2D contours of a 3D surface |
geom_density()
|
ggplot2 | Density curve | |
geom_errorbar()
|
ggplot2 | Error bars or capped ranges | |
geom_histogram()
|
ggplot2 | Histogram | |
geom_hline()
|
ggplot2 | yline() | Horizontal reference line |
geom_jitter()
|
ggplot2 | scatter, jitter() | Jittered points |
geom_label()
|
ggplot2 | mlabel() | Text labels in boxes |
geom_line()
|
ggplot2 | Lines connecting observations | |
geom_linerange()
|
ggplot2 | twoway | Vertical intervals: lines, crossbars & errorbars |
geom_point()
|
ggplot2 | Points (scatter plot) | |
geom_pointrange()
|
ggplot2 | rcap | Points with intervals |
geom_qq()
|
ggplot2 | Quantile-quantile points | |
geom_qq_line()
|
ggplot2 | Reference line for a quantile-quantile plot | |
geom_rect()
|
ggplot2 | twoway | Rectangles |
geom_ribbon()
|
ggplot2 | Shaded band between two values | |
geom_segment()
|
ggplot2 | twoway | Line segments and curves |
geom_sf()
|
ggplot2 | spmap | Map from spatial data |
geom_smooth()
|
ggplot2 | Fitted line or smooth curve | |
geom_step()
|
ggplot2 | line, connect(stairstep) | Step plot |
geom_text()
|
ggplot2 | Text labels on a plot | |
geom_tile()
|
ggplot2 | heatplot | Heat-map tiles |
geom_violin()
|
ggplot2 | Violin plot | |
geom_vline()
|
ggplot2 | Vertical reference line | |
ggplot()
|
ggplot2 | Start a plot | |
ggsave()
|
ggplot2 | Save a plot to a file | |
labs()
|
ggplot2 | title() | Title and axis labels |
position_dodge()
|
ggplot2 | over() | Place bars or points side by side |
position_jitter()
|
ggplot2 | dotplot | Jitter points to avoid overplotting |
scale_colour_manual()
|
ggplot2 | mcolor() | Choose colours by hand |
scale_fill_brewer()
|
ggplot2 | set scheme | ColorBrewer fill colours |
scale_x_continuous()
|
ggplot2 | xlabel() | Axis breaks and labels |
scale_x_log10()
|
ggplot2 | xscale(log) | Logarithmic x axis |
scale_y_continuous()
|
ggplot2 | scatter | Position scales for continuous data (x & y) |
scale_y_log10()
|
ggplot2 | scatter | Position scales for continuous data (x & y) |
stat_ecdf()
|
ggplot2 | cumul | Empirical cumulative distribution plot |
stat_summary()
|
ggplot2 | Plot a summary, such as the mean, of y at each x | |
stat_summary_2d()
|
ggplot2 | heatplot | Summarize a variable within two-dimensional bins |
theme()
|
ggplot2 | graphregion() | Fine-tune the look of a plot |
theme_bw()
|
ggplot2 | Black-and-white plot theme | |
theme_classic()
|
ggplot2 | set scheme | Classic plot theme |
theme_minimal()
|
ggplot2 | set scheme | Minimal plot theme |
theme_set()
|
ggplot2 | Set the default theme for every plot | |
xlim()
|
ggplot2 | xscale(range()) | Limits of the x axis |
glmmTMB()
|
glmmTMB | menbreg | Fit Models with TMB |
nbinom2()
|
glmmTMB | menbreg | Family functions for glmmTMB |
cv.glmnet()
|
glmnet | lasso | Cross-validation for glmnet |
pairs()
|
graphics | Scatter-plot matrix | |
plot()
|
graphics | quantile | The Default Scatterplot Function |
stem()
|
graphics | Stem-and-leaf display | |
arrow()
|
grid | twoway | Describe arrows to add to a line |
tbl_cross()
|
gtsummary | tabulate x1 x2 | Cross table |
tbl_regression()
|
gtsummary | esttab | Regression table |
tbl_summary()
|
gtsummary | Descriptive Table 1 | |
as_factor()
|
haven | decode | Turn labelled values into a factor |
is_tagged_na()
|
haven | mvencode | "Tagged" missing values |
labelled()
|
haven | Attach value labels to a vector | |
print_labels()
|
haven | label list | Show value labels |
read_dta()
|
haven | Read a Stata .dta file | |
read_sas()
|
haven | Read a SAS file | |
read_sav()
|
haven | Read an SPSS .sav file | |
read_xpt()
|
haven | import | Read and write SAS transport files |
tagged_na()
|
haven | replace x = .a | Stata-style extended missing values such as .a |
write_dta()
|
haven | Write a Stata .dta file | |
write_sav()
|
haven | savespss | Write an SPSS file |
write_xpt()
|
haven | export | Read and write SAS transport files |
zap_labels()
|
haven | Remove value labels | |
zap_missing()
|
haven | mvdecode | Turn special missing values into NA |
adorn_totals()
|
janitor | tabulate x1 x2 | Add totals to a tabyl |
clean_names()
|
janitor | rename *, lower | Clean and lower-case variable names |
get_dupes()
|
janitor | duplicates list | List duplicated rows |
remove_empty()
|
janitor | missings dropvars | Drop empty rows and columns |
tabyl()
|
janitor | tabulate | Frequency and cross tables |
look_for()
|
labelled | lookfor | Find variables by name or label |
set_variable_labels()
|
labelled | Set variable labels | |
to_factor()
|
labelled | decode | Turn labelled values into a factor |
val_labels()
|
labelled | label values | Get or set value labels |
var_label()
|
labelled | label variable | Get or set a variable label |
cfa()
|
lavaan | sem | Fit Confirmatory Factor Analysis Models |
fitMeasures()
|
lavaan | estat | Fit Measures for a Latent Variable Model |
lavResiduals()
|
lavaan | estat | Residuals |
modindices()
|
lavaan | estat | Modification Indices |
sem()
|
lavaan | Structural equation model | |
standardizedSolution()
|
lavaan | sem | Standardized Solution |
VarCorr()
|
lme4 | estat sd | Variance components of a multilevel model |
fixef()
|
lme4 | quadchk | Extract fixed-effects estimates |
glmer()
|
lme4 | Multilevel generalised linear model | |
glmerControl()
|
lme4 | melogit | Control of Mixed Model Fitting |
lmer()
|
lme4 | Multilevel linear model | |
ranef()
|
lme4 | predict, reffects | Predicted random effects |
bptest()
|
lmtest | Breusch-Pagan test for heteroskedasticity | |
coeftest()
|
lmtest | Coefficient tests with a chosen variance matrix | |
grangertest()
|
lmtest | vargranger | Test for Granger Causality |
lrtest()
|
lmtest | Likelihood-ratio test | |
resettest()
|
lmtest | RESET test for omitted variables | |
waldtest()
|
lmtest | test | Wald test of nested models |
as_date()
|
lubridate | dofc() | Convert to a date |
day()
|
lubridate | Day of the month | |
days()
|
lubridate | d + 7 | A period of days, for date arithmetic |
days_in_month()
|
lubridate | daysinmonth | Get the number of days in the month of a date-time |
dmy()
|
lubridate | date(s, "DMY") | Parse day-month-year text into a date |
floor_date()
|
lubridate | mofd() | Round a date down to a unit, such as the month |
hour()
|
lubridate | hh() | Hour of a date-time |
interval()
|
lubridate | Time span between two dates | |
make_date()
|
lubridate | Date from year, month and day | |
make_datetime()
|
lubridate | mdyhms() | Date-time from its parts |
mdy()
|
lubridate | date(s, "MDY") | Parse month-day-year text into a date |
minute()
|
lubridate | mm() | Minute of a date-time |
month()
|
lubridate | Month of a date | |
now()
|
lubridate | now() | Current date and time |
quarter()
|
lubridate | quarter() | Quarter of a date |
time_length()
|
lubridate | Length of a time span in chosen units, such as years | |
today()
|
lubridate | today() | Today's date |
wday()
|
lubridate | Day of the week | |
week()
|
lubridate | week() | Week of the year |
yday()
|
lubridate | doy() | Day of the year |
year()
|
lubridate | Year of a date | |
years()
|
lubridate | d + 365 | A period of years, for date arithmetic |
ymd()
|
lubridate | Parse text such as 2024-01-31 into a date | |
ymd_hms()
|
lubridate | Parse text into a date-time | |
avg_comparisons()
|
marginaleffects | margins r.x | Average contrasts |
avg_predictions()
|
marginaleffects | Average predictions, like Stata's margins | |
avg_slopes()
|
marginaleffects | Average marginal effects | |
comparisons()
|
marginaleffects | margins r.x | Differences between predictions (contrasts) |
hypotheses()
|
marginaleffects | Tests of linear and nonlinear hypotheses | |
plot_predictions()
|
marginaleffects | Plot predictions, like marginsplot | |
plot_slopes()
|
marginaleffects | marginsplot | Plot marginal effects |
predictions()
|
marginaleffects | margins | Predictions with standard errors |
slopes()
|
marginaleffects | margins, dydx(x) at() | Marginal effects for each observation |
cumul()
|
metafor | meta | Cumulative Meta-Analysis for 'rma' Objects |
escalc()
|
metafor | meta | Calculate Effect Sizes and Outcome Measures |
leave1out()
|
metafor | meta | Leave-One-Out Diagnostics for 'rma' Objects |
ranktest()
|
metafor | meta | Rank Correlation Test for Funnel Plot Asymmetry |
regtest()
|
metafor | meta | Regression Test for Funnel Plot Asymmetry |
rma()
|
metafor | meta | Meta-Analysis via Linear (Mixed-Effects) Models |
trimfill()
|
metafor | meta | Trim and Fill Analysis for 'rma.uni' Objects |
D1()
|
mice | mi | Compare two nested models using D1-statistic |
D2()
|
mice | mi | Compare two nested models using D2-statistic |
complete()
|
mice | mi | Extracts the completed data from a mids object |
make.predictorMatrix()
|
mice | mi | Creates a predictorMatrix argument |
mice()
|
mice | Multiple imputation by chained equations | |
pool()
|
mice | Combine results across imputations | |
pool.scalar()
|
mice | mi | Multiple imputation pooling: univariate version |
MIcombine()
|
mitools | mi | Multiple imputation inference |
datasummary()
|
modelsummary | tabstat | Custom summary-statistics tables |
datasummary_skim()
|
modelsummary | codebook | Quick overview of all variables |
modelplot()
|
modelsummary | Coefficient plot | |
modelsummary()
|
modelsummary | Regression and summary tables | |
glht()
|
multcomp | contrast | General Linear Hypotheses |
mcp()
|
multcomp | contrast | General Linear Hypotheses |
dmvnorm()
|
mvtnorm | lnmvnormalden | Multivariate Normal Density and Random Deviates |
pmvnorm()
|
mvtnorm | binormal | Multivariate Normal Distribution |
corAR1()
|
nlme | xtregar | AR(1) Correlation Structure |
gls()
|
nlme | hetregress | Fit Linear Model Using Generalized Least Squares |
lme()
|
nlme | xtregar | Linear Mixed-Effects Models |
nlme()
|
nlme | menl | Nonlinear Mixed-Effects Models |
varExp()
|
nlme | hetregress | Exponential Variance Function |
varIdent()
|
nlme | xtgls | Constant Variance Function |
multinom()
|
nnet | Multinomial logit | |
oaxaca()
|
oaxaca | Blinder-Oaxaca decomposition | |
clmm()
|
ordinal | meologit | Cumulative Link Mixed Models |
coords()
|
pROC | roctab | Coordinates of a ROC curve |
roc()
|
pROC | roctab | Build a ROC curve |
roc.test()
|
pROC | roccomp | Compare two ROC curves |
wrap_plots()
|
patchwork | Combine several plots | |
pdata.frame()
|
plm | xtset | Declare panel data for plm |
pgmm()
|
plm | Dynamic panel GMM (Arellano-Bond) | |
phtest()
|
plm | hausman | Hausman test |
plm()
|
plm | Panel models: fixed and random effects | |
plmtest()
|
plm | xttest0 | Lagrange FF Multiplier Tests for Panel Models |
purtest()
|
plm | xtunitroot | Unit root tests for panel data |
vcovBK()
|
plm | xtpcse | Beck and Katz Robust Covariance Matrix Estimators |
vcovHC()
|
plm | xtreg | Robust Covariance Matrix Estimators |
vcovSCC()
|
plm | xtreg | Driscoll and Kraay (1998) Robust Covariance Matrix Estimator |
polychor()
|
polycor | tetrachoric | Polychoric Correlation |
zeroinfl()
|
pscl | zip | Zero-inflated Count Data Regression |
ICC()
|
psych | icc | Intraclass Correlations (ICC1, ICC2, ICC3 from Shrout and Fleiss) |
KMO()
|
psych | estat | Find the Kaiser, Meyer, Olkin Measure of Sampling Adequacy |
alpha()
|
psych | alpha | Cronbach's alpha |
cohen.kappa()
|
psych | kap | Find Cohen's kappa and weighted kappa coefficients for correlation of two raters |
describe()
|
psych | summarize | Summary statistics (unlike Stata's describe) |
fa()
|
psych | factor | Factor analysis with more methods |
mardia()
|
psych | mvtest | Calculate univariate or multivariate (Mardia's test) skew and kurtosis for a vector, matrix, or data.frame |
principal()
|
psych | factor | Principal components analysis (PCA) |
list_rbind()
|
purrr | append | Stack a list of data frames |
map()
|
purrr | foreach | Apply a function to each element, returning a list |
map2()
|
purrr | forvalues | Apply a function to pairs of elements |
map_chr()
|
purrr | foreach | Apply a function to each element, returning text |
map_dbl()
|
purrr | foreach | Apply a function to each element, returning numbers |
possibly()
|
purrr | capture | Return a default value instead of an error |
reduce()
|
purrr | merge | Combine elements one after another, such as repeated merges |
walk()
|
purrr | foreach | Apply a function for its side effects, such as saving files |
ES.h()
|
pwr | power | Effect size calculation for proportions |
pwr.anova.test()
|
pwr | power | Power calculations for balanced one-way analysis of variance tests |
pwr.f2.test()
|
pwr | power | Power calculations for the general linear model |
pwr.norm.test()
|
pwr | power | Power calculations for the mean of a normal distribution (known variance) |
pwr.p.test()
|
pwr | power | Power calculations for proportion tests (one sample) |
pwr.r.test()
|
pwr | power | Power calculations for correlation test |
pwr.t2n.test()
|
pwr | power | Power calculations for two samples (different sizes) t-tests of means |
rq()
|
quantreg | Quantile regression | |
rdbwdensity()
|
rddensity | rdbwdensity | Bandwidth Selection for Manipulation Testing |
rddensity()
|
rddensity | rddensity | Manipulation Testing Using Local Polynomial Density Estimation |
rdbwselect()
|
rdrobust | rdbwselect | Bandwidth Selection Procedures for Local Polynomial Regression Discontinuity Estimators |
rdrobust()
|
rdrobust | Regression discontinuity | |
parse_number()
|
readr | destring, ignore() | Extract a number from text such as $1,200 |
read_csv()
|
readr | Read a CSV file | |
read_delim()
|
readr | import delimited | Read a file with any delimiter |
read_tsv()
|
readr | import delimited | Read a tab-separated file |
write_csv()
|
readr | Write a CSV file | |
excel_sheets()
|
readxl | import excel, describe | Sheet names of an Excel file |
read_excel()
|
readxl | Read an Excel sheet | |
install_github()
|
remotes | Install a package from GitHub | |
find_root()
|
rprojroot | setroot | Find the root of a directory hierarchy |
has_file()
|
rprojroot | setroot | Is a directory the project root? |
selection()
|
sampleSelection | Heckman sample-selection model | |
NeweyWest()
|
sandwich | newey | Newey-West HAC Covariance Matrix Estimation |
vcovBS()
|
sandwich | Bootstrap variance matrix | |
vcovCL()
|
sandwich | vce(cluster id) | Clustered variance matrix |
vcovHC()
|
sandwich | vce(robust) | Heteroskedasticity-robust variance matrix |
vcovJK()
|
sandwich | Jackknife variance matrix | |
st_as_sf()
|
sf | spset | Convert foreign object to an sf object |
as_survey_design()
|
srvyr | Declare a survey design | |
survey_mean()
|
srvyr | Survey-weighted mean | |
survey_prop()
|
srvyr | Survey-weighted proportion | |
survey_quantile()
|
srvyr | epctile | Survey-weighted quantiles |
survey_total()
|
srvyr | svy: total | Survey-weighted total |
AIC()
|
stats | Akaike information criterion | |
BIC()
|
stats | Bayesian information criterion | |
Box.test()
|
stats | wntestq | #1BoxBox-#1PiercePierce and #1LjungLjung-#1BoxBox Tests |
Gamma()
|
stats | glm | Family Objects for Models |
HoltWinters()
|
stats | tssmooth | Holt-Winters Filtering |
IQR()
|
stats | egen iqr() | Interquartile range |
StructTS()
|
stats | sspace | Fit Structural Time Series |
TukeyHSD()
|
stats | pwcompare, mcompare(tukey) | Tukey multiple comparisons |
acf()
|
stats | corrgram | Autocorrelation function |
addmargins()
|
stats | tabulate x1 x2 | Add totals to a table |
aggregate()
|
stats | collapse | Group statistics (base R) |
anova()
|
stats | anova | ANOVA table, or comparison of nested models |
aov()
|
stats | Analysis of variance | |
approx()
|
stats | ipolate | Interpolation Functions |
arima()
|
stats | ARIMA time-series model | |
as.dist()
|
stats | mdsmat | Distance Matrix Computation |
ave()
|
stats | stgen | Group Averages Over Level Combinations of Factors |
bartlett.test()
|
stats | oneway | Bartlett test of equal variances |
binom.test()
|
stats | bitest | Exact binomial test |
binomial()
|
stats | Binomial family for logit and probit models | |
cancor()
|
stats | canon | Canonical Correlations |
ccf()
|
stats | xcorr | Auto- and Cross- Covariance and -Correlation Function Estimation |
chisq.test()
|
stats | tabulate x1 x2, chi2 | Chi-square test |
cmdscale()
|
stats | mds | Classical (Metric) Multidimensional Scaling |
coef()
|
stats | Model coefficients | |
complete.cases()
|
stats | egen rowmiss() | Rows with no missing values |
confint()
|
stats | regress | Confidence intervals of coefficients |
cooks.distance()
|
stats | predict | Regression Deletion Diagnostics |
cor()
|
stats | Correlation matrix | |
cor.test()
|
stats | Correlation with a significance test | |
cov()
|
stats | correlate, covariance | Covariance |
cov2cor()
|
stats | estat | Correlation, Variance and Covariance (Matrices) |
cutree()
|
stats | cluster | Cut a Tree into Groups of Data |
dbeta()
|
stats | betaden | The Beta Distribution |
dbinom()
|
stats | binomialp | The Binomial Distribution |
dcauchy()
|
stats | cauchyden | The Cauchy Distribution |
dchisq()
|
stats | chi2den | The (non-central) Chi-Squared Distribution |
density()
|
stats | kdensity | Kernel density estimate |
dexp()
|
stats | exponentialden | The Exponential Distribution |
df()
|
stats | Fden | The F Distribution |
dfbetas()
|
stats | dfbeta | Regression Deletion Diagnostics |
dffits()
|
stats | predict | Regression Deletion Diagnostics |
dgamma()
|
stats | gammaden | The Gamma Distribution |
dhyper()
|
stats | hypergeometricp | The Hypergeometric Distribution |
dist()
|
stats | mds | Distance Matrix Computation |
dlogis()
|
stats | logisticden | The Logistic Distribution |
dnbinom()
|
stats | nbinomialp | The Negative Binomial Distribution |
dnorm()
|
stats | normalden() | Normal density |
dpois()
|
stats | poissonp | The Poisson Distribution |
dt()
|
stats | tden | The Student t Distribution |
dweibull()
|
stats | weibullden | The Weibull Distribution |
ecdf()
|
stats | cumul | Empirical cumulative distribution |
expand.model.frame()
|
stats | vce(cluster g) | Retrieve additional variables aligned with a fitted model's observations |
factanal()
|
stats | Factor analysis | |
filter()
|
stats | tssmooth | Linear Filtering on a Time Series |
fisher.test()
|
stats | Fisher's exact test | |
fitted()
|
stats | Fitted values of a model | |
ftable()
|
stats | table | Flat multi-way table |
gaussian()
|
stats | glm | Family Objects for Models |
glm()
|
stats | Generalised linear model, such as logit or Poisson | |
hatvalues()
|
stats | predict | Regression Deletion Diagnostics |
hclust()
|
stats | cluster | Hierarchical Clustering |
inverse.gaussian()
|
stats | glm | Family Objects for Models |
kmeans()
|
stats | K-means clustering | |
kruskal.test()
|
stats | Kruskal-Wallis test | |
ks.test()
|
stats | Kolmogorov-Smirnov test | |
lm()
|
stats | Linear regression | |
logLik()
|
stats | e(ll) | Log-likelihood of a model |
lowess()
|
stats | lowess | Lowess smoother |
mad()
|
stats | egen mad() | Median absolute deviation |
manova()
|
stats | manova | Multivariate Analysis of Variance |
mantelhaen.test()
|
stats | mhodds | Cochran-Mantel-#1HaenszelHaenszel Chi-Squared Test for Count Data |
mcnemar.test()
|
stats | mcc | McNemar test for paired proportions |
median()
|
stats | Median | |
model.frame()
|
stats | estat | Extracting the Model Frame from a Formula or Fit |
model.matrix()
|
stats | xi | Design matrix with dummy variables |
na.omit()
|
stats | Drop rows with missing values | |
nls()
|
stats | nl | Nonlinear least squares |
nobs()
|
stats | e(N) | Number of observations used by a model |
offset()
|
stats | poisson | Include an Offset in a Model Formula |
optim()
|
stats | ml | General-purpose optimisation |
p.adjust()
|
stats | test, mtest | Adjust p-values for multiple tests |
pacf()
|
stats | pac | Auto- and Cross- Covariance and -Correlation Function Estimation |
pairwise.t.test()
|
stats | pwmean | Pairwise t tests with adjusted p-values |
pbeta()
|
stats | ibeta | The Beta Distribution |
pbinom()
|
stats | binomial | The Binomial Distribution |
pcauchy()
|
stats | cauchy | The Cauchy Distribution |
pchisq()
|
stats | chi2tail() | Chi-square probability |
pexp()
|
stats | exponential | The Exponential Distribution |
pf()
|
stats | F | The F Distribution |
pgamma()
|
stats | gammap | The Gamma Distribution |
phyper()
|
stats | hypergeometric | The Hypergeometric Distribution |
plogis()
|
stats | predictnl | The Logistic Distribution |
pnbinom()
|
stats | nbinomial | The Negative Binomial Distribution |
pnorm()
|
stats | normal() | Normal cumulative probability |
poisson()
|
stats | glm | Family Objects for Models |
poisson.test()
|
stats | stir | Exact Poisson tests |
poly()
|
stats | Polynomial terms for a model | |
power.prop.test()
|
stats | power | Power Calculations for Two-Sample Test for Proportions |
power.t.test()
|
stats | power twomeans | Power and sample size for a t test |
ppoints()
|
stats | quantile | Ordinates for Probability Plotting |
ppois()
|
stats | poisson | The Poisson Distribution |
prcomp()
|
stats | Principal components | |
predict()
|
stats | Predictions from a model | |
princomp()
|
stats | pcamat | Principal Components Analysis |
promax()
|
stats | rotate | Rotation Methods for Factor Analysis |
prop.test()
|
stats | Test of a proportion | |
prop.trend.test()
|
stats | nptrend | Test for trend in proportions |
pt()
|
stats | ttail() | t-distribution probability |
ptukey()
|
stats | tukeyprob | The Studentized Range Distribution |
pweibull()
|
stats | weibull | The Weibull Distribution |
qbeta()
|
stats | invibeta | The Beta Distribution |
qcauchy()
|
stats | invcauchy | The Cauchy Distribution |
qchisq()
|
stats | qchi | The (non-central) Chi-Squared Distribution |
qexp()
|
stats | invexponential | The Exponential Distribution |
qf()
|
stats | invF | The F Distribution |
qgamma()
|
stats | invgammap | The Gamma Distribution |
qlogis()
|
stats | invlogistic | The Logistic Distribution |
qnorm()
|
stats | invnormal() | Normal quantile |
qqplot()
|
stats | qqplot | Quantile-Quantile Plots |
qt()
|
stats | invt | The Student t Distribution |
qtukey()
|
stats | invtukeyprob | The Studentized Range Distribution |
quantile()
|
stats | pctile | Quantiles |
quasibinomial()
|
stats | Binomial family that allows survey weights | |
quasipoisson()
|
stats | svy | Family Objects for Models |
qweibull()
|
stats | invweibull | The Weibull Distribution |
rbeta()
|
stats | rbeta | The Beta Distribution |
rbinom()
|
stats | rbinomial() | Binomial random numbers |
rcauchy()
|
stats | rcauchy | The Cauchy Distribution |
rchisq()
|
stats | rchi2 | The (non-central) Chi-Squared Distribution |
relevel()
|
stats | Choose the base category of a factor | |
reshape()
|
stats | icc | Reshape Grouped Data |
residuals()
|
stats | predict, residuals | Model residuals |
rexp()
|
stats | rexponential | The Exponential Distribution |
rgamma()
|
stats | rgamma | The Gamma Distribution |
rhyper()
|
stats | rhypergeometric | The Hypergeometric Distribution |
rlogis()
|
stats | rlogistic | The Logistic Distribution |
rnbinom()
|
stats | rnbinomial | The Negative Binomial Distribution |
rnorm()
|
stats | Normal random numbers | |
rpois()
|
stats | rpoisson | The Poisson Distribution |
rstandard()
|
stats | predict | Regression Deletion Diagnostics |
rstudent()
|
stats | predict | Regression Deletion Diagnostics |
rt()
|
stats | rt | The Student t Distribution |
runif()
|
stats | Uniform random numbers | |
runmed()
|
stats | tssmooth | Running Medians -- Robust Scatter Plot Smoothing |
rweibull()
|
stats | rweibull | The Weibull Distribution |
sd()
|
stats | Standard deviation | |
setNames()
|
stats | labmask | Set the Names in an Object |
shapiro.test()
|
stats | Shapiro-Wilk normality test | |
sigma()
|
stats | estat | Extract Residual Standard Deviation 'Sigma' |
spectrum()
|
stats | pergram | Spectral Density Estimation |
step()
|
stats | stepwise | Stepwise model selection |
t.test()
|
stats | t test and confidence interval of a mean | |
ts()
|
stats | tsset | Time-series object |
uniroot()
|
stats | ciwidth | One Dimensional Root (Zero) Finding |
update()
|
stats | regress | Refit a model with changes |
var()
|
stats | summarize, detail | Variance |
var.test()
|
stats | sdtest | F test of equal variances |
varimax()
|
stats | rotate | Rotation Methods for Factor Analysis |
vcov()
|
stats | Variance-covariance matrix of a model | |
weighted.mean()
|
stats | summarize [aweight = w] | Weighted mean |
wilcox.test()
|
stats | Wilcoxon rank-sum or signed-rank test | |
xtabs()
|
stats | tabulate x1 x2 | Cross-tabulation from a formula |
stri_reverse()
|
stringi | ustrreverse | Reverse Each String |
stri_trans_nfc()
|
stringi | ustrnormalize | Perform or Check For Unicode Normalization |
stri_trans_nfkc()
|
stringi | ustrnormalize | Perform or Check For Unicode Normalization |
fixed()
|
stringr | Match text literally rather than as a regular expression | |
regex()
|
stringr | Regular expression with options such as ignore_case | |
str_c()
|
stringr | generate s = a + b | Join strings |
str_count()
|
stringr | Count matches in a string | |
str_detect()
|
stringr | Whether a string contains a pattern | |
str_dup()
|
stringr | "-" * 10 | Repeat a string |
str_ends()
|
stringr | substr() | Whether a string ends with a pattern |
str_extract()
|
stringr | Extract the matching text | |
str_extract_all()
|
stringr | ustrregexs() | Extract every match |
str_flatten()
|
stringr | levelsof, separate() | Collapse a vector into one string |
str_glue()
|
stringr | display "`x'" | Fill a text template |
str_length()
|
stringr | Number of characters | |
str_locate()
|
stringr | strpos() | Position of a match |
str_match()
|
stringr | regexs() | Extract the groups of a regular expression |
str_pad()
|
stringr | string(x, "%05.0f") | Pad a string to a fixed width |
str_remove()
|
stringr | subinstr() | Remove the first match |
str_remove_all()
|
stringr | subinstr() | Remove every match |
str_replace()
|
stringr | Replace the first match | |
str_replace_all()
|
stringr | Replace every match | |
str_split()
|
stringr | split | Split strings into pieces |
str_squish()
|
stringr | Trim spaces and collapse repeated spaces | |
str_starts()
|
stringr | substr() | Whether a string starts with a pattern |
str_sub()
|
stringr | Part of a string by position | |
str_subset()
|
stringr | keep if regexm() | Keep the strings that match |
str_to_lower()
|
stringr | Lower case | |
str_to_sentence()
|
stringr | strproper() | Sentence case |
str_to_title()
|
stringr | Title case | |
str_to_upper()
|
stringr | Upper case | |
str_trim()
|
stringr | Remove leading and trailing spaces | |
str_trunc()
|
stringr | abbrev() | Shorten strings to a width |
str_wrap()
|
stringr | display | Wrap text into lines |
word()
|
stringr | Extract words from a sentence | |
as.svrepdesign()
|
survey | svyset | Convert a survey design to use replicate weights |
cv()
|
survey | estat | Summary statistics for sample surveys |
deff()
|
survey | estat | Summary statistics for sample surveys |
degf()
|
survey | svydescribe | Contingency tables for survey data |
postStratify()
|
survey | svyset | Post-stratify a survey |
rake()
|
survey | svyset | Raking of replicate weight design |
svyby()
|
survey | svy | Survey statistics on subsets |
svychisq()
|
survey | svy | Contingency tables for survey data |
svyciprop()
|
survey | svy | Confidence intervals for proportions |
svydesign()
|
survey | svyset | Declare a survey design (survey package) |
svyglm()
|
survey | Survey-weighted regression | |
svymean()
|
survey | svy: mean | Survey-weighted mean (survey package) |
svyratio()
|
survey | svy | Ratio estimation |
svytable()
|
survey | svy: tabulate | Survey-weighted table |
svytotal()
|
survey | svy | Summary statistics for sample surveys |
Surv()
|
survival | Survival-time outcome for a model | |
basehaz()
|
survival | predict | Alias for the survfit function |
clogit()
|
survival | Conditional logit | |
concordance()
|
survival | estat | Compute the concordance statistic for data or a model |
cox.zph()
|
survival | estat | Test the Proportional Hazards Assumption of a Cox Regression |
coxph()
|
survival | Cox proportional hazards model | |
finegray()
|
survival | stcrreg | Create data for a Fine-Gray model |
frailty()
|
survival | stcox | Random effects terms |
strata()
|
survival | Stratum term in a survival model formula | |
survSplit()
|
survival | stsplit | Split a survival data set at specified times |
survdiff()
|
survival | Log-rank test | |
survfit()
|
survival | Kaplan-Meier survival curves | |
survreg()
|
survival | Parametric survival model | |
add_row()
|
tibble | set obs | Add rows to a table |
as_tibble()
|
tibble | Convert to a tibble | |
rownames_to_column()
|
tibble | xpose | Turn row names into a column |
tibble()
|
tibble | Create a data frame (tibble) | |
tribble()
|
tibble | input | Type a small table row by row |
complete()
|
tidyr | Add rows for missing combinations of values | |
crossing()
|
tidyr | cross | All combinations, sorted and unique |
drop_na()
|
tidyr | drop if missing(x) | Drop rows with missing values |
expand()
|
tidyr | fillin | All combinations of values, dropping other columns |
expand_grid()
|
tidyr | cross | Table of every combination of given values |
fill()
|
tidyr | Fill missing values with the previous or next value | |
full_seq()
|
tidyr | tsfill | Complete sequence of values |
nest()
|
tidyr | by | Nest rows into list-columns, one row per group |
pivot_longer()
|
tidyr | Reshape from wide to long | |
pivot_wider()
|
tidyr | Reshape from long to wide | |
replace_na()
|
tidyr | replace x = 0 if missing(x) | Replace missing values |
separate_longer_delim()
|
tidyr | split | Split text into rows |
separate_wider_delim()
|
tidyr | Split one text column into several | |
separate_wider_position()
|
tidyr | substr() | Split text into columns by position |
uncount()
|
tidyr | Repeat each row a given number of times | |
unite()
|
tidyr | egen concat() | Join columns into one |
unnest()
|
tidyr | expand | Expand list-columns back into rows |
as_character()
|
tidystata | decode | Alias of decode() |
as_dummy()
|
tidystata | Dummy variables for every category | |
as_numeric()
|
tidystata | destring | Alias of destring() |
assert()
|
tidystata | Stop and count the rows where a condition fails | |
browse()
|
tidystata | View data in a spreadsheet window | |
capture()
|
tidystata | Return the result or report a caught error and return NULL; quiet suppresses warnings and messages | |
codebook()
|
tidystata | Describe every variable: type, label, counts and values | |
corr()
|
tidystata | Complete-case Pearson correlations | |
cut_quantile()
|
tidystata | xtile | Alias of xtile() |
decode()
|
tidystata | Convert to text, using value labels for labelled data | |
destring()
|
tidystata | Convert to numbers, dropping value labels | |
ds()
|
tidystata | List variable names | |
duplicates_drop()
|
tidystata | Drop duplicated rows, keeping the first | |
duplicates_list()
|
tidystata | List duplicated rows | |
duplicates_report()
|
tidystata | Count duplicated rows | |
duplicates_tag()
|
tidystata | Mark duplicated rows | |
findit()
|
tidystata | Find the R equivalent of a Stata command | |
fre()
|
tidystata | Frequency table with a total row | |
fre2()
|
tidystata | tabulate | Two-way cross-tabulation with row and column totals |
is_first()
|
tidystata | Mark the first row of each group | |
isid()
|
tidystata | Check that variables uniquely identify the rows | |
misstable()
|
tidystata | Missing values per variable, or missing-value patterns | |
mvdecode()
|
tidystata | Turn given codes into missing values | |
mvencode()
|
tidystata | Replace missing values with a code | |
na_if_value()
|
tidystata | mvdecode | Alias of mvdecode() |
pc()
|
tidystata | Percentage of the total | |
pct()
|
tidystata | egen pc() | Alias of pc() |
print_all()
|
tidystata | Print every row and column | |
pwcorr()
|
tidystata | Pairwise correlations with counts and p-values | |
row_max()
|
tidystata | Maximum across variables in each row | |
row_mean()
|
tidystata | Mean across variables in each row | |
row_median()
|
tidystata | Median across variables in each row | |
row_min()
|
tidystata | Minimum across variables in each row | |
row_miss()
|
tidystata | Number of missing values in each row | |
row_non_miss()
|
tidystata | Number of observed values in each row | |
row_nvals()
|
tidystata | Number of distinct values in each row, ignoring missing values | |
row_sd()
|
tidystata | Standard deviation across variables in each row | |
row_sum()
|
tidystata | Sum across variables in each row | |
row_unique()
|
tidystata | egen rownvals() | Number of distinct values in each row, counting missing as one |
set_seed()
|
tidystata | Set the random seed, alone or at the end of a pipe | |
stata_diff()
|
tidystata | Difference from the previous period, respecting time gaps | |
stata_lag()
|
tidystata | Value from an earlier period, respecting time gaps | |
stata_lead()
|
tidystata | Value from a later period, respecting time gaps | |
stata_merge()
|
tidystata | Merge two tables and report matches, like Stata's merge | |
std()
|
tidystata | Standardise to mean 0 and standard deviation 1 | |
summ()
|
tidystata | Summary statistics for variables | |
tab()
|
tidystata | Frequency table | |
tab1()
|
tidystata | One frequency table per variable | |
tab2()
|
tidystata | Two-way cross-tabulation, or every pairwise table | |
tab_gen()
|
tidystata | tabulate, generate() | Alias of as_dummy() |
tabstat()
|
tidystata | Chosen statistics for variables, optionally by group | |
timer()
|
tidystata | Time how long code takes | |
tostring()
|
tidystata | Convert to text, keeping codes rather than value labels | |
value_if_na()
|
tidystata | mvencode | Alias of mvencode() |
variables()
|
tidystata | List variables with their types and labels | |
variables_search()
|
tidystata | Find variables by name or label | |
varlist()
|
tidystata | Select variables with Stata wildcards such as x* | |
xtile()
|
tidystata | Quantile groups, following Stata's xtile | |
md5sum()
|
tools | checksum | Compute MD5 Checksums |
garch()
|
tseries | arch | Fit GARCH Models to Time Series |
as_tsibble()
|
tsibble | Declare time-series or panel data | |
fill_gaps()
|
tsibble | Add rows for missing time points | |
yearmonth()
|
tsibble | Monthly period | |
yearquarter()
|
tsibble | Quarterly period | |
ca.jo()
|
urca | vecrank | Johansen Procedure for VAR |
cajorls()
|
urca | vec | OLS regression of VECM |
ur.df()
|
urca | dfuller | Augmented-Dickey-Fuller Unit Root Test |
ur.ers()
|
urca | dfgls | Elliott, Rothenberg and Stock Unit Root Test |
ur.pp()
|
urca | pperron | Phillips and Perron Unit Root Test |
View()
|
utils | browse | Open the data viewer |
capture.output()
|
utils | dataex | Send Output to a Character String or File |
combn()
|
utils | tab2 | Generate All Combinations of n Elements, Taken m at a Time |
data()
|
utils | Load a built-in example dataset | |
getAnywhere()
|
utils | Find where a function is defined | |
glob2rx()
|
utils | Turn a wildcard pattern into a regular expression | |
head()
|
utils | First rows | |
help()
|
utils | Open a help page | |
help.search()
|
utils | Search all installed help pages | |
install.packages()
|
utils | Install a package from CRAN | |
object.size()
|
utils | memory | Report the Space Allocated for an Object |
packageVersion()
|
utils | ftools | Package Description |
read.csv()
|
utils | import delimited | Read a CSV file (base R) |
read.delim()
|
utils | import | Data Input |
read.fwf()
|
utils | infix | Read Fixed Width Format Files |
read.table()
|
utils | infile | Data Input |
sessionInfo()
|
utils | about | Collect Information About the Current R Session |
str()
|
utils | Compact view of an object's structure | |
tail()
|
utils | Last rows | |
unzip()
|
utils | unzipfile | Extract or List Zip Archives |
update.packages()
|
utils | Update installed packages | |
write.csv()
|
utils | export delimited | Write a CSV file (base R) |
write.table()
|
utils | outfile | Data Output |
write_xlsx()
|
writexl | Write an Excel file | |
zipr()
|
zip | zipfile | Compress Files into 'zip' Archives |
na.locf()
|
zoo | stfill | Last Observation Carried Forward |
rollapply()
|
zoo | rolling | Apply Rolling Functions |