Print

Print


Dear Ox-Users,

I am an absolute beginner to ox-language. I normally use R. Now I am using a program implanted in Ox.

I would like to estimate the same model for 100 different data sets and save the estimates afterwards. Those data sets are saved in file_1.xls to file_100.xls and I would like to save the estimates in results_1.xls to results_100.xls.

Is there a way to do that automatically with a loop? Without having to start the estimation 100 times and replacing the file names per hand? Attached you find some sample code.

I would very much appreciate some help as ox is a closed book for me at the moment.

Cheers,

Katharina

/*Simulation */

#include <oxstd.h>
#include <packages/gnudraw/gnudraw.h>
//#include  <packages/sfamb/sfamb.ox>
#import <packages/sfamb/sfamb>

main(){
/*new object of class 'Sfa', Load data*/
    decl fob = new Sfa();fob.Load("file_i.xls");
//            fob.Info();          exit(1);

/*Model specification*/

//            fob.SetMethod(POOLED);
//            fob.SetMethod(CFE);
                fob.SetMethod(WT);
                fob.SetConstant();


/*Identification of panel structure*/

                fob.Ident(fob.GetVar("id"), fob.GetVar("time"));

/*Set up model*/
    fob.Select(Y_VAR, {"y",0,0});                                // Select dependent variable

    fob.Select(X_VAR, {                                                                                 // Select regressors
                                                                                              "Constant",0,0,
                                                                                              "x1",0,0,
                                                                                              "x2",0,0
                                                                                              });

                fob.Select(Z_VAR, {                                                                                     //Scaling sigma_u
                                                                                              "Constant", 0, 0,
                                                                                              "z1", 0, 0,
                                                                                              "z2", 0, 0,
                                                                                              });


//            fob.Select(U_VAR, {                                                                                    //Scaling sigma_u
//                                                                                          "Constant", 0, 0
//                                                                                          });
//



                // Select estimation sample
                fob.SetSelSample(-1, 1, -1, 1);  // full sample
    fob.SetPrintSfa(TRUE);
    MaxControl(1000,10,TRUE);
//            fob.SetPrintDetails(1);//display starting values and elapsed time
                fob.SetTranslog(0);

                //Estimate the model, get TE scores
                fob.Estimate();

                fob.TestGraphicAnalysis();

                fob.Renew(fob.TE(),{"TE"});
                fob.Renew(fob.Ineff(),{"Ineff"});

                fob.Save("out_i.xls");

                ////Coefficients
                savemat("par_i.xlsx", fob.GetPar());


   ////Std.Error
                savemat("se_i.xlsx", fob.GetStdErr());


                delete fob;

}


Katharina Schley, M.A. Int. Econ.
Wissenschaftliche Mitarbeiterin
Professuren für Ökonometrie und Statistik
GRK 1644 "Skalenprobleme in der Statistik"

Georg-August-Universität Göttingen
Humboldtallee 3
Raum 1.104
37073 Göttingen

Telefon: +49 (0) 551 - 39 21394
Telefax: +49 (0) 551 - 39 27279
E-Mail: [log in to unmask]<mailto:[log in to unmask]>
Internet: http://www.uni-goettingen.de/de/215408.html
http://www.uni-goettingen.de/de/156579.html