Bookmark and Share

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: reading in 150 stored regression models from csv file, one at a time and using predict ... ?


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: reading in 150 stored regression models from csv file, one at a time and using predict ... ?
Date   Sun, 24 Nov 2013 02:59:19 -0500

On Sat, Nov 23, 2013 at 4:45 AM, Alexander Nervedi
<[email protected]> wrote:
> Thanks Sergiy. This is the default that i have, i was just wondering if one could do the generate through a matrix multiplication then it would be cool - but haven't figured that out yet.

http://en.wikipedia.org/wiki/Linear_regression
has the formula for matrix form. Use the same, but your betas is not a
vector but a matrix. Hence your yhat is also not a vector (1
prediction for each obs) but a matrix (with 150 predictions for each
obs). Use mata's st_view() to do the multiplication (both for reading
your Xs and storing your Yhats).

Best, Sergiy

>
> ----------------------------------------
>> Date: Fri, 22 Nov 2013 17:56:28 -0500
>> Subject: Re: st: reading in 150 stored regression models from csv file, one at a time and using predict ... ?
>> From: [email protected]
>> To: [email protected]
>>
>> Alex,
>> use -insheet- to read the estimates back to Stata, once there save
>> them to matrices, then load the original data, then do predictions
>> with:
>> generate yhat`i'=beta[1,`i']*x1+.....
>>
>> However it is probably easier if you do predictions on the spot (in
>> the same loop which originally created the 205 estimates). Unless you
>> already lost your outcome variable and can't go back.
>>
>> Best, Sergiy
>>
>>
>> On Fri, Nov 22, 2013 at 1:46 PM, Alexander Nervedi
>> <[email protected]> wrote:
>>> Hi Stata-masters,
>>>
>>> I have transactions data on 205 different commodity groups, and have estimated simple OLS models for hedonic prices each of these groups - simple reg y x1 x2 x3 x4 x5, where y is prices and x1, ... x5 are attributes of the commodities. I have stored these models in coef.csv using parmby and outsheet. Now i would like to read in the regressions from each of the these 205 models, and try to figure out what the prices would have been across each of the 205 categories if the structural relationship looked like it does for commodity group `j' where `j' takes on values from 1 to 205.
>>>
>>> I need to read in the coefs and run predict for the entire sample one set of coefs a time - but how do i get that to happen since predict doesn't work unless an ols command has been run ...
>>>
>>> thanks,
>>>
>>> Alex
>>> *
>>> * For searches and help try:
>>> * http://www.stata.com/help.cgi?search
>>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index