Bookmark and Share

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]

Re: st: how to define a matrix with mathematical expression


From   Nina YIN <yinnina.ccer@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: how to define a matrix with mathematical expression
Date   Mon, 10 Sep 2012 16:05:25 +0200

Hi Maarten

Sorry that I didn't specify the exact problem since it's a little bit
difficult to explain.
Now I explain it below:
 I want to do a matrix computation to estimate the marginal cost of
firm in the following equation:

price-marginal cost=inverse of martrix A*Demand

where matrix A is what I want to generate, while price, marginal cost
and demand are vectors for each products.

matrix A is composed with the derivatives of demands of products with
respect to prices of each products; i.e.,

the (i,j) element of A is

Aij=   - partial Demand of product j/partial price of product i,  if
product i and j are produced by the same firm;
Aij=0, otherwise.


Now I know prices, demands, derivatives of demands over prices, I need
to calculate marginal cost for each products.
whether product i and j are produced by the same firm or not could be
identified in data, which I could use some expression for it.
I could generate (i,i)elements for the matrix, but for the (i,j)
elements (i!=j), I have no idea what to do for it.

If you have any ideas about it, please feel free to tell me! Thank you
very much!

Best,
Nina







On Mon, Sep 10, 2012 at 3:34 PM, Maarten Buis <maartenlbuis@gmail.com> wrote:
> You cannot expect much help, since you still have not specified what
> it is exactly that you want to do, even though you were explicitly
> asked to do so. All we can than do is give you general comments, like:
> in Stata you can typically use equations to quickly fill in those 0s.
> Moreover, you would typically be able to fill in the rest easily by
> using the chain rule. Often the combination of these two tricks
> reduces a seemingly huge problem to an easily manageable problem. This
> is done a lot in Stata whenever something is done with maximum
> likelihood. Whether these tricks also help in your case, we just
> cannot say as you did not explain what your problem is.
>
> -- Maarten
>
> On Mon, Sep 10, 2012 at 2:55 PM, Nina YIN wrote:
>> Okay, Nick, thank you for your answer,  Symbolic manipulation is
>> exactly what I want.
>> Maybe I should return to Matlab to deal with it.
>>
>> On Mon, Sep 10, 2012 at 2:49 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>>> I don't think I can add much to my previous post. The key is that
>>> Stata expects to be given a number for each element of a matrix. It
>>> won't do symbolic manipulation, if that is what you are seeking.
>>>
>>> If you made concrete what your matrix is, that might help make clear
>>> what you are finding difficult to understand.
>>>
>>> Nick
>>>
>>> On Mon, Sep 10, 2012 at 1:37 PM, Nina YIN <yinnina.ccer@gmail.com> wrote:
>>>> Hi Nick,
>>>>
>>>> Thank you for your reply!
>>>>
>>>> Does you mean that I should make these derivations into vectors and
>>>> then define them into matrix?
>>>>
>>>> However, it's a big matrix with size110*110. Also I want to define the
>>>> element "x_{ij}" as
>>>>
>>>> if some condition satisfied, x_{ij}= partial Di/partial Pj;
>>>>
>>>> else  x_{ij}=0.
>>>>
>>>> Therefore, it would be a problem if it need me to define each element by hand.
>>>>
>>>> Do you have any idea about this? Thank you very much!
>>>>
>>>> Best,
>>>> Nina
>>>>
>>>> On Mon, Sep 10, 2012 at 2:27 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>>>>> I think you are correct. If your matrix is a matrix of partial
>>>>> derivatives, you have to do any calculus derivations yourself.
>>>>>
>>>>> Nick
>>>>>
>>>>> On Mon, Sep 10, 2012 at 1:22 PM, Nina YIN <yinnina.ccer@gmail.com> wrote:
>>>>>
>>>>>> I am trying to construct a matrix with elements defined in
>>>>>> mathematical expression. For example, a m*m matrix A with elements
>>>>>> "a_{ij}"=partial Di/ partial Pj. Di (Pj) is the i-th ( j-th ) element
>>>>>> of variable D(P).
>>>>>>
>>>>>> I just know -matrix define and -mkmat, however I didn't find out that
>>>>>> these two commands could help me in this problem. Do I understand it
>>>>>> well?
>>> *
>>> *   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/
>>
>>
>>
>> --
>> Best Regards,
>> Nina YIN
>>
>>
>> Toulouse School of Economics
>> Manufacture des Tabacs
>> 21 Allee de Brienne
>> Toulouse, 31000, France
>> Tel: 0033-(0)5 6123 8348
>> *
>> *   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/
>
>
>
> --
> ---------------------------------
> Maarten L. Buis
> WZB
> Reichpietschufer 50
> 10785 Berlin
> Germany
>
> http://www.maartenbuis.nl
> ---------------------------------
> *
> *   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/



-- 
Best Regards,
Nina YIN


Toulouse School of Economics
Manufacture des Tabacs
21 Allee de Brienne
Toulouse, 31000, France
Tel: 0033-(0)5 6123 8348
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index