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

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

From |
Austin Nichols <austinnichols@gmail.com> |

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

Subject |
Re: st: How to get parts of XB matrix |

Date |
Fri, 3 Jun 2011 21:25:17 -0400 |

Zhi Su <su.zh@husky.neu.edu>: If you want a prediction zeroing out only a few coefficients, it's probably easier to start with -predict- and then subtract those few off. But you should get the same result either way. sysuse auto, clear reg price mpg trunk weight length turn predict p g pr=p-_b[_cons] g xb=0 loc X mpg trunk weight length turn foreach v of loc X { replace xb=xb+`v'*_b[`v'] } su pr xb On Fri, Jun 3, 2011 at 5:56 PM, Austin Nichols <austinnichols@gmail.com> wrote: > Zhi Su <su.zh@husky.neu.edu> : > Something like > g xb=0 > foreach v of loc X { > replace xb=xb+'v'*_b['v'] > } > > On Friday, June 3, 2011, Zhi Su <su.zh@husky.neu.edu> wrote: >> Dear statalist, >> >> I run a regression Y=XB+u, with 30 independent variables. I want to >> get predicted XB of 15 independent variables among 30 independent >> variables. >> Here are my questions >> 1.The coefficient of an independent variable x is stored in _b[x]. >> Is _b[x] a vector or scalar? >> 2. Generally, I use "local" to assign X I want in to a local macro >> name. And I can easily change X in the local macro name. How can I >> utilize this local macro name when I create XB matrix with independent >> variables I want? * * 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/

**References**:**st: How to get parts of XB matrix***From:*Zhi Su <su.zh@husky.neu.edu>

**Re: st: How to get parts of XB matrix***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**RE: st: RE: Saving Inter-item Correlations or Alphas as New Variables** - Next by Date:
**st: transformation of variables** - Previous by thread:
**Re: st: How to get parts of XB matrix** - Next by thread:
**st: transformation of variables** - Index(es):