Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re:Re: Re: st: pick maximum,minimum, mode and median among scalars

From   Zhi Su <[email protected]>
To   statalist <[email protected]>
Subject   Re:Re: Re: st: pick maximum,minimum, mode and median among scalars
Date   Wed, 10 Aug 2011 11:59:34 -0400

Dear Tirthankar,

  The codes are very helpful. I have a few more questions.
  The codes to indicate the index for minimum are
  vMinIndex = fnMatMaxIndex(-mBeta)
  I am a little bit confused here. Why entering parameter (-mBeta) in
the mata function can produce index for minimum?
  Why not use the minindex(real vector v, real scalar k, i, w)?

  My actual case is more complicated. The four constraints in the
regressions actually are ratios multiplied to variables and their
combination change the values of depdedent variables. I run the
regression under different combinations of the constraints, in other
words, different depdedent varaibles. I record the combination of the
ratios in the names of depdendent variables. Here is the codes.

      foreach n1 in 0 5 10 {
      foreach n2 in 0 5 10 {
      foreach n3 in 0 5 10 {
      foreach n4 in 0 5 10 {
      generate su_`n1'_`n2'_`n3'_`n4'=
      generate y_`n1'_`n2'_`n3'_`n4'=y- su_`n1'_`n2'_`n3'_`n4'
      regress y_`n1'_`n2'_`n3'_`n4'  x5 x6 x7 x8, robust
      mat mBeta_y= (nullmat(mBeta_y) , e(b)')

  Using your codes, I have be able to get the maximum. minimum and
median of the coefficients of variables of interest. Is there any way
to record the names of depdendents corresponding to the maximum? For
example, the maximum for coefficient of X5 is 0.005, when the denpdent
variable is y_0_5_10_0=y-0*x1-0.5*x2-x3-0*x4. And the maximum for
X6,X7 ,X8Then the maxindex matrix contain (y_0_5_10_0, y_10_0_0_5,
y_5_5_10_5, y_0_5_0_5).


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