Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
"Nakelse, Tebila (AfricaRice)" <T.Nakelse@cgiar.org> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: RE: RE: RE: Accessing to a subvector of vector like |

Date |
Tue, 7 Feb 2012 15:49:15 +0000 |

Nick the code you've given is correct and work very well. But it seems it not solve my problem which I know is not clearly expose. Below I tried to xplicit explicit. sysuse auto (1978 Automobile Data) . gen gpm = 1 / mpg . qui logit foreign weight length turn . mat bl=e(b) . predict pz, p . qui regress gpm length displacement pz . mat breg = e(b) . mat li breg breg[1,4] length displacement pz _cons y1 .00028888 .000039 -.00406527 -.01058354 . mat li bl bl[1,4] foreign: foreign: foreign: foreign: weight length turn _cons y1 -.00225393 .05080304 -.43106583 12.501797 predictnl Ey = breg[1,1]*length + breg[1,2]*displacement + breg[1,3]* normal(bl[1,1]*weight+bl[1,2]* length+bl[1,3]* turn+ bl[1,4]) + breg[1,4], se(Ey_se) Warning: prediction doesn't vary with respect to e(b). I want to use Ey in my margins command margins, expression (breg[1,1]*length + breg[1,2]*displacement + breg[1,3]* normal(bl[1,1]*weight+bl[1,2]* length+bl[1,3]* turn+ bl[1,4]) + breg[1,4]) || pz ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | .0501869 . . . . . ------------------------------------------------------------------------------ The problem here is that, margins does not compute standard error. May be, because the element of breg and bl are not recognized as element of e(b) . I really do not know why ? May be if there is a solution to tell to margin that this elements are from estimation it would solve the problem. What I have done is to stack bl and breg in one matrix and ereturn repost it in e(b) matrix used by margins. But here the main problem is that pz(predicted probability) is estimated in a first step using a different set of independent variables. May be if I extract the coefficients of pz from e(b), margins would take into account the first step . And I do not how to tell margins to take into account the first step. Best regards Tebila -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Monday, February 06, 2012 8:07 PM To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: RE: RE: RE: Accessing to a subvector of vector like I think you've changed the question. Please show us the exact code you used and explain in what sense it is "not working". Otherwise my answer can only be a guess that you did something wrong. Nick n.j.cox@durham.ac.uk Nakelse, Tebila (AfricaRice) Thank you Nick I tried this solution. But it still not working. I want to use expression(pnl_exp) in margins. But if I use this solution stata may not know whether this coefficients are from a estimation and may not use this information to compute the matrix of covariance for example. Nakelse, Tebila (AfricaRice) Thank you Nick. It is okay. Nick Cox Just copy to a regular vector first: sysuse auto gen gpm = 1 / mpg regress gpm weight length displacement . mat li e(b) e(b)[1,4] weight length displacement _cons y1 .00001174 .00006458 5.517e-06 .00152916 . mat b = e(b) . mat b1 = b[1, "weight".. "length"] . mat li b1 b1[1,2] weight length y1 .00001174 .00006458 Nick n.j.cox@durham.ac.uk Nakelse, Tebila (AfricaRice) I would like to access to a subvector of a vector like e(b) or e(V). Stata allows to have et sub-element as _b[varname]. Is it possible to have _b[varlist] ? * * 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/

**Follow-Ups**:**st: RE: RE: RE: RE: RE: RE: Accessing to a subvector of vector like***From:*Nick Cox <n.j.cox@durham.ac.uk>

**References**:**Re: st: MIXLOGIT: marginal effects***From:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: MIXLOGIT: marginal effects***From:*Arne Risa Hole <arnehole@gmail.com>

**R: st: MIXLOGIT: marginal effects***From:*"Davide Castellani" <davide.castellani@unibg.it>

**st: Accessing to a subvector of vector like***From:*"Nakelse, Tebila (AfricaRice)" <T.Nakelse@cgiar.org>

**st: RE: Accessing to a subvector of vector like***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: RE: RE: Accessing to a subvector of vector like***From:*"Nakelse, Tebila (AfricaRice)" <T.Nakelse@cgiar.org>

**st: RE: RE: RE: Accessing to a subvector of vector like***From:*"Nakelse, Tebila (AfricaRice)" <T.Nakelse@cgiar.org>

**st: RE: RE: RE: RE: Accessing to a subvector of vector like***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Interpreting 3 way dummy interaction with margins** - Next by Date:
**st: RE: RE: RE: RE: RE: RE: Accessing to a subvector of vector like** - Previous by thread:
**st: RE: RE: RE: RE: Accessing to a subvector of vector like** - Next by thread:
**st: RE: RE: RE: RE: RE: RE: Accessing to a subvector of vector like** - Index(es):