Hi,
I'm also trying to get the forecast using PcGive. I saw your reply saying that we should use a derivate class to export the variable m_mDynForc.
I'm trying but I have a message of error saying that I'm redefining a class.
I'm running a MC simulation using Autometrics and I don't have any experience in Ox language. I think it's the only thing that I couldn't found out by myself.
Also when using DoForecasting, I don't know what to put in the last 4 inputs, if I'm not doing the plot.
In case that you could help me, I'm putting my code here.
Thanks in advance!
Att,
Camila
#include <oxstd.h>
#include<oxfloat.h>
#import <packages/PcGive/pcgive_ects>
class PcGive : PcGiveCore
{
PcGive();
GetForecasts();
};
PcGive::GetForecasts()
{
return m_mDynForc;
}
decl iT,iMCSize,vBeta0,vBeta1,vBeta2,vBeta3,vBeta4,vBeta5;
decl iMC, mU, mY, mX;
main()
{
decl base, nomes, parm, coeff, parm_total, coeff_total, forecast;
betas_rel=<>;
parm_total=<>;
coeff_total={};
decl model = new PcGive();
model.Load("\\\\psf\\Home\\Desktop\\ox_autometrics\\nomes100.xls");
nomes=model.GetVarNameByIndex(<0:99>);
model.Empty();
iT = 500;
iMCSize = 1;
vBeta0=0;
vBeta1=1;
vBeta2=1;
vBeta3=1;
vBeta4=1;
vBeta5=1;
for(iMC=0;iMC<iMCSize;++iMC)
{
mU = rann(iT,1);
mY = zeros(iT,1);
mX = rann(iT,100);
mY = vBeta0+vBeta1*mX[][0]+vBeta2*mX[][1] +vBeta3*mX[][2]+vBeta4*mX[][3]+vBeta5*mX[][4]+ mU[] ;
//Autometrics
decl model = new PcGive();
model.Create(1,1,1,rows(mY),1); //creates database
model.Deterministic(-1);
model.Append(mY, "y"); //appends data and variable names
model.Append(mX, nomes);
model.DeSelect();
model.Select(Y_VAR, {"y", 0, 0});
model.Select(X_VAR, {"Constant", 0, 0});
model.SelectByIndex(X_VAR,<3:102>, 0, 0);
model.Autometrics(0.05, "none", 0);
model.SetSelSample(1, 1, iT, 1);
model.SetForecasts(10, TRUE);
model.SetMethod(M_OLS);
model.Estimate();
coeff=model.GetParNames();
parm=model.GetPar();
parm_total=parm_total~parm;
coeff_total=sprint(coeff_total,coeff);
model.DoForecasting(-1,1,1,-1,-1,0,-1);
model.PrintStaticForecasts();
forecast=model.GetForecasts();
print(forecast);
delete model;
}
savemat("parm_total.xls",parm_total);
decl file = fopen("betas_rel.csv", "w");
fprint(file, coeff_total);
fclose(file);
}
|