Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: RE: Graph with point estimates and ci


From   "Scholes, Shaun" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: RE: Graph with point estimates and ci
Date   Thu, 26 Apr 2012 18:05:29 +0000

I have given this a try. The two sets of code should give the same results. 
Note however that I find it much easier to work with -svy:mean- rather than -svy:prop- but this requires your 
variable of interest to be coded 0/1. You would need to install Roger Newson's -parmest- (SJ, etc.).

clear
sysuse auto
gen subgroup = 0
replace subgroup=1 if _n>15
statsby _b _se, by(rep78) saving(R:\tot.dta,replace):proportion foreign
statsby _b _se, by(rep78) saving(R:\subgroup.dta,replace):proportion foreign if subgroup==1
clear
use R:\tot.dta
append using R:\subgroup.dta


clear
sysuse auto
gen subgroup = 0
replace subgroup=1 if _n>15
gen wgt=1
svyset [pweight=wgt]
parmby "svy: mean foreign,over(rep78)",saving("R:\tot.dta",replace) ev(_N _N_subp V_db) em(depvar) es(N) ylabel
parmby "svy,subpop(subgroup): mean foreign,over(rep78)",saving("R:\subgroup.dta",replace) ev(_N _N_subp V_db) em(depvar) es(N) ylabel
clear
use R:\tot.dta
append using R:\subgroup.dta

I may have misunderstood what you are trying to do but maybe this will help. 
Best wishes
Shaun


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: 26 April 2012 16:44
To: '[email protected]'
Subject: RE: st: RE: Graph with point estimates and ci

You could set up a loop with -foreach-. 

Various other approaches e.g. Roger Newson's -parmest- (SJ, etc.), or so I imagine. 

Nick 
[email protected] 


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Richard Moverare
Sent: 26 April 2012 16:36
To: [email protected]
Subject: Re: st: RE: Graph with point estimates and ci

Ok, is there some other way I can retrieve the point estimate and the
standard error from -svy: proportion- over years and get it into a
dataset of a similar kind?

Any help would be greatly appreciated.

All the best,
Rick


Den 26 april 2012 17:26 skrev Nick Cox <[email protected]>:
> Appears not.
>
> Nick
> [email protected]
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Richard Moverare
> Sent: 26 April 2012 16:17
> To: [email protected]
> Subject: Re: st: RE: Graph with point estimates and ci
>
> I thought so too, but I get the error message: "svy is not supported
> by statsby". Am I making some other mistake, i.e. is svy supported by
> statsby?
>
> All the best,
> Rick
>
> Den 26 april 2012 15:19 skrev Nick Cox <[email protected]>:
>> As I understand it, your syntax should schematically be
>>
>> -statsby ...: svy: ... : proportion: ...
>>
>> Nick
>> [email protected]
>>
>>
>> -----Original Message-----
>> From: [email protected] [mailto:[email protected]] On Behalf Of Richard Moverare
>> Sent: 26 April 2012 14:14
>> To: statalist
>> Subject: st: Graph with point estimates and ci
>>
>> Dear all,
>>
>> I have a dataset with one variable that indicates if each observation
>> (person) have done a certain activity, i.e. 1 or 0. The dataset is
>> from a survey that is conducted several years, so I have information
>> for each year. For each year I want to produce a graph where I have an
>> estimate of the proportion who has done this activity. I would like
>> this to be respresented by a filled circle with lines that represent
>> the confidence interval of the estimae. In the same graph I would also
>> like to have another estimate for a subgroup, presented in the same
>> way. And, finally I would like to add vertical line referring to a
>> known percentage in the whole population, i.e. I want to compare the
>> survey estimates with a known proportion. Then I would like to create
>> similar graphs for different years and combine them.
>>
>> If we are using the auto dataset and considering rep78 as years and
>> foreign as the activity, I could do something like this
>>
>> sysuse auto
>> statsby _b _se, by(rep78) saving(tot, replace): proportion foreign
>>
>> statsby _b _se, by(rep78) saving(subgroup, replace): proportion
>> foreign if subgroup==1
>>
>> And then I can combine the two resulting datasets and create a graph
>> using -twoway scatter- with "rcap" and "horisontal xline".
>>
>> However, I would like to do this while taking into account the survey
>> design, i.e. using -svy-. Is there some way I can do that in a similar
>> way, or should I take another path to get the same graph?
>>
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index