 
题目见附件的图。有没有比较懂eviews编程的教一下我吖?老师给了个example做参考,自己修改command来做某个topic。
有偿求助吖!!谁在这方面比较懂加我qq 248556335
老师原来sample的2个文件command,只有一个解释变量的,现在做2个怎么改
' OLS Monte Carlo Simulation
'generate the explanatory variable and save the data for use later
!n=5  'number of observations
cd "H:\mc_exe"
workfile genx u 1 !n
series 
x=@runif(0,10) 'generate the explanatory variable from uniform distribution U(0,10).
freeze(tabx) x 'create a table oject called tabx and store x into it
'save the explanatory variable as csv file (comma-separated-value pure text file) 
'the file name is x5 (5 is the sample size)
tabx.save x5
close genx
============================================
' OLS Monte Carlo Simulation
!n=5  'number of observations
'set the number of simulations !s in the MC experiment
'or we can call !s the number of artificial data sets
!s=20
'any scalars starting with "!" will not be saved in the workfile
'they are just used during the program running
'define the workfile range !r
if !n>!s then
  !r=!n
else 
  !r=!s
endif
workfile olssim u 1 !r
smpl 1 !n
'read the explanatory variable from the file generated by mc_genx.prg into a series called x
read(skipcol=1,skiprow=3) x5.csv x
vector(2) b 'create a vector to store the true value of intercept and slope
b(1)=1 'true value of intercept
b(2)=2 'true value of the slope
scalar sigma=10 'true value of sigma
scalar sigmasq=sigma^2 'true value of sigma square
series ey=b(1)+b(2)*x 'the expected mean of y
series intpt=1 'the intercept
group xg intpt x 'create a group called xg with intpt and xs as columns
stom(xg,xm) 'transform xg into the explanatory variable matrix x
matrix 
varb=sigmasq*@inverse(@transpose(xm)*xm)'the true variance-covariance matrix of beta_hat
scalar sdb1=varb(1,1)^0.5 'the true standard deviation of the intercept estimator
scalar sdb2=varb(2,2)^0.5 'the true standard deviation of the slope estimator
scalar df=!n-2 'degrees of freedom
scalar a=0.05 'set the level of significance
'calculate the critical values for the t-distribution
scalar 
tlb=@qtdist(a/2,df) 'the t critical value, 2.5% quantile if a=0.05
scalar 
tub=@qtdist(1-a/2,df) 'the t critical value, 97.5% quantile if a=0.05
'change the range of the work file and initialize the series to store the estimated values
smpl 1 !s
series b1hat=0 'this is to store the estimated values of intercept
series seb1hat=0 'this is to store the estimated standard error of the intercept estimator
series b2hat=0 'this is to store the estimated values of slope
series seb2hat=0 'this is to store the estimated standard error of the slope estimator
series sigmahat=0 'this is to store the estimated values of sigma
series sigmasqhat=0 'this is to store the estimated values of sigma square
scalar t1err=0 'this is to store how many Type I errors committed
vector(2) ebhat 'create a vector called ebhat to calculate the sample average of bhat
vector(2) ebhatt 'create another vector to store temporary values
matrix(2,2) varbhat 'create a matrix called varbhat to estimate the variance matrix of bhat
smpl 1 !n
series y=0 'initialize the dependent variable
'the for loop for simulations, do it !s times
for !i=1 to !s
    smpl 1 !n
    
y=ey+@nrnd*sigma 'generate the dependent variable
    equation eq.ls y c x 'create an equation call eq and run the ols
    smpl 1 !s
    b1hat(!i) = 
eq.@coefs(1) 'store the intercept estimate
    seb1hat(!i)=eq.@stderrs(1) 'store the intercept estimated standard deviation
    b2hat(!i) = 
eq.@coefs(2) 'store the slope estimate
    seb2hat(!i)=eq.@stderrs(2) 'store the slope estimated standard deviation
    sigmahat(!i)=eq.@se 'store the estimated standard deviation of regression
    sigmasqhat(!i)=sigmahat(!i)^2 'store the estimated variance of regression
    ebhatt(1)=b1hat(!i)
    ebhatt(2)=b2hat(!i)
    ebhat=ebhat+ebhatt
    
varbhat=varbhat+ebhatt*@transpose(ebhatt)
    'calculate the lower and upper bound under H0:slope=slope_true given the level of significance 
    'if the estimated slope is outside the bounds, we reject H0 and make a Type I error
    !slb2=b(2)+seb2hat(!i)*tlb 'the lower bound
    !sub2=b(2)+seb2hat(!i)*tub 'the upper bound
    if (b2hat(!i)<!slb2) or (b2hat(!i)>!sub2) then      
       t1err=t1err+1  'if we reject H0:slope=slope_true, we make a Type I error
    endif 'if condition finishes here
next 'for loop finishes here
t1err=t1err/!s 'percentage of Type I errors committed
ebhat=ebhat/!s
varbhat=varbhat/!s-ebhat*@transpose(ebhat)
delete ebhatt
'the following is to calculate the power of the t test based on different (wrong) test values
!mintv=0 'minimum test value
!maxtv=4 'maximum test value
!ntestv=101 'number of test values
!step=(!maxtv-!mintv)/!ntestv 'step size
'create a !ntestv by 2 matrix called ptest
'the first column stores the wrong test values while the second stores the power of tests
matrix(!ntestv,2)  ptest
series reject=0 'initialize a series to store the occurrences of rejecting the wrong hypothesis
for !i=1 to !ntestv
    ptest(!i,1)=!mintv+(!i-1)*!step 'the test value
    
reject=@recode(((b2hat-ptest(!i,1))/seb2hat<tlb) or ((b2hat-ptest(!i,1))/seb2hat>tub), 1, 0 )
    ptest(!i,2)=@sum(reject)/!s
next
ptest.xy 'plot the power of test curve column 2 (c2) against column 1 (c1)