GithubHelp home page GithubHelp logo

jadesiu / stata4econ Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fanwangecon/stata4econ

0.0 1.0 0.0 5.96 MB

Reusable Stata Code from Various Projects

Home Page: https://fanwangecon.github.io/stata4Econ/

License: MIT License

Stata 100.00%

stata4econ's Introduction

HitCount Star Fork Star

This is a work-in-progress website of sample Stata files, produced by Fan. Materials gathered from various projects in which STATA code is used. The goal of this repository is to make it easier to find/re-use codes produced for various projects.

STATA files are linked below by section. Various functions are stored in corresponding .do files. To use the files, clone the repository. Some files have examples/instructions created using Jupyter notebooks or STATA translator and are shown as HTML and PDF files. See here for Github set up.

From Fan's other repositories: For dynamic borrowing and savings problems, see Dynamic Asset Repository; For example R code, see R Panel Data Code, for example Matlab code, see Matlab Example Code; For intro econ with Matlab, see Intro Mathematics for Economists, and for intro stat with R, see Intro Statistics for Undergraduates. See here for all of Fan's public repositories.

Please contact FanWangEcon for issues or problems.

1. Regressions

1.1 All Purpose Regression Tool

  1. All Purpose N Columns M Panels Regression Structure
    • Code: DO | PDF Gen Tables Log | HTML Gen Tables Log
    • Output: PDF Table | HTML Table | DOC Table
    • A regression table has these ingredients: (1) regression method (2) LHS (3) RHS (to keep) (4) RHS (controls not to show in table) (5) conditions (6) regression options (7) row and column title and footnotes labeling
    • Specify regression table column and panel specific ingredients for all, none, any row or column subsets freely
    • Versatile structure that can test large sets of regression specifications

1.2 Various Examples

  1. Discrete Interactions: DO | HTML | PDF
    • Regression with interacted discrete regressors
    • core: regress + esttab

2. Generate Table

2.1 Multiple Regression Panels

  1. Multiple Panels: DO | Gen Table Log | PDF Table | TEX Table
    • Three panels, different regressors for each panel, different conditionings each column.
    • core: regres + esttab

2.2 Multiple Regression Panels with Interactions

  1. Continuous and Discrete Interactions: DO | Gen Table Log | PDF Table | TEX Table
    • Three panels, different regressors for each panel, different conditionings each column.
    • core: regres + esttab

2.3 Cross Tabulation

  1. Continuous and Discrete Interactions: DO | Gen Table Log | PDF Table | TEX Table
    • Three row categories, two interacting column categories, statistics for multiple variables
    • core: regres + estpost tabstat

3. Dataset Manipulation

3.1 Generate

  1. Generate Grouped Categorical Variable: DO | HTML | PDF
    • Reduce the number of categories for a categorical variable
    • core: recode turn (min/35 = 1 "Turn <35") ... (46/max = 5 "Turn > 45") (else =. ), gen(turn_m5); if inrange(turn, 31, 35), if inlist(turn, 46, 48, 51)

3.2 Summary

  1. Multiple Variables Jointly Nonmissing: DO | HTML | PDF
    • Find rows where there are no missing values for any variables in a list of variables and where certain conditionings are satisfied
    • core: egen valid = rownonmiss($svr_list) if $scd_bse $scd_one $scd_two

3.3 Random

  1. Drop Random Subset of Data: DO | HTML | PDF
    • Drop random subset of data for different variables
    • core: round((_n/_N) x it_drop_frac) == round(it_drop_frac x uniform())

4. Programming

4.1 Basic

  1. Local, Global and Scalar: DO | HTML | PDF
    • local, global and scalar as boolean controls
    • core: local bl_includereg1 = 1, if (`bl_includereg1'); global bl_includereg3 = 0, if ($bl_includereg3); scalar bl_includereg5 = 0, if (bl_includereg5);

4.2 Matrix

  1. Define and Slice Matrix: DO | HTML | PDF
    • matrix definition and slicing, get column and row names, replace matrix subset.
    • core: matrix + rownumb/colnumb + matrix mt_bl_estd = J(it_rowcnt, it_colcnt, bl_fillval) + mat_a[1..., colnumb(mat_a, "reg1")] + ...

5. Support

5.1 Logging

  1. LOG2HTML and Translator: DO | Translator PDF | SMCL Log PDF
    • translator to export console buffer to PDF, or to export log file to pdf; log2html to convert to html.
    • core: log2html + translate @Results

Please contact for issues or problems.

RepoSize CodeSize Language Release License

stata4econ's People

Contributors

fanwangecon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.