# Re: Re: st: creating a matrix by adding rows inside a loop: conformability error

 From nicola.baldini2@unibo.it To statalist@hsphsun2.harvard.edu Subject Re: Re: st: creating a matrix by adding rows inside a loop: conformability error Date Thu, 15 Nov 2007 12:04:11 +0100

```The problem should be there. I agree that mux*(idd-p) is a row vector, but it is summed to only the i-th (i=1...63) row of the matrixes and not the full matrixes which you noted are [63,15], therefore at each loop I am summing three components which are all [1,15] vectors.
Nicola

At 02.33 13/11/2007 -0500, you wrote:
>Nicola,
>
>in my opinion, there is a problem with the vector mux*(idd-p) which is (1,15),
>not 63...
>
>valérie
>
>- --- <nicola.baldini2@unibo.it> wrote:
>I would like to create a matrix xtilde such that the i-th row is the sum of three components:
>(1) the i-th row of matrix xmean[63,15] multiplied by matrix p[15,15]
>(2) the vector mux[1,15] multiplied by the difference between idd[15,15] and p[15,15]
>(3) the i-th row of matrix dz[63,30] multiplied by matrix q[30,15]
>What's wrong in line 4. of the following syntax? All matrixes appearing in it have 15 columns, and thus there should be not any conformability error.
>
>. forvalues i = 1/63 {
>  2. mat p=inv((r1+vu)/ns[`i'])*r1
>  3. mat q=r2*(idd-p)
>  4. matrix xtilde[`i',.] = (nullmat(xtilde) \  xmean[`i',.]*p +mux*(idd-p)+dz[`i',.]*q))
>  5. }
>conformability error
>r(503);
>
>Nicola

*
*   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/
```