Maybe something like:
Fob.DropGroupIf( !sumr( fob.GetVar(“id”) == dbase.GetVar(sprint(“v”, i))' ) );
Compare transpose, if none equal then drop. (I was unable to locate documentation on DropGroupIf, so this is a guess.)
regards,
Jaap de Vries
Van: The ox-users list is aimed at all Ox users [[log in to unmask]] namens Schley, Katharina [[log in to unmask]]
Verzonden: woensdag 10 juni 2015 8:34
Aan: [log in to unmask]
Onderwerp: Reduce Sample Size for Simulation
Dear Ox-Users,
Thank you very much for your help last time. I was able to implement the program.
However, I am struggling again with a Simulation and was hoping that I would get some help again.
I have a panel data set which contains information on different countries. They have all accounted an id variable (-> which is not a running number from 1 to n).
My goal is to reduce my data set from 400 to 200 individuals. To do that, I have created a xlsx document (Simu.xlsx) which contains variables from v1 to v5000 which are essentially lists of different selections of my
id variables. Each column contains 200 instead of 400 ids. The goal of this ‘exercise’ is to obtain 5000 estimations of my model with different data set. The data for my whole sample is in data.xls
I was trying to drop the groups if the id in data is unequal to the values in Simu.xlsx. The matrix dimensions do not match, therefore, Ox gives me an error. Is there a way in Ox to call upon the values of the variables
in Simu.xlsx and compare them to the id variable in data?
Again, all your help is very much appreciated. Please see the code underneath.
Cheers,
Katharina
/*Simulation */
#include <oxstd.h>
#include <packages/gnudraw/gnudraw.h>
//#include <packages/sfamb/sfamb.ox>
#import <packages/sfamb/sfamb>
main(){
decl dbase;
dbase = new Database();
dbase.Load(“Simu.xlsx”);
// dbase.Info(); exit(1);
/*new object of class ‘Sfa’, Load data*/
decl fob = new Sfa();fob.Load(“data.xls”);
// fob.Info(); exit(1);
decl I;
for (I = 1; I < 6; ++i)
{
/*Model specification*/
// fob.SetMethod(POOLED);
// fob.SetMethod(CFE);
fob.SetMethod(WT);
fob.SetConstant();
/* Drop time periods*/
// fob.RemoveObsIf(fob.GetVar(“time”) .<=2003);
/*Identification of panel structure*/
fob.Ident(fob.GetVar(“id”), fob.GetVar(“time”));
/*Drop Groups with missings*/
Fob.DropGroupIf(fob.GetVar(“id”) .!= dbase.GetVar(sprint(“v”, i))); /* Error: Runtime error: 'matrix[3144][1] .!= matrix[200][1]' bad operand */
/*Set up model*/
fob.Select(Y_VAR, {"lnPI_smr",0,0}); // Select dependent variable
fob.Select(X_VAR, { // Select regressors
"Constant",0,0,
"lnx1",0,0,
"lnx2",0,0,
});
fob.Select(Z_VAR, { //Scaling sigma_u
"Constant", 0, 0,
"lnz", 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(),{sprint("TE", i)});
fob.Renew(fob.Ineff(),{sprint("Ineff", i)});
fob.Save(sprint("sample_res", i, ".csv"));
//
fob.Renew(fob.GetLLFi(), {sprint("LLi", i)});
savemat(sprint("LL_smr", i, ".csv"), fob.GetLLFi());
////
// fob.Save("out.xls");
//
// savemat("out2.xls", fob.TE()~fob.Ineff());
// print("\n", fob.Local(0.99));
////Coefficients
// println("par ", fob.GetPar());
savemat(sprint("par", i, ".csv"), fob.GetPar());
////Std.Error
// println("se ",fob.GetStdErr());
savemat(sprint("se", i, ".csv"), fob.GetStdErr());
//// Convergence Status
// println("convergence", MaxConvergenceMsg(SetResults));
delete fob;
}
}
|