Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error: command lassoShooting is unrecognized

    I want to run following code, but it return error: command lassoShooting is unrecognized. I would appreciate if someone can help me.

    # delimit ;
    set more off;

    clear all ;
    set maxvar 20000 ;
    set matsize 11000 ;

    capture log close ;
    log using JEPInstitutions.txt , replace text ;

    insheet using /Users/Public/acemoglu_col_notext.txt ;

    gen lnmort = log(mort) ;
    gen lat2 = latitude^2 ;
    gen lat3 = latitude^3 ;
    gen lat_c08 = (latitude - .08)*(latitude - .08 > 0) ;
    gen lat2_c08 = ((latitude - .08)*(latitude - .08 > 0))^2 ;
    gen lat3_c08 = ((latitude - .08)*(latitude - .08 > 0))^3 ;
    gen lat_c16 = (latitude - .16)*(latitude - .16 > 0) ;
    gen lat2_c16 = ((latitude - .16)*(latitude - .16 > 0))^2 ;
    gen lat3_c16 = ((latitude - .16)*(latitude - .16 > 0))^3 ;
    gen lat_c24 = (latitude - .24)*(latitude - .24 > 0) ;
    gen lat2_c24 = ((latitude - .24)*(latitude - .24 > 0))^2 ;
    gen lat3_c24 = ((latitude - .24)*(latitude - .24 > 0))^3 ;

    local controls = "africa asia namer samer latitude lat2 lat3
    lat_c08 lat2_c08 lat3_c08 lat_c16 lat2_c16 lat3_c16
    lat_c24 lat2_c24 lat3_c24" ;

    * Baseline with just latitude ;
    ivreg gdp (exprop = lnmort) latitude , robust first ;

    * Include all controls ;
    * ivreg gdp (exprop = lnmort) `controls' , robust first;
    * Note: The results from the all controls IV as above differ from MATLAB... ;
    * Stata is probably doing some regularization internally since you get the ;
    * same result if you do the IV "by hand" in Stata as you do in MATLAB. This ;
    * discrepancy may be worth further exploration. We'll go with MATLAB ;
    * results for now. ;
    quietly reg gdp `controls' ;
    predict rgdp , resid ;
    quietly reg exprop `controls' ;
    predict rexp , resid ;
    quietly reg lnmort `controls' ;
    predict rmor , resid ;
    ivreg rgdp (rexp = rmor) , robust first noconstant;
    * Need to scale standard error by sqrt(63/(64-18)) to account for partialing ;
    * out the controls to get things to line up with usual degrees of freedom ;
    * correction done in Stata (and in MATLAB) for robust standard errors. ;
    scalar se_all = .684*sqrt(63/(64-18)) ;
    scalar list se_all ;

    * Variable selection ;
    * Outcome reduced form ;
    lassoShooting gdp `controls' , lasiter(100) verbose(0) fdisplay(0) ;
    local gdpSel `r(selected)' ;
    di "`gdpSel'" ;

    * Endogenous variable reduced form ;
    lassoShooting exprop `controls' , lasiter(100) verbose(0) fdisplay(0) ;
    local expSel `r(selected)' ;
    di "`expSel'" ;

    * Instrument reduced form ;
    lassoShooting lnmort `controls' , lasiter(100) verbose(0) fdisplay(0) ;
    local morSel `r(selected)' ;
    di "`morSel'" ;

    * Get union of selected instruments ;
    local xTS : list gdpSel | expSel ;
    local xTS : list xTS | morSel ;

    * Run final IV regression including selected controls ;
    ivreg gdp (exprop = lnmort) `xTS' , robust first ;

    log close ;

  • #2
    Welcome to Statalist.

    There is no lassoShooting command built into Stata, so apparently the command is community contributed and needs to be installed in order to run it. That's not usually a problem, however
    Code:
    search lassoShooting
    finds no matches. And searching the web turns up an R package, but nothing related to Stata.

    Can you give us a link to a description of the package? Preferably one not behind a paywall.

    Comment


    • #3
      In internet there are different codes but they are not working. Example please see in attachment
      Attached Files

      Comment


      • #4
        Have you put the command in a folder where Stata can find it? Commands are usually not recognized if they are in a folder that Stata does not look for commands.

        Comment


        • #5
          I checked in different directory no result same. But where Stata can read the files exactly?

          Comment


          • #6
            Start by running the adopath command. It will tell you the directories in which Stata looks for ado files (and their help files and other pieces of Stata).
            Code:
            . adopath
              [1]  (BASE)      "/Applications/Stata/ado/base/"
              [2]  (SITE)      "/Applications/Stata/ado/site/"
              [3]              "."
             [4]  (PERSONAL)  "/Users/lisowskiw/Library/Application Support/Stata/ado/personal/"
              [5]  (PLUS)      "/Users/lisowskiw/Library/Application Support/Stata/ado/plus/"
              [6]  (OLDPLACE)  "~/ado/"
            The BASE and SITE directories are not writable by you and in any event should not be used by you. The current directory (".") means that Stata will look in Stata's "working directory" - but you don't want to have to copy your ado file to every directory you need it in. The PLUS directory is used by Stata commands (like ssc and net) that install ado files over the internet - it is best not to install things into that directory yourself.

            The PERSONAL directory is where you should move lassoShooting.ado to. If it came with a help file (.hlp or .sthlp) you can move it there as well.

            Comment

            Working...
            X