Statalist The Stata Listserver


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

st: RE: Stata 9 --> sepov is not recongnizing the svyset variables. Any ideas?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Stata 9 --> sepov is not recongnizing the svyset variables. Any ideas?
Date   Thu, 19 Oct 2006 18:04:31 +0100

-sepov- has this provenance: 

STB-51  sg117 . . Robust std errors for Foster-Greer-Thorbecke poverty indices
        (help sepov if installed) . . . . . . . .  D. Jolliffe and A. Semykina
        9/99    pp.34--36; STB Reprints Vol 9, pp.200--203
        provides estimates of standard errors for the Foster-Greer-
        Thorbecke class of poverty indices; handles complex survey
        designs including stratification and multi-stages

As such, the problem may lie in the fact that the program authors 
were not aware of changes to Stata to be introduced in 2005. 

Looking at -sepov-, I see this code: 

------------------------------------- sepov.ado
* version 1.1.0  27/09/99	sepov.ado           [STB-51: sg117]
* Dean Jolliffe, Anastassia Semykina

#delimit;

program define sepov;
	version 5.0;
	local varlist "required existing min(1)";
	local weight "pweight iweight";
	local if "optional";
	local in "optional";
	local options "Povline(string) Alfa(real 0) *";
	parse "`*'";
	parse "`varlist'", parse(" ");
	tempvar fgt0 fgt1 fgt2 fgta;

	if `alfa'>=0 {;
	  while "`1'"~="" {;   
           local lbl : variable label `1';
           if "`lbl'"=="" { local lbl "(unlabeled)" };
	   quietly {;
	      gen `fgt0'=0;
	      replace `fgt0'=1 if `1'<`povline';
	      gen `fgt1'=0;
	      replace `fgt1'=1-`1'/`povline' if `1'<`povline';
	      gen `fgt2'=0;
	      replace `fgt2'=(1-`1'/`povline')^2 if `1'<`povline';
	   };

	   if `alfa'==0|`alfa'==1|`alfa'==2 {;
	      quietly svymean `fgt0' `fgt1' `fgt2' `if' `in' [`weight'`exp'], `options';
	      di in gre _n(2) "Poverty measures for the variable `1': `lbl'";
	      rename `fgt0' p0;
	      rename `fgt1' p1;
	      rename `fgt2' p2;
	      svymean p0 p1 p2 `if' `in' [`weight'`exp'], `options';
	      drop p0 p1 p2;
	   };

	   else {;
	      quietly {;
	        gen `fgta'=0;
	        replace `fgta'=(1-`1'/`povline')^`alfa' if `1'<`povline';
	      svymean `fgt0' `fgt1' `fgt2' `fgta' `if' `in' [`weight'`exp'], `options';
	      };
	      di in gre _n(2) "Poverty measures for the variable `1': `lbl'";
	      rename `fgt0' p0;
	      rename `fgt1' p1;
	      rename `fgt2' p2;
	      rename `fgta' p`alfa';
	      svymean p0 p1 p2 p`alfa'  `if' `in' [`weight'`exp'], `options';
	      drop p0 p1 p2 p`alfa';
	   };

	   macro shift;
	  };
	};

	if `alfa'<0 {;
	   di in red "Negative alfa is not allowed";
	};
end;
-----------------------------------------------------

Now there are some things here that we can omit because they 
are repeated or unnecessary, or at least appear to be,
and some things that can now be written more concisely 
given changes in Stata. I also changed the spelling of 
-alfa- to -alpha-. 

Here is an untested rendering: 

--------------------------------------- 
*! sepov2 NJC 19 Oct 2006 
* version 1.1.0  27/09/99	sepov.ado           [STB-51: sg117]
* Dean Jolliffe, Anastassia Semykina
program sepov2
	version 9    
	syntax varlist [pweight iweight] [if] [in] [, /// 
	Povline(string) Alpha(real 0) * ] 

	if `alpha' < 0 { 
		di as err "negative alpha is not allowed"
		exit 198 
	}

	foreach v of local varlist { 
        	local lbl `": `: variable label `v''"' 
		gen p0 = `v' < `povline' 
		gen p1 = cond(p0, 1 - `v'/`povline', 0) 
		gen p2 = cond(p0, (1 - `v'/`povline')^2, 0) 
		di as txt _n(2) "Poverty measures for `v'`lbl'"

		if !inlist(`alpha', 0, 1, 2) {
			gen p`alpha'= cond(p0, (1-`v'/`povline')^`alpha', 0) 
			local svyvars p0 p1 p2 p`alpha' 
		}
		else local svyvars p0 p1 p2 

		svymean `svyvars' `if' `in' [`weight'`exp'], `options'
		drop `svyvars' 
	}
end
------------------------------- 

Now my guess is that changing the call here to -svymean- 
to -svy: mean- may help you and should do no harm. 

If that does no good, I have no more ideas to follow with. 

A misfeature of -sepov- not directly documented in its help
is that it is assumed that the user does not possess variables
p0, p1, p2, p`alfa'. I have not fixed the corresponding problem
in -sepov2- above. 

Nick 
[email protected] 

Anna Gueorguieva
  
> Switching to stata 9 problem: I need your help to figure out 
> what is going wrong now that I am using stata 9 (just 
> switched two weeks ago, yay!!!) with my old code.
>  
> Basically, the command sepov which estimates poverty indices 
> taking into account survey design effects does not preserve 
> the strata and the psu after svyset (and in 8 it was no problem). 
>  
> Here is what I get:
>  
>  
> *FIRST stata is reading correctly my variables for the survey set up
>  
> svyset [pw=repweight_s], strata(strata_unique)  psu(psu) fpc(fpc)|| _n
>       pweight: repweight_s
>           VCE: linearized
>      Strata 1: strata_unique
>          SU 1: psu
>         FPC 1: fpc
>      Strata 2: <one>
>          SU 2: <observations>
>         FPC 2: <zero>
> . 
> *WHEN I CALL THE COMMAND sepov, however, it does not show strata
> . 
> . sepov real_totc_per_ae [pw=repweight_s], p(povline_m) subpop(wave2)
> Poverty measures for the variable real_totc_per_ae: (unlabeled)
> Survey mean estimation
> pweight:  repweight_s                             Number of 
> obs    =      4785
> Strata:   <one>                                   Number of 
> strata =         1
> PSU:      <observations>                          Number of 
> PSUs   =      4785
> Subpop.:  ==1                                     Population 
> size  = 3639689.6
> --------------------------------------------------------------
> ----------------
>     Mean |   Estimate    Std. Err.   [95% Conf. Interval]        Deff
> ---------+----------------------------------------------------
> ----------------
>       p0 |   .4513918    .0154961    .4210124    .4817712    2.318254
>       p1 |   .1225897    .0053558    .1120899    .1330895    2.152049
>       p2 |   .0468943    .0026791    .0416422    .0521465    1.932348
> --------------------------------------------------------------
> ----------------
>  
> Has anybody dealt with this yet? How do I fix this?
>  
> Thank you in advance for your time and support!

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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