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]
st: Re: Comparison of results from Stata and Mata
From
[email protected] (William Gould, StataCorp LP)
To
[email protected]
Subject
st: Re: Comparison of results from Stata and Mata
Date
Fri, 04 Feb 2011 10:23:27 -0600
Matthew Baker <[email protected]> wrote,
> I have noticed that there can be a (small) discrepancy between the
> results produced by Stata's predict command after running a regression
> and what I think should generate identical results in Mata. As an
> illustration, when running the following code:
>
> sysuse auto, clear
> reg price weight length
> predict xb
> gen err=price-xb
>
> mata
> st_view(X=.,.,"weight length")
> X=X,J(rows(X),1,1)
> st_view(Y=.,.,"price")
> beta=invsym(X'X)*X'Y
> err_mata=Y-X*beta
> end
>
> getmata err_mata
> sum err err_mata
>
> I find that the results of the sum command are as follows [...]
>
> Variable | Obs Mean Std. Dev. Min Max
> -----------+------------------------------------------------
> err | 74 -.0000198 2382.413 -4432.274 5771.01
> err_mata | 74 6.20e-06 2382.413 -4432.274 5771.01