Brilliant! Thanks Kit, this is statalist when at its best!
/Jan
On 5 Dec 04, at 8:16, Kit Baum wrote:
> capt program drop jan
> program jan, eclass
> syntax , adjb(numlist)
> tempname b adjbeta VV
> mat `b' = e(b)
> local nc = colsof(b)
> local nca : word count(`adjb')
> if `nca' ~= `nc' {
> di as err "Must have `nc' elements in adjb'"
> error 198
> }
> local cn: colnames `b'
> mat `VV' = e(V)
> mat input `adjbeta' = (`adjb')
> mat colnames `adjbeta' = `cn'
> local dv `e(depvar)'
> local cmd `e(cmd)'
> local pred `e(predict)'
> local model `e(model)'
> ereturn post `adjbeta' `VV'
> ereturn local depvar `dv'
> ereturn local cmd `cmd'
> ereturn local pred `pred'
> ereturn local model `model'
> end
>
>
>
> . reg price mpg headroom
>
> Source | SS df MS Number of obs =
> 74
> -------------+------------------------------ F( 2, 71) =
> 10.44
> Model | 144280501 2 72140250.4 Prob > F =
> 0.0001
> Residual | 490784895 71 6912463.32 R-squared =
> 0.2272
> -------------+------------------------------ Adj R-squared =
> 0.2054
> Total | 635065396 73 8699525.97 Root MSE =
> 2629.2
>
> ------------------------------------------------------------------------
> ------
> price | Coef. Std. Err. t P>|t| [95% Conf.
> Interval]
> -------------
> +----------------------------------------------------------------
> mpg | -259.1057 58.42485 -4.43 0.000 -375.6015
> -142.6098
> headroom | -334.0215 399.5499 -0.84 0.406 -1130.701
> 462.6585
> _cons | 12683.31 2074.497 6.11 0.000 8546.885
> 16819.74
> ------------------------------------------------------------------------
> ------
>
> . jan, adjb(-250 -300 12000)
>
> . predict phat,xb
>
> . g checkjan=-250*mpg-300*headroom+12000
>
> . su phat checkjan
>
> Variable | Obs Mean Std. Dev. Min Max
> -------------+--------------------------------------------------------
> phat | 74 5777.703 1361.107 850 8250
> checkjan | 74 5777.703 1361.107 850 8250
>
>
> Kit Baum, Boston College Economics
> http://ideas.repec.org/e/pba1.html
>
> On Dec 5, 2004, at 2:33 AM, statalist-digest wrote:
>
> > I am looking for a way to compute my own version of the predicted
> > values (following a regression estimation), x*b-star, where x is the
> > matrix of data on the x-variables and b-star is a transformed vector
> > of regression coefficients. However, I find no way of computing this
> > particular cross-product using, e.g., matrix accum, and my data
> > set is too big to allow matrix mkmat. Any clues?
>
> *
> * 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/
*
* 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/