Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Implemenation Stata 11 ado.file

From   "Catharina Klepsch" <>
Subject   st: Implemenation Stata 11 ado.file
Date   Tue, 20 Jul 2010 12:02:41 +0200

Dear Stata Users

Below you will find an extract of an ado.file(xttest) which I would like to implement(Stata Version 11.0), but there are still some problems I could not solve:

I would like to insert an option, which allows to lag the exogenous variables. If I do xttest y l.x1 l.x2 I get a problem with step 3, because the mean variables should be calculated from the x (without lag)! I tried several things but I really did not find an appropriate solution…

Furthermore is it possible to add an option to the xttest program to insert yeardummies but without calculating the lags and means of the yeardummies? A solution is not to insert yeardummies at Step 5 (xttobit y x yeardummies), because the program should be applicable to different datasets

Step 5 does xttobit, with intm(gh) ll(0) ul(1), but is it also possible to insert an option where  the ll and ul specifications are used as the person using xttest wishes?

For any comments I would be very grateful!
Best regards Catharina

capture program drop xttest
program define xttest , eclass sortpreserve byable(recall)

version 11.0
syntax varlist(ts) [if] [in]

    *** Split varlist into dependent and independent variables:
        tokenize `varlist'
        local regressand `1'
        macro shift
        local regressors `*'

      *** Check if the dataset is tsset:
        qui tsset
        local panelvar `r(panelvar)'
        local timevar  `r(timevar)'
        *generate year Dummyvariables
        *capture tabulate `timevar', gen (yearDum)
                if "`panelvar'"=="" {
                di as err "must specify panelvar and timevar; use xtset"
                exit 459
*** generate lag variables for the endogenous variable
foreach x of local regressand {
by `panelvar': generate lag`x' = `x'[_n-1]

*** generate lag variables for the exogenous variables
foreach x of local regressors{
capture quietly by `panelvar': generate lag`x' = `x'[_n-1]

***generate for all independent Variables the mean, which will then be defined with zAvg*
foreach x of local regressors{
by `panelvar', sort: egen zAvg`x' = mean(`x')

***generate yi0 (being the first value of the dependent variable for each panelvar):
foreach x of local regressand {
by `panelvar': generate yi0 = `regressand'[1]

***Program for random sampling

local n 1  // shows the number of replications

forvalues i= 1(1) `n' {
local n = `n'+1

bsample, cluster (`panelvar') idcluster(newpanelvar)

tokenize `varlist'
local regressand `1'

xttobit `regressand' lag* `regressors' zAvg* yi0 , intm(gh) ll(0) ul(1)


GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive!
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index