[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: AW: st: Eliminating patterns from Panel Data

From   Maarten buis <[email protected]>
To   [email protected]
Subject   RE: AW: st: Eliminating patterns from Panel Data
Date   Sun, 20 Jan 2008 19:54:12 +0000 (GMT)

--- Maarten buis <[email protected]> wrote:
> I am not particularly interested in making this program more
> generally available (e.g. through -ssc-), eventhough that is now
> trivially easy. The reason is that I don't think that this command is
> very useful. This way you can easily end up ignoring 90% or more of
> your data. All I wanted to show is that if you want a command you can
> easily make one yourself.

The example below illustrates that point. In the case of nlswork only
1.8% of all respondents was observed in all waves! So using only
complete units would discard 98.2% of all respondents. That does not
seem wise.

For the example to work you need to make the command -mkbalanced-
available as described in:

At the bottom I have added an update with with a version statement as
sugested by Nick and I also added a variable label for the generated

*----------- begin example -----------------
webuse nlswork, clear
mkbalanced, gen(balanced)
bys idcode (year) : gen first = _n == 1
sum balanced if first
*------------ end example ------------------

*--------- begin mkbalanced.ado------------------
*! version 1.0.2 MLB 20Jan2008
program define mkbalanced, sortpreserve
        version 9.1
	syntax, GENerate(name)
	confirm new var `generate'
	capture xtset
	if _rc == 459 {
		di as err ///
		"panel variable not set, use -xtset varname ...-"
	local panelvar "`r(panelvar)'"
	local timevar "`r(timevar)'"

	tempvar touse nvals
	gen byte `touse' = !missing(`timevar')

	qui levelsof `timevar'
	local t : word count `r(levels)'
	bys `panelvar' `timevar' `touse' : ///
          gen long `nvals' = _n == 1 if `touse'
	bys `panelvar' `touse' : ///
	    replace `nvals' = sum(`nvals') if `touse'
	bys `panelvar' `touse' : ///
	    gen byte `generate' = `nvals'[_N]== `t'
        label variable `generate' ///
        "whether or not a unit is completely observed"
*--------- end mkbalanced.ado------------------

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Sent from Yahoo! Mail - a smarter inbox

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index