UseConstantAsInstrument: Boolean;
UseConstantAsInstrument: boolean;
The UseConstantAsInstrument property determines whether to use the constant as an instrumental variable.
Available values:
True. The constant is used as an instrumental variable.
False. The constant is used as usually.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
simeq: SmSimultaneousSystem;
eqs: ISlSimultaneousEquations;
eq: ISlSimultaneousEquation;
can, fra, ger, ita, jpn, us, uk: Array[20] Of Double;
res, i: Integer;
Begin
simeq := New SmSimultaneousSystem.Create;
// Set values can,fra,ger,ita,jpn,us,uk
can[00] := 6209; fra[00] := 4110; ger[00] := 3415; ita[00] := 2822; jpn[00] := 1475; uk[00] := 5320; us[00] := 8680;
can[01] := Double.Nan; fra[01] := 4280; ger[01] := 3673; ita[01] := 3023; jpn[01] := 1649; uk[01] := 5484; us[01] := 9132;
can[02] := 6752; fra[02] := 4459; ger[02] := 4013; ita[02] := 3131; jpn[02] := 1787; uk[02] := 5517; us[02] := 9213;
can[03] := 6837; fra[03] := 4545; ger[03] := 4278; ita[03] := 3351; jpn[03] := 1884; uk[03] := 5791; us[03] := 9450;
can[04] := 6495; fra[04] := Double.Nan; ger[04] := 4577; ita[04] := 3463; jpn[04] := 1972; uk[04] := 5971; us[04] := 9177;
can[05] := 6907; fra[05] := 4861; ger[05] := 5135; ita[05] := 3686; jpn[05] := 2108; uk[05] := 6158; us[05] := 9756;
can[06] := 7349; fra[06] := 5195; ger[06] := 5388; ita[06] := 3815; jpn[06] := 2249; uk[06] := 6238; us[06] := 9756;
can[07] := 7213; fra[07] := 5389; ger[07] := 5610; ita[07] := 3960; jpn[07] := 2394; uk[07] := 6322; us[07] := 9724;
can[08] := 7061; fra[08] := 5463; ger[08] := 5787; ita[08] := 4119; jpn[08] := 2505; uk[08] := 6340; us[08] := 9476;
can[09] := Double.Nan; fra[09] := 5610; ger[09] := 6181; ita[09] := 4351; jpn[09] := 2714; uk[09] := 6569; us[09] := 9913;
can[10] := 7132; fra[10] := 5948; ger[10] := 6633; ita[10] := 4641; jpn[10] := 3052; uk[10] := 6813; us[10] := 9974;
can[11] := 7137; fra[11] := 6218; ger[11] := 6910; ita[11] := 5008; jpn[11] := 3453; uk[11] := 6974; us[11] := 10046;
can[12] := 7473; fra[12] := 6521; ger[12] := 7146; ita[12] := 5305; jpn[12] := 3666; uk[12] := 6994; us[12] := 10467;
can[13] := 7722; fra[13] := 6788; ger[13] := 7248; ita[13] := 5611; jpn[13] := 4008; uk[13] := 7220; us[13] := 10740;
can[14] := 8088; fra[14] := Double.Nan; ger[14] := 7689; ita[14] := 5693; jpn[14] := 4486; uk[14] := 7570; us[14] := 11157;
can[15] := 8516; fra[15] := 7486; ger[15] := 8046; ita[15] := 5804; jpn[15] := 4663; uk[15] := 7686; us[15] := 11738;
can[16] := 8941; fra[16] := 7832; ger[16] := 8143; ita[16] := 6121; jpn[16] := 5115; uk[16] := 7811; us[16] := 12274;
can[17] := 9064; fra[17] := 8153; ger[17] := 8064; ita[17] := 6546; jpn[17] := 5655; uk[17] := 8012; us[17] := 12450;
can[18] := 9380; fra[18] := 8468; ger[18] := 8556; ita[18] := 6918; jpn[18] := 6358; uk[18] := 8265; us[18] := 12874;
// Set calculation period
simeq.ModelPeriod.FirstPoint := 1;
simeq.ModelPeriod.LastPoint := 20;
// Set missing data treatment parameters
simeq.MissingData.Method := MissingDataMethod.LinTrend;
// Estimation method for systems of simultaneous equations
simeq.SimultaneousSystemMethod := SimultaneousSystemMode.General;
// Use constant as an instrumental variable
simeq.UseConstantAsInstrument := True;
eqs := simeq.Equations;
// Set the first equation
eq := eqs.Add;
eq.DependentVariable.Value := can;
eq.EndogenousVariables.Add.Value := fra;
eq.EndogenousVariables.Add.Value := ger;
eq.ExogenousVariables.Add.Value := us;
eq.ExogenousVariables.Add.Value := uk;
eq.ExogenousVariables.Item(0).Include := False;
eq.Intercept.Mode := InterceptMode.AutoEstimate;
// Set the second equation
eq := eqs.Add;
eq.DependentVariable.Value := fra;
eq.EndogenousVariables.Add.Value := ger;
eq.EndogenousVariables.Add.Value := ita;
eq.EndogenousVariables.Item(1).Include := False;
eq.ExogenousVariables.Add.Value := jpn;
eq.ExogenousVariables.Add.Value := us;
// Set stack instrumental variables
simeq.StackInstrumental.Add.Value := us;
// Set maximum number of iterations
simeq.MaxIteration := 250;
// Set accuracy of solution
simeq.Tolerance := 0.001;
// Execute calculation and display results
res := simeq.Execute;
Debug.WriteLine(simeq.Errors);
Debug.WriteLine("The first equation. Modeling series");
Debug.Indent;
For i := 0 To simeq.ModelPeriod.LastPoint - 1 Do
Debug.Write(i.ToString + " ");
Debug.WriteLine(eqs.Item(0).Fitted[i]);
End For;
Debug.Unindent;
Debug.WriteLine("The second equation. Modeling series");
Debug.Indent;
For i := 0 To simeq.ModelPeriod.LastPoint - 1 Do
Debug.Write(i.ToString + " ");
Debug.WriteLine(eqs.Item(1).Fitted[i]);
End For;
Debug.Unindent;
End Sub UserProc;
After executing the example the console window displays modeling series for both equations.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
simeq: SmSimultaneousSystem;
eqs: ISlSimultaneousEquations;
eq: ISlSimultaneousEquation;
can, fra, ger, ita, jpn, us, uk: Array[20] Of Double;
Endogenous, Exogenous: ISlSerie;
Fitted: Array;
res, i: Integer;
Begin
simeq := New SmSimultaneousSystem.Create();
// Set values can,fra,ger,ita,jpn,us,uk
can[00] := 6209; fra[00] := 4110; ger[00] := 3415; ita[00] := 2822; jpn[00] := 1475; uk[00] := 5320; us[00] := 8680;
can[01] := Double.Nan; fra[01] := 4280; ger[01] := 3673; ita[01] := 3023; jpn[01] := 1649; uk[01] := 5484; us[01] := 9132;
can[02] := 6752; fra[02] := 4459; ger[02] := 4013; ita[02] := 3131; jpn[02] := 1787; uk[02] := 5517; us[02] := 9213;
can[03] := 6837; fra[03] := 4545; ger[03] := 4278; ita[03] := 3351; jpn[03] := 1884; uk[03] := 5791; us[03] := 9450;
can[04] := 6495; fra[04] := Double.Nan; ger[04] := 4577; ita[04] := 3463; jpn[04] := 1972; uk[04] := 5971; us[04] := 9177;
can[05] := 6907; fra[05] := 4861; ger[05] := 5135; ita[05] := 3686; jpn[05] := 2108; uk[05] := 6158; us[05] := 9756;
can[06] := 7349; fra[06] := 5195; ger[06] := 5388; ita[06] := 3815; jpn[06] := 2249; uk[06] := 6238; us[06] := 9756;
can[07] := 7213; fra[07] := 5389; ger[07] := 5610; ita[07] := 3960; jpn[07] := 2394; uk[07] := 6322; us[07] := 9724;
can[08] := 7061; fra[08] := 5463; ger[08] := 5787; ita[08] := 4119; jpn[08] := 2505; uk[08] := 6340; us[08] := 9476;
can[09] := Double.Nan; fra[09] := 5610; ger[09] := 6181; ita[09] := 4351; jpn[09] := 2714; uk[09] := 6569; us[09] := 9913;
can[10] := 7132; fra[10] := 5948; ger[10] := 6633; ita[10] := 4641; jpn[10] := 3052; uk[10] := 6813; us[10] := 9974;
can[11] := 7137; fra[11] := 6218; ger[11] := 6910; ita[11] := 5008; jpn[11] := 3453; uk[11] := 6974; us[11] := 10046;
can[12] := 7473; fra[12] := 6521; ger[12] := 7146; ita[12] := 5305; jpn[12] := 3666; uk[12] := 6994; us[12] := 10467;
can[13] := 7722; fra[13] := 6788; ger[13] := 7248; ita[13] := 5611; jpn[13] := 4008; uk[13] := 7220; us[13] := 10740;
can[14] := 8088; fra[14] := Double.Nan; ger[14] := 7689; ita[14] := 5693; jpn[14] := 4486; uk[14] := 7570; us[14] := 11157;
can[15] := 8516; fra[15] := 7486; ger[15] := 8046; ita[15] := 5804; jpn[15] := 4663; uk[15] := 7686; us[15] := 11738;
can[16] := 8941; fra[16] := 7832; ger[16] := 8143; ita[16] := 6121; jpn[16] := 5115; uk[16] := 7811; us[16] := 12274;
can[17] := 9064; fra[17] := 8153; ger[17] := 8064; ita[17] := 6546; jpn[17] := 5655; uk[17] := 8012; us[17] := 12450;
can[18] := 9380; fra[18] := 8468; ger[18] := 8556; ita[18] := 6918; jpn[18] := 6358; uk[18] := 8265; us[18] := 12874;
// Set calculation period
simeq.ModelPeriod.FirstPoint := 1;
simeq.ModelPeriod.LastPoint := 20;
// Set missing data treatment parameters
simeq.MissingData.Method := MissingDataMethod.mdmLinTrend;
// Estimation method for systems of simultaneous equations
simeq.SimultaneousSystemMethod := SimultaneousSystemMode.ssmGeneral;
// Use constant as an instrumental variable
simeq.UseConstantAsInstrument := True;
eqs := simeq.Equations;
// Set the first equation
eq := eqs.Add();
eq.DependentVariable.Value := can;
Endogenous := eq.EndogenousVariables.Add();
Endogenous.Value := fra;
Endogenous := eq.EndogenousVariables.Add();
Endogenous.Value := ger;
Exogenous := eq.ExogenousVariables.Add();
Exogenous.Value := us;
Exogenous := eq.ExogenousVariables.Add();
Exogenous.Value := uk;
eq.ExogenousVariables.Item[0].Include := False;
eq.Intercept.Mode := InterceptMode.imAutoEstimate;
// Set the second equation
eq := eqs.Add();
eq.DependentVariable.Value := fra;
Endogenous := eq.EndogenousVariables.Add();
Endogenous.Value := ger;
Endogenous := eq.EndogenousVariables.Add();
Endogenous.Value := ita;
eq.EndogenousVariables.Item[1].Include := False;
Exogenous := eq.ExogenousVariables.Add();
Exogenous.Value := jpn;
Exogenous := eq.ExogenousVariables.Add();
Exogenous.Value := us;
// Set stack instrumental variables
simeq.StackInstrumental.Add().Value := us;
// Set maximum number of iterations
simeq.MaxIteration := 250;
// Set accuracy of solution
simeq.Tolerance := 0.001;
// Execute calculation and display results
res := simeq.Execute();
System.Diagnostics.Debug.WriteLine(simeq.Errors);
System.Diagnostics.Debug.WriteLine("The first equation. Modeling series");
Fitted := eqs.Item[0].Fitted;
System.Diagnostics.Debug.Indent();
For i := 0 To simeq.ModelPeriod.LastPoint - 1 Do
System.Diagnostics.Debug.Write(i.ToString() + " ");
System.Diagnostics.Debug.WriteLine(Fitted[i]);
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("The second equation. Modeling series");
Fitted := eqs.Item[1].Fitted;
System.Diagnostics.Debug.Indent();
For i := 0 To simeq.ModelPeriod.LastPoint - 1 Do
System.Diagnostics.Debug.Write(i.ToString() + " ");
System.Diagnostics.Debug.WriteLine(Fitted[i]);
End For;
System.Diagnostics.Debug.Unindent();
End Sub;
See also: