You are on page 1of 16

TAMILNADU AGRICULTURAL UNIVERSITY

CENTRE FOR AGRICULTURAL AND RURAL DEVELOPMENT


STUDIES
DEPARTMENT OF AGRICULTURAL ECONOMICS

BASIC GRAPHICAL VISUALIZATION USING STATA


STATISTICAL FUNCTIONS AND SYNTAX IN STATA
LOGICAL FUNCTIONS IN STATA

SARVESH JP
2022504011
I M.Sc., Agricultural Economics
B A S I C G R A P H I C A L V I S U A L I Z AT I O N I N S TATA

• Scatter Plot - scatter y_variable x_variable


• Line Plot - line y_variable x_variable
• Bar Chart (Clustered) - graph bar (mean) y_variable, over(x_variable)
• Bar Chart (Stacked)- graph bar (mean) y_variable, over(x_variable) stack
• Histogram - histogram variable_name
• Box Plot - graph box variable_name
• Pie Chart - graph pie variable_name
• Area Plot - area y_variable x_variable
• Time Series Plot - tsline variable_name
• Dot Plot - tsline variable_name
• Violin Plot - twoway violin y_variable x_variable
• Heatmap - graph heatmap y_variable x_variable
• Bubble Plot - twoway (scatter y_variable x_variable size_variable)
• Quantile-Quantile (Q-Q) Plot - qqplot variable_name
• Probability Plot - probplot variable_name
TO P S TAT I S T I C A L F U N C T I O N S I N S TATA

 summarize: Provides summary statistics for numeric variables.

 tabulate: Creates frequency tables for categorical variables.

 regress: Performs linear regression analysis.

 logit and probit: Perform logistic and probit regression, respectively.

 anova: Performs analysis of variance (ANOVA).

 manova: Performs multivariate analysis of variance (MANOVA).

 tsset: Defines the time variable for time series data.

 sts and stcox: Perform survival analysis.

 ttest: Performs t-tests.

 chi2: Performs chi-squared tests.

 wilcoxon: Performs Wilcoxon signed-rank tests.

 ranksum: Performs Mann-Whitney U tests.


 xtreg: Performs fixed or random effects panel data regression.

 xtsum: Provides summary statistics for panel data.

 scatter: Creates scatterplots.

 histogram: Generates histograms.

 graph twoway: Allows customization of graphs.

 correlate: Calculates correlation coefficients.

 pca: Performs principal component analysis.

 cluster: Performs cluster analysis.

 cnreg: Fits censored normal regression models.

 poisson: Performs Poisson regression analysis for count data.

 xtfrontier: Estimates stochastic frontier models for panel data.

 mvreg: Fits multivariate regression models.

 outlier: Detects outliers in data.

• mvmeta: Performs meta-analysis of multiple datasets


C O M M O N LY U S E D S Y N TA X I N S TATA

 use filename [, clear]: Opens a dataset for analysis.


 describe [varlist]: Provides information about the dataset.
 summarize varname: Calculates summary statistics for a variable.
 tabulate varname [if] [in], [options]: Creates frequency tables.
 regress depvar indepvars [if] [in] [, options]: Performs linear regression analysis.

 logit depvar indepvars [if] [in] [, options]: Performs logistic regression analysis.
 probit depvar indepvars [if] [in] [, options]: Performs probit regression analysis.
 anova depvar indepvar [if] [in] [, options]: Conducts analysis of variance (ANOVA).
 manova depvars = indepvars [if] [in] [, options]: Conducts multivariate analysis of variance (MANOVA).
 tsset timevar: Defines the time variable for time series analysis.
 tsline varname: Creates time series line plots.

 pca varlist [, options]: Performs principal component analysis.


 cluster kmeans varlist, k(kvalue): Conducts k-means clustering analysis.
 logistic depvar indepvars [if] [in] [, options]: Fits logistic regression models.
 glm depvar indepvars [if] [in] [, options]: Fits generalized linear models.
 sts list: Lists survival data.
 sts graph: Generates survival probability plots.
 ttest varname == value [if] [in] [, options]: Performs t-tests.
 chi2 varname == value [if] [in] [, options]: Performs chi-squared tests.
 wilcoxon varname = value [if] [in] [, options]: Performs Wilcoxon signed-rank
tests.
 ranksum varname, by(groupingvar) [if] [in] [, options]: Performs Mann-Whitney
U tests.
 xtreg depvar indepvars i.panelvar [, options]: Performs panel data regression.
 xtsum varname: Provides summary statistics for panel data.
 scatter xvar yvar [if] [in] [, options]: Creates scatterplots.
 histogram varname [, options]: Generates histograms.
 keep varlist: Keeps specified variables and discards others.
 drop varlist: Drops specified variables from the dataset.
 rename oldvar newvar: Renames variables.
 order varlist, first/last: Reorders variables.
 cluster varname, [options]: Specifies clustering for robust standard errors.
 prop varname, [options]: Computes proportions and tests for equality.
 stcox indepvars [if] [in] [, options]: Fits Cox proportional hazards models.
C O M M O N L O G I C A L F U N C T I O N S O F S TATA

 ==: Equal to
 !=: Not equal to
 >: Greater than
 <: Less than
 >=: Greater than or equal to
 <=: Less than or equal to
 &: Logical AND
 |: Logical OR
 ~: Logical NOT
 if condition: Used in many STATA commands to subset data based on logical conditions.
 inlist(valuelist, varname): Checks if a value is in a list of values. Returns 1 if the value is found, 0 otherwise.
 missing(varname): Checks if a value in a variable is missing (.) and returns 1 if it is, 0 otherwise.
 egen allvar = all(condition, varlist): Checks if all values in varlist meet the specified condition and returns 1
if true, 0 otherwise.

• egen countvar = count(condition, varlist): Counts the number of values in varlist that meet the specified
condition.
• egen anyvar = any(condition, varlist):
 egen allvar = all(condition, varlist): Checks if all values in varlist meet the specified
condition and returns 1 if true, 0 otherwise.
 egen countvar = count(condition, varlist): Counts the number of values in varlist that
meet the specified condition.
 egen inlistvar = inlist(value, varlist): Checks if a value is in a list of values. Returns 1 if
the value is found, 0 otherwise.
 egen nvalsvar = nvals(varlist): Counts the number of distinct values in a list of variables.
 egen seqvar = seq(), from(start) to(end) [by(increment)]: Generates a sequence of
numbers.

 egen rankvar = rank(varlist): Computes the rank of values.


 egen groupvar = group(groupvar): Creates groups based on a variable.
 egen tagvar = tag(varlist): Generates tag variables.
 egen totalvar = total(varlist): Computes the sum of variables.
 egen meanvar = mean(varlist): Calculates the mean of variables.
 egen medianvar = median(varlist): Computes the median of variables.
 egen minvar = min(varlist): Calculates the minimum of variables.
 egen maxvar = max(varlist): Computes the maximum of variables.

• egen sdvar = sd(varlist): Calculates the standard deviation of variables.


R E F E R E N C E S A N D F U RT H E R R E A D I N G S

• https://blog.stata.com/

• https://www.stata-journal.com/subscription/

• https://www.stata.com/bookstore/
THANKS FOR YOUR ATTENTION

You might also like