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: Confirming whether a variable is binary or continuous
From
"Seed, Paul" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: Confirming whether a variable is binary or continuous
Date
Mon, 19 Mar 2012 19:24:52 +0000
It may be that a binary variable contains missing values.
For system missing, with 3 possible values [0, 1, .] one can use
assert var^2 == var
But this still leaves the possibility of no ones or zeros,
and does not handle other non-missing values.
A more general solution for any 2 non-missing values is
su var, mean
assert (var == r(min) | var == r(max) | var >= . ) & r(min) != r(max)
The question asked about binary or continuous; but
the possibility of categorical must also be considered.
For this there is a simple test; provided your continuous variable
is not rounded to the nearest integer & your categorical variables
do not include fractions.
assert var == int(var)
Paul T Seed, Senior Lecturer in Medical Statistics,
Division of Women’s Health, King’s College London
Women’s Health Academic Centre, KHP
(+44) (0) 20 7188 3642.
> Date: Sat, 17 Mar 2012 07:05:00 +0000
> From: Nick Cox <[email protected]>
> Subject: Re: st: Confirming whether a variable is binary or continuous
>
> Variations on this are often used inside Stata commands
>
> sort var
> assert var == var[1] | var == var[_N]
>
> Here -var- must be one of two distinct values, but nothing specifies
> what they are precisely.
>
> Nick
>
> On Fri, Mar 16, 2012 at 11:39 PM, daniel klein
> <[email protected]> wrote:
> > Nick,
> >
> > very smart solution, thanks. Seems it is often the simple solutions
> > that are so hard to find.
> >
> > The difference to the "-tabulate- solution" is that <var> is allowed
> > to be a constant here, which is perfectly alright for a binary
> > variable. It is for Bert to decide whether the indicators are allowed
> > to be constant or have to vary.
> >
> > Daniel
> >
> > --
> > You can also do this by e.g.
> >
> > assert inlist(var, 0. 1)
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 07:46:20 +0000
> From: Nick Cox <[email protected]>
> Subject: Re: st: Confirming whether a variable is binary or continuous
>
> My wording was sloppy. That test is satisfied also by one distinct
> value. For there to be precisely two distinct values, it is also
> necessary for -var[1]- to differ from -var[_N]-.
>
> Similarly the test -inlist(var, 0, 1)- is satisfied if -var- is always
> 0 or if -var- is always 1.
>
> Nick
>
> On Sat, Mar 17, 2012 at 7:05 AM, Nick Cox <[email protected]> wrote:
> > Variations on this are often used inside Stata commands
> >
> > sort var
> > assert var == var[1] | var == var[_N]
> >
> > Here -var- must be one of two distinct values, but nothing specifies
> > what they are precisely.
> >
> > Nick
> >
> > On Fri, Mar 16, 2012 at 11:39 PM, daniel klein
> > <[email protected]> wrote:
> >> Nick,
> >>
> >> very smart solution, thanks. Seems it is often the simple solutions
> >> that are so hard to find.
> >>
> >> The difference to the "-tabulate- solution" is that <var> is allowed
> >> to be a constant here, which is perfectly alright for a binary
> >> variable. It is for Bert to decide whether the indicators are
> allowed
> >> to be constant or have to vary.
> >>
> >> Daniel
> >>
> >> --
> >> You can also do this by e.g.
> >>
> >> assert inlist(var, 0. 1)
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 09:03:04 +0000 (GMT)
> From: olorunfemi sola <[email protected]>
> Subject: st: working with panel data in Stata
>
> Dear All,
>
> Am working with panel data. The data are as follows:
> id time ep dep lr
> lagos 2000 10 11 12
> lagos 2001 8 12 13
> lagos 2002 9 9 9
> lagos 2003 7 10 12
> ondo 2000 10 8 10
> ondo 2001 8 12 13
> ondo 2002 10 11 14
> ondo 2003 7 10 11
> ife 2000 9 11 12
> ife 2001 8 8 11
> ife 2002 9 10 12
> ife 2003 10 9 12
> But when i give this command --------" tsset id time " it gave the
> following error:
> tsset id time
> varlist: id: string variable not allowed
> r(109)
> Expecting your assistance.
>
>
> ***********************************************************************
> SOLA OLORUNFEMI Ph.D
> SENIOR LECTURER
> DEAPARTMENT OF ECONOMICS
> ADEKUNLE AJASIN UNIVERSITY
> AKUNGBA AKOKO
> ONDO STATE NIGERIA
> official e-mail: [email protected]
> TEL NO +234 803 581 0893
>
> **********************************************************************
>
>
> ________________________________
> From: Nick Cox <[email protected]>
> To: [email protected]
> Sent: Friday, 16 March 2012, 23:46
> Subject: Re: st: Confirming whether a variable is binary or continuous
>
> My wording was sloppy. That test is satisfied also by one distinct
> value. For there to be precisely two distinct values, it is also
> necessary for -var[1]- to differ from -var[_N]-.
>
> Similarly the test -inlist(var, 0, 1)- is satisfied if -var- is always
> 0 or if -var- is always 1.
>
> Nick
>
> On Sat, Mar 17, 2012 at 7:05 AM, Nick Cox <[email protected]> wrote:
> > Variations on this are often used inside Stata commands
> >
> > sort var
> > assert var == var[1] | var == var[_N]
> >
> > Here -var- must be one of two distinct values, but nothing specifies
> > what they are precisely.
> >
> > Nick
> >
> > On Fri, Mar 16, 2012 at 11:39 PM, daniel klein
> > <[email protected]> wrote:
> >> Nick,
> >>
> >> very smart solution, thanks. Seems it is often the simple solutions
> >> that are so hard to find.
> >>
> >> The difference to the "-tabulate- solution" is that <var> is allowed
> >> to be a constant here, which is perfectly alright for a binary
> >> variable. It is for Bert to decide whether the indicators are
> allowed
> >> to be constant or have to vary.
> >>
> >> Daniel
> >>
> >> --
> >> You can also do this by e.g.
> >>
> >> assert inlist(var, 0. 1)
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 18:26:17 +0900
> From: "Joseph Coveney" <[email protected]>
> Subject: st: Re: working with panel data in Stata
>
> Try:
>
> encode id, generate(ID) label(IDs)
> tsset ID time, yearly
>
> Joseph Coveney
>
> P.S. You might want to re-read Section 2.3 ("How do I send questions
> to
> Statalist?") of the list's FAQ (URL below).
>
> - -----Original Message-----
>
> Am working with panel data. The data are as follows:
> id time ep dep lr
> lagos 2000 10 11 12
> lagos 2001 8 12 13
> lagos 2002 9 9 9
> lagos 2003 7 10 12
> ondo 2000 10 8 10
> ondo 2001 8 12 13
> ondo 2002 10 11 14
> ondo 2003 7 10 11
> ife 2000 9 11 12
> ife 2001 8 8 11
> ife 2002 9 10 12
> ife 2003 10 9 12
> But when i give this command --------" tsset id time " it gave the
> following
> error:
> tsset id time
> varlist: id: string variable not allowed
> r(109)
> Expecting your assistance.
>
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 18:32:24 +0900
> From: "Joseph Coveney" <[email protected]>
> Subject: st: Re: Re: working with panel data in Stata
>
> Make that Section 2.2. Sorry.
>
> Joseph Coveney
>
>
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 09:46:04 +0000
> From: Nick Cox <[email protected]>
> Subject: Re: st: Re: Re: working with panel data in Stata
>
> I think Joseph has in mind
>
> "please do not start a new thread by replying to a previous posting.
> Again, even if you delete the previous posting’s contents and change
> its title, such practice also messes up archiving."
>
>
> On Sat, Mar 17, 2012 at 9:32 AM, Joseph Coveney
> <[email protected]> wrote:
> > Make that Section 2.2. Sorry.
> >
> > Joseph Coveney
> >
> >
> >
> > *
> > * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 07:23:17 -0230
> From: Matthew Kerby <[email protected]>
> Subject: st: Parsing words on allcaps
>
> Dear Statalist
>
> Perhaps somebody can advise on how to solve this problem.
>
> I have a dataset which consists of a single string variable. The each
> observation consists of a sentence which in turn contains a name in all
> caps. I would like to create a new variable which contains only those
> words which appear in all caps. eg. in example below I would like to
> extract the name of the hockey player.
>
>
> clear
> input str244 string
> "GRETZKY W. likes hamburgers"
> "Hotdogs are preferred by LEMIEUX M."
> "All things being equal, CROSBY S. will eat doughnuts"
> end
>
> I would like to end up with a string variable (player) which looks like
> the following:
>
> player
> "GRETZKY W."
> "LEMIEUX M."
> "CROSBY S."
>
> Any help on how to parse a string variable on allcaps is greatly
> appreciated.
> Cheers,
> M.
>
>
>
> - --
> Matthew Kerby, PhD
>
> Assistant Professor
> Department of Political Science
> Memorial University of Newfoundland
> St. John's, Newfoundland, A1B 3X9, Canada
>
> email: kerbym(at)mun.ca
> web: matthewkerby.net
> twitter: matthewkerby
> Tel: (709) 864-3093
> Fax: (709) 864-4000
>
>
> This electronic communication is governed by the terms and conditions
> at
> http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2011
> .php
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 09:55:33 +0000 (GMT)
> From: olorunfemi sola <[email protected]>
> Subject: Re: st: Re: Re: working with panel data in Stata
>
> Nick,
> Â Sorry, it was a costly mistake from me. I will not repeat it. Am
> sorry.
>
> Â
> ***********************************************************************
> SOLA OLORUNFEMIÂ Â Ph.D
> SENIOR LECTURERÂ Â
> Â DEAPARTMENT OF ECONOMICS
> ADEKUNLE AJASIN UNIVERSITY
> AKUNGBA AKOKO
> ONDO STATE NIGERIA
> official e-mail: [email protected]
> TEL NO +234 803 581 0893
> **********************************************************************
>
>
> - ----- Original Message -----
> From: Nick Cox <[email protected]>
> To: [email protected]
> Cc:
> Sent: Saturday, 17 March 2012, 1:46
> Subject: Re: st: Re: Re: working with panel data in Stata
>
> I think Joseph has in mind
>
> "please do not start a new thread by replying to a previous posting.
> Again, even if you delete the previous posting’s contents and change
> its title, such practice also messes up archiving."
>
>
> On Sat, Mar 17, 2012 at 9:32 AM, Joseph Coveney
> <[email protected]> wrote:
> > Make that Section 2.2. Â Sorry.
> >
> > Joseph Coveney
> >
> >
> >
> > *
> > * Â 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 10:05:33 +0000 (GMT)
> From: olorunfemi sola <[email protected]>
> Subject: Re: st: Re: working with panel data in Stata
>
> Joseph,
> Thank you. Your suggestion worked perfectly.
>
>
> ***********************************************************************
> SOLA OLORUNFEMI Ph.D
> SENIOR LECTURER
> DEAPARTMENT OF ECONOMICS
> ADEKUNLE AJASIN UNIVERSITY
> AKUNGBA AKOKO
> ONDO STATE NIGERIA
> official e-mail: [email protected]
> TEL NO +234 803 581 0893
> **********************************************************************
>
>
> - ----- Original Message -----
> From: Joseph Coveney <[email protected]>
> To: [email protected]
> Cc:
> Sent: Saturday, 17 March 2012, 1:26
> Subject: st: Re: working with panel data in Stata
>
> Try:
>
> encode id, generate(ID) label(IDs)
> tsset ID time, yearly
>
> Joseph Coveney
>
> P.S. You might want to re-read Section 2.3 ("How do I send questions
> to
> Statalist?") of the list's FAQ (URL below).
>
> - -----Original Message-----
>
> Am working with panel data. The data are as follows:
> id time ep dep lr
> lagos 2000 10 11 12
> lagos 2001 8 12 13
> lagos 2002 9 9 9
> lagos 2003 7 10 12
> ondo 2000 10 8 10
> ondo 2001 8 12 13
> ondo 2002 10 11 14
> ondo 2003 7 10 11
> ife 2000 9 11 12
> ife 2001 8 8 11
> ife 2002 9 10 12
> ife 2003 10 9 12
> But when i give this command --------" tsset id time " it gave the
> following
> error:
> tsset id time
> varlist: id: string variable not allowed
> r(109)
> Expecting your assistance.
>
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 10:38:01 +0000
> From: Nick Cox <[email protected]>
> Subject: Re: st: Parsing words on allcaps
>
> - -moss- (SSC) should help.
>
> Nick
>
> On 17 Mar 2012, at 09:53, Matthew Kerby <[email protected]> wrote:
>
> > Dear Statalist
> >
> > Perhaps somebody can advise on how to solve this problem.
> >
> > I have a dataset which consists of a single string variable. The each
> > observation consists of a sentence which in turn contains a name in
> > all caps. I would like to create a new variable which contains only
> > those words which appear in all caps. eg. in example below I would
> > like to extract the name of the hockey player.
> >
> >
> > clear
> > input str244 string
> > "GRETZKY W. likes hamburgers"
> > "Hotdogs are preferred by LEMIEUX M."
> > "All things being equal, CROSBY S. will eat doughnuts"
> > end
> >
> > I would like to end up with a string variable (player) which looks
> > like the following:
> >
> > player
> > "GRETZKY W."
> > "LEMIEUX M."
> > "CROSBY S."
> >
> > Any help on how to parse a string variable on allcaps is greatly
> > appreciated.
> > Cheers,
> > M
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 08:58:12 -0230
> From: Matthew Kerby <[email protected]>
> Subject: Re: st: Parsing words on allcaps
>
> Thanks! Worked.
>
>
> On 2012-03-17, at 8:08 AM, Nick Cox wrote:
>
> > -moss- (SSC) should help.
> >
> > Nick
> >
> > On 17 Mar 2012, at 09:53, Matthew Kerby <[email protected]> wrote:
> >
> >> Dear Statalist
> >>
> >> Perhaps somebody can advise on how to solve this problem.
> >>
> >> I have a dataset which consists of a single string variable. The
> each observation consists of a sentence which in turn contains a name
> in all caps. I would like to create a new variable which contains only
> those words which appear in all caps. eg. in example below I would like
> to extract the name of the hockey player.
> >>
> >>
> >> clear
> >> input str244 string
> >> "GRETZKY W. likes hamburgers"
> >> "Hotdogs are preferred by LEMIEUX M."
> >> "All things being equal, CROSBY S. will eat doughnuts"
> >> end
> >>
> >> I would like to end up with a string variable (player) which looks
> like the following:
> >>
> >> player
> >> "GRETZKY W."
> >> "LEMIEUX M."
> >> "CROSBY S."
> >>
> >> Any help on how to parse a string variable on allcaps is greatly
> appreciated.
> >> Cheers,
> >> M
> > *
> > * 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/
>
>
> This electronic communication is governed by the terms and conditions
> at
> http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2011
> .php
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 12:12:02 +0000
> From: "Ploy T." <[email protected]>
> Subject: st: Two Way Fixed Effect on Unbalanced Panel Data
>
> Hi Statalist
>
>
> I have questions regarding two-way fixed effect on large unbalanced
> panel. Here is my model:
>
>
> ln Xijt = â0 + aij + qt + â1 lnGDPit + â2 lnGDPjt + â3 lnPOPit + â4
> lnPOPjt + â5 FTAijt + åijt
>
>
>
> My LHS variable is bilateral export from country i to country j. The
> explanatory variables are GDP and population of both countries, and a
> dummy variable that takes value 1 if both countries are member of an
> FTA. I would like to run the model for
> 1.) one way fixed country effect
> 2.) one way fixed time effect and
> 3.) two way fixed effect.
>
> I have unbalanced panel data for approximately 2,200 country pairs with
> 6 time periods. I'm a new STATA user. So, as far as I know, there is no
> problem on running unbalanced panel data on one-way fixed effect
> (correct me if I'm wromg). But there's no direct method on estimating
> two-way fixed effects on large unbalanced panel data. Is there any way
> or commands that help me get through such problem?
>
> Moreover, if I change my model such that:
>
>
> ln Xijt = â0 + aij + â1 lnGDPit + â2 lnGDPjt + â3 lnPOPit + â4 lnPOPjt
> + â5 FTAijt - lnPit - lnPjt+ åijt
>
>
>
> That is, country-fixed effect and country-and-time fixed effects
> (estimating aij together with lnPit and lnPjt) are estimated together.
> Is there any method to get estimation of such model?
>
> Thanks very much in advance.
> Ploy T.
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 09:36:59 -0400
> From: David Hoaglin <[email protected]>
> Subject: Re: st: Two Way Fixed Effect on Unbalanced Panel Data
>
> Hi, Ploy.
>
> As a start, you could separate the effect aij into the "main effects"
> for the two countries and the interaction (e.g., replace aij with ci +
> cj + dij).
>
> In the second version of your model, you may want to keep the "main
> effect" for time (qt in the first version).
>
> You could fit both models by ordinary regression, accompanied by
> plotting and diagnosis, to see how the data behave. (The number of
> predictors, however, may be too large for some flavors of Stata.)
>
> That regression approach does not take into account the correlation
> structure. If you regard the panel as consisting of pairs of
> countries, a fixed-effects analysis with aij as the pair effect seems
> all right. Those fixed effects for the pairs would account for
> structure in the data that does not change over time, and that would
> include the country-specific effects ci and cj that I introduced above.
> At the moment, I don't see how to separate aij into ci + cj + dij
> within a fixed-effects model, but I have not tried to search for work
> on panels of pairs.
>
> I hope this discussion helps.
>
> David Hoaglin
>
> 2012/3/17 Ploy T. <[email protected]>:
> > Hi Statalist
> >
> >
> > I have questions regarding two-way fixed effect on large unbalanced
> > panel. Here is my model:
> >
> >
> > ln Xijt = â0 + aij + qt + â1 lnGDPit + â2 lnGDPjt + â3 lnPOPit + â4
> > lnPOPjt + â5 FTAijt + åijt
> >
> >
> >
> > My LHS variable is bilateral export from country i to country j. The
> > explanatory variables are GDP and population of both countries, and a
> > dummy variable that takes value 1 if both countries are member of an
> > FTA. I would like to run the model for
> > 1.) one way fixed country effect
> > 2.) one way fixed time effect and
> > 3.) two way fixed effect.
> >
> > I have unbalanced panel data for approximately 2,200 country pairs
> > with 6 time periods. I'm a new STATA user. So, as far as I know,
> there
> > is no problem on running unbalanced panel data on one-way fixed
> effect
> > (correct me if I'm wromg). But there's no direct method on estimating
> > two-way fixed effects on large unbalanced panel data. Is there any
> way
> > or commands that help me get through such problem?
> >
> > Moreover, if I change my model such that:
> >
> >
> > ln Xijt = â0 + aij + â1 lnGDPit + â2 lnGDPjt + â3 lnPOPit + â4
> > lnPOPjt + â5 FTAijt - lnPit - lnPjt+ åijt
> >
> >
> >
> > That is, country-fixed effect and country-and-time fixed effects
> > (estimating aij together with lnPit and lnPjt) are estimated
> together.
> > Is there any method to get estimation of such model?
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 14:31:52 +0000
> From: "Nakelse, Tebila (AfricaRice)" <[email protected]>
> Subject: st: depvar name in b an V matrix
>
> Dear Statalisters,
> I am using regress command in Stata and I would like to know if it is
> possible to add the depvar name in b an V matrix as it is done in logit
> command.
> For logit when I do :
> Logit y x
>
> e(b)[1,2]
> y: y:
> x _cons
> y1 -.35129185 -2.9228238
>
> when I do
> regress y x,
> I will have
>
> e(b)[1,2]
> x _cons
> y1 -.00809294 .045464
>
> without y in e(b) column names what I want to do
>
> I know I can pass through a regular matrix and used matrix functions
> such as coleq, roweq, colnames or rownames and after repost in e and V.
>
> I will appreciate any help
> Tebila
>
>
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 16:23:13 +0000
> From: Andrea Rispoli <[email protected]>
> Subject: st: Variable autocorrelation
>
> Dear Statalisters,
>
> I have a panel dataset and I would like to see whether certain
> variables are autocorrelated to see to what extent they are
> slow-moving versus fast-moving. What kind of test/ command can I
> run?This is perhaps a question with a well known answer but I could
> not find an answer after searching for a while so if someone my give
> me a suggestion I would really appreciate it!
> Thank you in advance.
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 18:02:51 -0400
> From: Amanda Fu <[email protected]>
> Subject: st:AR(1) error notice: sample may not include multiple panels
>
> Dear Statalists,
>
> Sorry for bothering you with a question about a simple AR(1)
> estimation. I searched related discussion in the archives , but still
> cannot figure out why the error message comes out. Any suggestions
> will be helpful.
>
> I want to estimate a univarate AR(1) model (without any controls). The
> data set is a panel data, including 1000 observations for 5 years
> (200 variables. The one I am interested is enroll taking values 0,1) .
> . tsset id years
> . arima enrollment,ar(1)
> "sample may not include multiple panels"
>
> I must have missed something here. Can someone give me some hints?
> In addition, instead of using ARIMA, may I know if there is any easy
> alternative to do the AR(1) ?
>
> Thank you very much!
>
> Amanda
> *
> * 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/
>
> ------------------------------
>
> Date: Sun, 18 Mar 2012 01:06:57 +0000
> From: Clive Nicholas <[email protected]>
> Subject: Re: st:AR(1) error notice: sample may not include multiple
> panels
>
> Amanda Fu wrote:
>
> > Sorry for bothering you with a question about a simple AR(1)
> > estimation. I searched related discussion in the archives , but still
> > cannot figure out why the error message comes out. Any suggestions
> > will be helpful.
> >
> > I want to estimate a univarate AR(1) model (without any controls).
> The
> > data set is a panel data, including 1000 observations for 5 years
> > (200 variables. The one I am interested is enroll taking values 0,1)
> .
> > . tsset id years
> > . arima enrollment,ar(1)
> > "sample may not include multiple panels"
> >
> > I must have missed something here. Can someone give me some hints?
> > In addition, instead of using ARIMA, may I know if there is any easy
> > alternative to do the AR(1) ?
>
> ARIMA models are designed for _single_ time series, not panel data.
> Since you're looking to specify AR(1) effects, that also rules out
> fixed- and random-effect models under -xtreg-, since parameter
> estimates are almost always biased and inconsistent in the presence of
> AR(1). Your only real alternative is investigate instrumental variable
> models, particularly IV-2SLS (-h xtivreg-), assuming you can find
> suitable variables to 'instrument' with the lagged variable. That's
> where the fun starts, although I use the word 'fun' advisedly.
>
> - --
> Clive Nicholas
>
> [Please DO NOT mail me personally here, but at
> <[email protected]>. Please respond to contributions I make in
> a list thread here. Thanks!]
>
> "My colleagues in the social sciences talk a great deal about
> methodology. I prefer to call it style." -- Freeman J. Dyson
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 21:13:21 -0400
> From: Richard Herron <[email protected]>
> Subject: Re: st:AR(1) error notice: sample may not include multiple
> panels
>
> This question came up yesterday, too. Here was my response:
>
> Panels require strict exogeneity for consistency, so you can't have
> lagged dependent variables on the right hand side (i.e., dynamic
> panels aren't allowed).
>
> If you think about the within estimator for panel data, then you have
> y_{i, t-1} - mean(y_i) on the right hand side, which is not orthogonal
> to e_{i,t} because mean(y_i) contains y_{i,t} from the left hand side.
>
> There are some solutions to this in -xtabond-, which does the Arellano
> and Bond estimator. Arellano and Bond correct the endogeneity by
> estimating the dynamic panel in first differences and using lags as
> instruments and GMM to take care of over-identification.
>
> Chapter 9 in Cameron and Trivedi's "Microeconometrics Using Stata"
> provides a handful of techniques for estimating dynamic panel models.
> Chapters 21 and 22 in their Microeconometrics textbook provides more
> theory. HTH.
>
> On Sat, Mar 17, 2012 at 18:02, Amanda Fu <[email protected]> wrote:
> > Dear Statalists,
> >
> > Sorry for bothering you with a question about a simple AR(1)
> > estimation. I searched related discussion in the archives , but still
> > cannot figure out why the error message comes out. Any suggestions
> > will be helpful.
> >
> > I want to estimate a univarate AR(1) model (without any controls).
> The
> > data set is a panel data, including 1000 observations for 5 years
> > (200 variables. The one I am interested is enroll taking values 0,1)
> .
> > . tsset id years
> > . arima enrollment,ar(1)
> > "sample may not include multiple panels"
> >
> > I must have missed something here. Can someone give me some hints?
> > In addition, instead of using ARIMA, may I know if there is any easy
> > alternative to do the AR(1) ?
> >
> > Thank you very much!
> >
> > Amanda
> > *
> > * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 21:34:48 -0400
> From: David Hoaglin <[email protected]>
> Subject: Re: st: ztnb model: why are some results omitted?
>
> Dear Ekaterina,
>
> How are you interpreting the constant term in the model? Because the
> four income categories are exhaustive, they need only three parameters
> in addition to the constant term. It seems likely that ztnb is
> treating the highest quartile of income as the reference category.
>
> I suggest that you merge the four income variables into a single
> categorical variable (which you might name inccat) and then use
> inccat##conf_inc as the list of independent variables.
>
> Regards,
>
> David Hoaglin
>
> On Fri, Mar 16, 2012 at 6:14 PM, Ekaterina Hertog
> <[email protected]> wrote:
> > Dear all,
> > I use Stata 12 and I am trying to analyse how individual relative
> income and
> > whether the level of income was supported by official documentation
> or not
> > affects the number of page views an person receives on a dating site.
> I am
> > particularly interested in the interactions between the relative
> income
> > variables and the variable for confirmed income.
> > I have no information about people who receive no page views so I use
> a
> > zero-truncated negative binominal model.
> > The dependent variable is a count of the number of page views.
> > inclow25 = income is in the lowest quartile of incomes in the general
> > population
> > inc50per = income in the 2nd lowest quartile
> > inc75per = income in the 2nd highest quartile
> > inchigh25 = income in the highest quartile of earners in the
> population
> > conf_inc = is a binary variable: 1 meaning that the income level is
> > confirmed with appropriate documentation
> > I run the model separately for men and the code I use looks as
> follows:
> > ztnb totpagev inclow25##conf_inc inc50per##conf_inc
> inc75per##conf_inc
> > inchigh25##conf_inc if gender==1
> >
>
> *
> * 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/
>
> ------------------------------
>
> Date: Sat, 17 Mar 2012 23:12:14 -0400
> From: Amanda Fu <[email protected]>
> Subject: Re: st:AR(1) error notice: sample may not include multiple
> panels
>
> Hello Mr. Nicholas and Mr. Herron,
>
> Thank you very much for your suggestions.
>
> After seeing the above suggestions, I checked chapter 9 in Cameron and
> Trivedi again and saw there was some useful discussion. I am sorry
> that I missed this this morning. I focused on searching stuff related
> to "time series" in that book.
>
> In addition to Arellano-Bond estimator, would it be fine if I use
> Cochrane–Orcutt estimation (-prais, cort) to estimate AR(1)?
>
> Thank you!
> Amanda
>
> On Sat, Mar 17, 2012 at 9:13 PM, Richard Herron
> <[email protected]> wrote:
> > This question came up yesterday, too. Here was my response:
> >
> > Panels require strict exogeneity for consistency, so you can't have
> > lagged dependent variables on the right hand side (i.e., dynamic
> > panels aren't allowed).
> >
> > If you think about the within estimator for panel data, then you have
> > y_{i, t-1} - mean(y_i) on the right hand side, which is not
> orthogonal
> > to e_{i,t} because mean(y_i) contains y_{i,t} from the left hand
> side.
> >
> > There are some solutions to this in -xtabond-, which does the
> Arellano
> > and Bond estimator. Arellano and Bond correct the endogeneity by
> > estimating the dynamic panel in first differences and using lags as
> > instruments and GMM to take care of over-identification.
> >
> > Chapter 9 in Cameron and Trivedi's "Microeconometrics Using Stata"
> > provides a handful of techniques for estimating dynamic panel models.
> > Chapters 21 and 22 in their Microeconometrics textbook provides more
> > theory. HTH.
> >
> > On Sat, Mar 17, 2012 at 18:02, Amanda Fu <[email protected]> wrote:
> >> Dear Statalists,
> >>
> >> Sorry for bothering you with a question about a simple AR(1)
> >> estimation. I searched related discussion in the archives , but
> still
> >> cannot figure out why the error message comes out. Any suggestions
> >> will be helpful.
> >>
> >> I want to estimate a univarate AR(1) model (without any controls).
> The
> >> data set is a panel data, including 1000 observations for 5 years
> >> (200 variables. The one I am interested is enroll taking values 0,1)
> .
> >> . tsset id years
> >> . arima enrollment,ar(1)
> >> "sample may not include multiple panels"
> >>
> >> I must have missed something here. Can someone give me some hints?
> >> In addition, instead of using ARIMA, may I know if there is any easy
> >> alternative to do the AR(1) ?
> >>
> >> Thank you very much!
> >>
> >> Amanda
> >> *
> >> * 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/
>
> ------------------------------
>
> End of statalist-digest V4 #4460
> ********************************
>
> *
> * 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/