1. Trang chủ
  2. » Tài Chính - Ngân Hàng

SAS/ETS 9.22 User''''s Guide 127 ppt

10 73 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 289,21 KB

Nội dung

1252 ✦ Chapter 18: The MODEL Procedure Output 18.6.3 Listing of OUTEST= Data Set Created in the FIT Statement General Form Equations for Supply-Demand Model Price Quantity Solution _ S _ _ _ T N N T A U A Y T S O M P U E b E E S D d d d s s s s _ _ _ _ 0 1 2 0 1 2 1 2SLS 0 Converged 10 -395.887 0.71733 0.29806 -107.620 201.571 102.212 Output 18.6.4 Listing of OUT= Data Set Created in the First SOLVE Statement General Form Equations for Supply-Demand Model Price Quantity Solution Obs _TYPE_ _MODE_ _ERRORS_ price quantity income unitcost year 1 PREDICT SIMULATE 0 1.20473 371.552 2571.87 2.31220 1986 2 PREDICT SIMULATE 0 1.18666 382.642 2609.12 2.45633 1987 3 PREDICT SIMULATE 0 1.20154 391.788 2639.77 2.51647 1988 4 PREDICT SIMULATE 0 1.68089 400.478 2667.77 1.65617 1989 5 PREDICT SIMULATE 0 2.06214 411.896 2705.16 1.01601 1990 The following statements produce the goal-seeking solutions for PRICE and UNITCOST by using the GOAL dataset. title2 "Price Unitcost Solution"; / * produce goal-seeking solutions for income and quantity assumptions * / proc model model=model; solve price unitcost / data=goal out=pc; run; proc print data=pc; run; The output data set produced by the final SOLVE statement is shown in Output 18.6.5. Example 18.7: Spring and Damper Continuous System ✦ 1253 Output 18.6.5 Listing of OUT= Data Set Created in the Second SOLVE Statement General Form Equations for Supply-Demand Model Price Unitcost Solution Obs _TYPE_ _MODE_ _ERRORS_ price quantity income unitcost year 1 PREDICT SIMULATE 0 0.99284 371.4 2571.87 2.72857 1986 2 PREDICT SIMULATE 0 1.86594 416.5 2721.08 1.44798 1987 3 PREDICT SIMULATE 0 2.12230 597.3 3327.05 2.71130 1988 4 PREDICT SIMULATE 0 2.46166 764.1 3885.85 3.67395 1989 5 PREDICT SIMULATE 0 2.74831 694.3 3650.98 2.42576 1990 Example 18.7: Spring and Damper Continuous System This model simulates the mechanical behavior of a spring and damper system shown in Figure 18.92. Figure 18.92 Spring and Damper System Model A mass is hung from a spring with spring constant K. The motion is slowed by a damper with damper constant C. The damping force is proportional to the velocity, while the spring force is proportional to the displacement. This is actually a continuous system; however, the behavior can be approximated by a discrete time model. We approximate the differential equation @ d isp @ time D velocity 1254 ✦ Chapter 18: The MODEL Procedure with the difference equation  d isp  time D velocity This is rewritten as d isp  LAG.disp/ dt D velocity where dt is the time step used. In PROC MODEL, this is expressed with the program statement disp = lag(disp) + vel * dt; or dert.disp = vel; The first statement is simply a computing formula for Euler’s approximation for the integral d isp D Z velocity dt If the time step is small enough with respect to the changes in the system, the approximation is good. Although PROC MODEL does not have the variable step-size and error-monitoring features of simulators designed for continuous systems, the procedure is a good tool to use for less challenging continuous models. The second form instructs the MODEL procedure to do the integration for you. This model is unusual because there are no exogenous variables, and endogenous data are not needed. Although you still need a SAS data set to count the simulation periods, no actual data are brought in. Since the variables DISP and VEL are lagged, initial values specified in the VAR statement determine the starting state of the system. The mass, time step, spring constant, and damper constant are declared and initialized by a CONTROL statement as shown in the following statements: title1 'Simulation of Spring-Mass-Damper System'; / * - Data to drive the simulation time periods * / data one; do n=1 to 100; output; end; run; proc model data=one outmodel=spring; var force -200 disp 10 vel 0 accel -20 time 0; control mass 9.2 c 1.5 dt .1 k 20; force = -k * disp -c * vel; disp = lag(disp) + vel * dt; Example 18.7: Spring and Damper Continuous System ✦ 1255 vel = lag(vel) + accel * dt; accel = force / mass; time = lag(time) + dt; run; The displacement scale is zeroed at the point where the force of gravity is offset, so the acceleration of the gravity constant is omitted from the force equation. The control variable C and K represent the damper and the spring constants respectively. The model is simulated three times, and the simulation results are written to output data sets. The first run uses the original initial conditions specified in the VAR statement. In the second run, the initial displacement is doubled; the results show that the period of the motion is unaffected by the amplitude. In the third run, the DERT. syntax is used to do the integration. Notice that the path of the displacement is close to the old path, indicating that the original time step is short enough to yield an accurate solution. These simulations are performed by the following statements: proc model data=one model=spring; title2 "Simulation of the model for the base case"; control run '1'; solve / out=a; run; title2 "Simulation of the model with twice the initial displacement"; control run '2'; var disp 20; solve / out=b; run; data two; do time = 0 to 10 by .2; output;end; run; title2 "Simulation of the model using the dert. syntax"; proc model data=two; var force -200 disp 10 vel 0 accel -20 time 0; control mass 9.2 c 1.5 dt .1 k 20; control run '3' ; force = -k * disp -c * vel; dert.disp = vel ; dert.vel = accel; accel = force / mass; solve / out=c; id time ; run; The output SAS data sets that contain the solution results are merged and the displacement time paths for the three simulations are plotted. The three runs are identified on the plot as 1, 2, and 3. The following statements produce Output 18.7.1 through Output 18.7.5. data p; set a b c; run; 1256 ✦ Chapter 18: The MODEL Procedure title2 'Overlay Plot of All Three Simulations'; proc sgplot data=p; series x=time y=disp / group=run lineattrs=(pattern=1); xaxis values=(0 to 10 by 1); yaxis values=(-20 to 20 by 10); run; Output 18.7.1 Model Summary Simulation of Spring-Mass-Damper System Simulation of the model for the base case The MODEL Procedure Model Summary Model Variables 5 Control Variables 5 Equations 5 Number of Statements 6 Program Lag Length 1 Model Variables force(-200) disp(10) vel(0) accel(-20) time(0) Control Variables mass(9.2) c(1.5) dt(0.1) k(20) run(1) Equations force disp vel accel time Output 18.7.2 Printed Output Produced by PROC MODEL SOLVE Statements Simulation of Spring-Mass-Damper System Simulation of the model for the base case The MODEL Procedure Dynamic Simultaneous Simulation Data Set Options DATA= ONE OUT= A Solution Summary Variables Solved 5 Simulation Lag Length 1 Solution Method NEWTON CONVERGE= 1E-8 Maximum CC 8.68E-15 Maximum Iterations 1 Total Iterations 99 Average Iterations 1 Example 18.7: Spring and Damper Continuous System ✦ 1257 Output 18.7.2 continued Observations Processed Read 100 Lagged 1 Solved 99 First 2 Last 100 Variables Solved For force disp vel accel time Output 18.7.3 Printed Output Produced by PROC MODEL SOLVE Statements Simulation of Spring-Mass-Damper System Simulation of the model with twice the initial displacement The MODEL Procedure Dynamic Simultaneous Simulation Data Set Options DATA= ONE OUT= B Solution Summary Variables Solved 5 Simulation Lag Length 1 Solution Method NEWTON CONVERGE= 1E-8 Maximum CC 2.64E-14 Maximum Iterations 1 Total Iterations 99 Average Iterations 1 Observations Processed Read 100 Lagged 1 Solved 99 First 2 Last 100 Variables Solved For force disp vel accel time 1258 ✦ Chapter 18: The MODEL Procedure Output 18.7.4 Printed Output Produced by PROC MODEL SOLVE Statements Simulation of Spring-Mass-Damper System Simulation of the model using the dert. syntax The MODEL Procedure Simultaneous Simulation Data Set Options DATA= TWO OUT= C Solution Summary Variables Solved 4 Solution Method NEWTON Maximum Iterations 0 Observations Processed Read 51 Solved 51 Variables Solved For force disp vel accel ODE's dert.disp dert.vel Auxiliary Equations force accel Example 18.8: Nonlinear FIML Estimation ✦ 1259 Output 18.7.5 Overlay Plot of Three Simulations Example 18.8: Nonlinear FIML Estimation The data and model for this example were obtained from Bard (1974, p.133–138). The example is a two-equation econometric model used by Bodkin and Klein to fit U.S production data for the years 1909–1949. The model is the following: g 1 D c 1 10 c 2 z 4 .c 5 z c 4 1 C .1  c 5 /z c 4 2 / c 3 =c 4  z 3 D 0 g 2 D Œc 5 =.1  c 5 /.z 1 =z 2 / .1c 4 /  z 5 D 0 where z 1 is capital input, z 2 is labor input, z 3 is real output, z 4 is time in years with 1929 as year zero, and z 5 is the ratio of price of capital services to wage scale. The c i ’s are the unknown parameters. z 1 and z 2 are considered endogenous variables. A FIML estimation is performed by using the following statements: 1260 ✦ Chapter 18: The MODEL Procedure data bodkin; input z1 z2 z3 z4 z5; datalines; 1.33135 0.64629 0.4026 -20 0.24447 1.39235 0.66302 0.4084 -19 0.23454 more lines title1 "Nonlinear FIML Estimation"; proc model data=bodkin; parms c1-c5; endogenous z1 z2; exogenous z3 z4 z5; eq.g1 = c1 * 10 ** (c2 * z4) * (c5 * z1 ** (-c4)+ (1-c5) * z2 ** (-c4)) ** (-c3/c4) - z3; eq.g2 = (c5/(1-c5)) * (z1/z2) ** (-1-c4) -z5; fit g1 g2 / fiml ; run; When FIML estimation is selected, the log likelihood of the system is output as the objective value. The results of the estimation are shown in Output 18.8.1. Output 18.8.1 FIML Estimation Results for U.S. Production Data Nonlinear FIML Estimation The MODEL Procedure Nonlinear FIML Summary of Residual Errors DF DF Adj Equation Model Error SSE MSE Root MSE R-Square R-Sq g1 4 37 0.0529 0.00143 0.0378 g2 1 40 0.0173 0.000431 0.0208 Nonlinear FIML Parameter Estimates Approx Approx Parameter Estimate Std Err t Value Pr > |t| c1 0.58395 0.0218 26.76 <.0001 c2 0.005877 0.000673 8.74 <.0001 c3 1.3636 0.1148 11.87 <.0001 c4 0.473688 0.2699 1.75 0.0873 c5 0.446748 0.0596 7.49 <.0001 Example 18.9: Circuit Estimation ✦ 1261 Output 18.8.1 continued Number of Observations Statistics for System Used 41 Log Likelihood 110.7773 Missing 0 Example 18.9: Circuit Estimation Consider the nonlinear circuit shown in Figure 18.93. Figure 18.93 Nonlinear Resistor Capacitor Circuit The theory of electric circuits is governed by Kirchhoff’s laws: the sum of the currents flowing to a node is zero, and the net voltage drop around a closed loop is zero. In addition to Kirchhoff’s laws, there are relationships between the current I through each element and the voltage drop V across the elements. For the circuit in Figure 18.93, the relationships are C d V dt D I for the capacitor and V D .R 1 C R 2 .1  exp.V///I for the nonlinear resistor. The following differential equation describes the current at node 2 as a function of time and voltage for this circuit: C d V 2 dt  V 1  V 2 R 1 C R 2 .1  exp.V// D 0 This equation can be written in the form d V 2 dt D V 1  V 2 .R 1 C R 2 .1  exp.V///C . 2571.87 2.3 1220 198 6 2 PREDICT SIMULATE 0 1.18666 382.642 26 09. 12 2.45633 198 7 3 PREDICT SIMULATE 0 1.20154 391 .788 26 39. 77 2.51647 198 8 4 PREDICT SIMULATE 0 1.680 89 400.478 2667.77 1.65617 198 9 5 PREDICT. year 1 PREDICT SIMULATE 0 0 .99 284 371.4 2571.87 2.72857 198 6 2 PREDICT SIMULATE 0 1.86 594 416.5 2721.08 1.44 798 198 7 3 PREDICT SIMULATE 0 2. 1223 0 597 .3 3327.05 2.71130 198 8 4 PREDICT SIMULATE 0. 3327.05 2.71130 198 8 4 PREDICT SIMULATE 0 2.46166 764.1 3885.85 3.67 395 198 9 5 PREDICT SIMULATE 0 2.74831 694 .3 3650 .98 2.42576 199 0 Example 18.7: Spring and Damper Continuous System This model simulates

Ngày đăng: 02/07/2014, 15:20