DEEPPRICE Procedure

A Demand-Price Example When the Price Is Endogenous

This example illustrates how the DEEPPRICE procedure estimates the parameters of interest and performs policy evaluation and policy comparison when the treatment variable is endogenous. In this case, the instrumental variable should be used. This example also demonstrates how you can save the model information and use it later to score other new data.

A simulated data set is generated, based on the following assumptions:

  • The treatment variable, scaled flight price (denoted by p), is continuous, and its value ranges from 0.01 to 75, inclusive.

  • The outcome variable, demand (denoted by y), is continuous and nonnegative.

  • The instrumental variable, normalized oil price (denoted by z), is continuous and available.

  • There are two covariates:

    • The customer type (denoted by s) is discrete, and its value ranges from 1 to 10, inclusive.

    • The time (denoted by t) is continuous, and its value ranges from 0 to 12, exclusive.

  • The disturbance in the treatment model is correlated with the disturbance in the outcome model. This implies that the treatment variable is endogenous.

The treatment model is given as

StartLayout 1st Row 1st Column p 2nd Column equals eta 0 left parenthesis t right parenthesis plus eta 1 left parenthesis t right parenthesis z plus eta comma eta tilde Overscript iid Endscripts upper N left parenthesis 0 comma 1 right parenthesis 2nd Row 1st Column eta 0 left parenthesis t right parenthesis 2nd Column equals 5 plus 0.3 psi left parenthesis t right parenthesis 3rd Row 1st Column eta 1 left parenthesis t right parenthesis 2nd Column equals 0.1 psi left parenthesis t right parenthesis 4th Row 1st Column psi left parenthesis t right parenthesis 2nd Column equals 2 left parenthesis StartFraction 50 Over 3 EndFraction left parenthesis StartFraction t minus 6 Over 12 EndFraction right parenthesis Superscript 4 Baseline plus normal e normal x normal p left parenthesis minus 400 left parenthesis StartFraction t minus 6 Over 12 EndFraction right parenthesis squared right parenthesis plus StartFraction t Over 12 EndFraction minus StartFraction 41 Over 20 EndFraction right parenthesis EndLayout

where psi left parenthesis period right parenthesis describes the seasonality.

The outcome model is given as

StartLayout 1st Row 1st Column y 2nd Column equals alpha left parenthesis s comma t right parenthesis plus beta left parenthesis s comma t right parenthesis p plus epsilon comma epsilon tilde Overscript iid Endscripts upper N left parenthesis 2 eta comma 0.25 right parenthesis 2nd Row 1st Column alpha left parenthesis s comma t right parenthesis 2nd Column equals 30 plus 0.1 s psi left parenthesis t right parenthesis 3rd Row 1st Column beta left parenthesis s comma t right parenthesis 2nd Column equals 0.1 s psi left parenthesis t right parenthesis minus 0.2 EndLayout

Note that epsilon and eta are correlated, which indicates that the scaled flight price is endogenous.

The following statements simulate 12,500 samples that are based on the treatment and outcome models that were just presented:

%let n=12500;
%let rho = 2;
%let seed=12346;
%deepPriceGenerateData(&n.,&rho.,&seed.);

The following DATA steps load the first 10,000 observations of the data set deepPriceDGP into the data table simPrice_train and the next 2,500 observations into the data table simPrice_test in your session that is associated with the mylib libref. The DATA steps assume that your libref is named mylib, but you can substitute any appropriately defined libref.

data mylib.simPrice_train;
   set deepPriceDGP(obs=10000 keep=i s t z p y R pstar);
run;

data mylib.simPrice_test;
   set deepPriceDGP(firstobs=10001 keep=i s t z p y R pstar);
run;

The unknown functions eta 0 left parenthesis dot right parenthesis, eta 1 left parenthesis dot right parenthesis, alpha left parenthesis dot right parenthesis, and beta left parenthesis dot right parenthesis are estimated through two DNNs by using the simPrice_train data table. The parameters of interest are then estimated, and the policy evaluation and policy comparison are performed. The instrumental variable is introduced into the model by using the INSTRUMENT statement. The following statements use PROC DEEPPRICE to perform these tasks and store the model information and parameter learning results:

proc deepprice data=mylib.simPrice_train;
   id i;
   instrument z;
   tmodel p=s t / dnn=(nodes=(32 32 32 32)
         train=(optimizer=(miniBatchSize=2000 regL1=0.001 maxEpochs=2000
         algorithm=adam) nthreads=5 seed=12346 recordseed=12346));
   model y=s t / dnn=(nodes=(32 32 32 32)
         train=(optimizer=(miniBatchSize=2000 regL1=0.001 maxEpochs=8000
         algorithm=adam) nthreads=5 seed=12346 recordseed=12346));
   infer policy=(pstar) policyComparison=(base=(p) compare=(pstar))
      out=mylib.oest outdetails=mylib.odetails;
   score outeta0=mylib.outeta0data outeta1=mylib.outeta1data
      outa=mylib.outadata outb=mylib.outbdata;
run;

The OUTETA0= option writes the eta 0 left parenthesis dot right parenthesis estimation information to the data table outeta0data, the OUTETA1= option writes the eta 1 left parenthesis dot right parenthesis estimation information to the data table outeta1data, the OUTA= option writes the alpha left parenthesis dot right parenthesis estimation information to the data table outadata, and the OUTB= option writes the beta left parenthesis dot right parenthesis estimation information to the data table outbdata. The number of observations is shown in Figure 7.

Figure 7: Number of Observations

The DEEPPRICE Procedure

Number of Observations10000
Observations with Missing Covariates0
Observations with Missing Covariates for Treatment Model0
Observations with Missing Covariates for Outcome Model0
Observations with Missing Outcome0
Observations with Missing Treatment0
Observations with Missing Instrumental Variable0


The estimates of parameters of interest are shown in Figure 8.

Figure 8: Parameters of Interest

Parameter Estimates
ParameterEstimateStandard
Error
95% Confidence LimitsZPr > |Z|
Average Intercept28.8324080.71326527.43443530.23038240.42<.0001
Average Slope-1.5943960.154868-1.897932-1.290860-10.30<.0001


The policy evaluation estimates the expected demand of a policy. The policy evaluation results are shown in Figure 9.

Figure 9: Policy Evaluation

Policy Evaluation
PolicyEstimateStandard
Error
95% Confidence LimitsZPr > |Z|
pstar10.8074736.861139-2.64011324.2550581.580.1152


The policy comparison estimates the difference in expected demand between two policies. The policy comparison results are shown in Figure 10.

Figure 10: Policy Comparison

Policy Comparison
Comparison
Policy
Base
Policy
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
pstarp-10.9758706.871267-24.4433052.491566-1.600.1102


According to the comparison of two policies, the policy p in the observed data generates more demand on average than the policy pstar; however, this does not mean that p generates more revenue than pstar! In fact, in the real world, although pstar is theoretically the best policy to maximize revenue, it cannot be available because it needs the unknown functions alpha left parenthesis dot right parenthesis and beta left parenthesis dot right parenthesis. Because of the availability of the true data generating process (DGP), the revenue that the optimized policies generate that is suggested by the plug-in estimator and influence-function estimator can be compared to that of the best-in-theory infeasible policy pstar. The following statements compare the actual function values in the true DGP to the estimates of eta 0 left parenthesis dot right parenthesis, eta 1 left parenthesis dot right parenthesis, alpha left parenthesis dot right parenthesis, and beta left parenthesis dot right parenthesis, which are _eta0_, _eta1_, _alpha_, and _beta_, respectively, in the oDetails data table in your session; compare the revenues that are generated through different policies; and use PROC MEANS to get the bias and variance of each estimator:

proc sort data=mylib.odetails out=odetails_tmp;
   by i;
run;

data odetails;
   merge odetails_tmp(in=a) deepPriceDGP(in=b where=(i<=10000));
   by i;
   diff_eta0 = _eta0_ - eta0;
   diff_eta1 = _eta1_ - eta1;
   diff_alpha = _alpha_-alpha;
   diff_beta  = _beta_ -beta;
   * revenue difference between observed policy and best policy;
   diff_R = R0 - Rstar;
   * ifpstar, the optimized policy suggested by influence-function
     estimator;
   if(_if_beta_<0) then ifpstar = -_if_alpha_/_if_beta_/2;
   else ifpstar = pub;
   if(ifpstar>pub) then ifpstar = pub;
   if(ifpstar<plb) then ifpstar = plb;
   ifystar = alpha + beta * ifpstar;
   if(ifystar<0) then ifystar=0;
   ifRstar = ifystar * ifpstar;
   * revenue difference between influence-function optimized policy and
     best policy;
   diff_ifR = ifRstar - Rstar;
   * pipstar, the optimized policy suggested by plug-in estimator;
   if(_beta_<0) then pipstar = -_alpha_/_beta_/2;
   else pipstar = pub;
   if(pipstar>pub) then pipstar = pub;
   if(pipstar<plb) then pipstar = plb;
   piystar = alpha + beta * pipstar;
   if(piystar<0) then piystar=0;
   piRstar = piystar * pipstar;
   * revenue difference between plug-in optimized policy and best policy;
   diff_piR = piRstar - Rstar;
run;

proc means data=odetails;
   var diff_eta0 diff_eta1 diff_alpha diff_beta diff_R diff_ifR diff_piR;
run;

The results are displayed in Figure 11, which shows that all four estimated functions are unbiased and also that the plug-in optimized policy is the best feasible policy.

Figure 11: Summary Statistics for Differences

The MEANS Procedure

VariableNMeanStd DevMinimumMaximum
diff_eta0
diff_eta1
diff_alpha
diff_beta
diff_R
diff_ifR
diff_piR
10000
10000
10000
10000
10000
10000
10000
-0.0054662
-0.0101667
-0.0288887
0.0440188
-115.5029685
-132.0524553
-76.3508287
0.1393846
0.0514571
2.4017872
0.5654596
153.9612042
148.7798031
133.3256657
-0.5600274
-0.2134025
-4.2549535
-1.8312735
-996.3512062
-990.7514537
-813.2234595
0.2398572
0.0734339
8.2332300
1.3122532
-2.001858E-7
-2.105923E-8
-4.053138E-8


You can apply the previously saved eta 0 left parenthesis dot right parenthesis estimation information, eta 1 left parenthesis dot right parenthesis estimation information, alpha left parenthesis dot right parenthesis estimation information, and beta left parenthesis dot right parenthesis estimation information to a new data set by specifying the INETA0=, INETA1=, INA=, and INB= options, respectively, in the SCORE statement. The following statements use the outeta0data, outeta1data, outadata, and outbdata data tables as input data tables and then estimate the parameters of interest and perform the policy evaluation and comparison by using the simPrice_test data table:

proc deepprice data=mylib.simPrice_test;
   id i;
   instrument z;
   infer policy=(pstar) policyComparison=(base=(p) compare=(pstar))
      out=mylib.oest2 outdetails=mylib.odetails2;
   score ineta0=mylib.outeta0data ineta1=mylib.outeta1data
      ina=mylib.outadata inb=mylib.outbdata;
run;

When you specify the INETA0=, INETA1=, INA=, and INB= options in the SCORE statement, you do not need to specify the TMODEL or MODEL statement. The estimates of parameters of interest and the results of the policy evaluation and policy comparison are shown in Figure 12.

Figure 12: Parameters of Interest, Policy Evaluation, and Policy Comparison

The DEEPPRICE Procedure

Parameter Estimates
ParameterEstimateStandard
Error
95% Confidence LimitsZPr > |Z|
Average Intercept30.8444641.17601928.53950933.14941926.23<.0001
Average Slope-2.0309620.259695-2.539955-1.521970-7.82<.0001

Policy Evaluation
PolicyEstimateStandard
Error
95% Confidence LimitsZPr > |Z|
pstar-4.1243919.355596-22.46102214.212240-0.440.6593

Policy Comparison
Comparison
Policy
Base
Policy
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
pstarp-26.2690439.476454-44.842550-7.695535-2.770.0056


For more information about the estimates of parameters of interest, policy evaluation, and policy comparison, see the sections Average Intercept and Slope Parameters and Policy Evaluation and Comparison.

Last updated: November 24, 2025