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

st: AW: Cannot initialize matrix to store summed coefficient estimates

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Cannot initialize matrix to store summed coefficient estimates
Date   Thu, 24 Sep 2009 16:28:26 +0200


help simulate 

does all this automatically, and is easy to understand with the example in
the help file. 


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Diederik van
Gesendet: Donnerstag, 24. September 2009 16:23
Betreff: st: Cannot initialize matrix to store summed coefficient estimates

Dear Statalist members,

I am trying to write a simple macro that takes a random sub sample of my
dataset, run my regression and aggregates the e(B) matrices in a new matrix
so I can calculate the average coefficient estimate and the average standard
error. However, I am a bit stuck with initializing the matrix that will
contain the summed coefficients and summed standard errors. What I have been
trying to do looks like this:

local define matrix X
foreach v of varlist  'varlist'  {
    //create 1 x k matrix with initial values 0.0
    matrix X[1, "`v'"]= 0.0

forvalues i =1/n {
    generate x =runiform()
    //some more code to create random sample
    regress varlist
    matrix y = e(b)
    foreach b of e(b)  {
            matrix X[1,`b'] = matrix X[1,`b'] + _b["`b'"]
    matrix list X

Unfortunately, I don't know how to fix the error that is thrown on row 3
(matrix X[1, "`v'"] = 0.0
Stata exits with a type mismatch error and I have tried a whole range of
alternatives but so far nothing works....

I would appreciate any suggestions to get this macro working and I am sure
it's quite simple but I have been staring at this for too long :(

Best regards,
Diederik van Liere

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2023 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index