"Fossies" - the Fresh Open Source Software Archive

Member "gretl/scripts/ramanathan/ps8-8.inp" (2 Oct 2015, 2586 Bytes) of package /windows/misc/gretl-2020e-win32.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Charmm source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # PS8.8, for Application in Section 8.4
    2 open data8-3
    3 genr y=exphlth/pop 
    4 genr x=income/pop
    5 # estimate model by OLS and save absolute residuals, squared residuals,
    6 # and their logs 
    7 ols y const x seniors  
    8 genr absuhat=abs($uhat)
    9 genr usq=$uhat*$uhat
   10 genr lnusq=ln(usq)
   11 # generate square and cross product variables; the flag -o generates cross 
   12 # product
   13 square x seniors -o 
   14 # Testing and estimation for the Glesjer approach
   15 ols absuhat const x seniors sq_x sq_seniors 
   16 # estimate residual s.d. from the auxiliary regression
   17 genr sigmahat=absuhat-$uhat
   18 # compute LM test statistic and its p-value
   19 genr LM1=$nrsq
   20 pvalue X 4 LM1
   21 # print sigmahat and note that only one estimate is negative
   22 print sigmahat 
   23 # replace negative value with original sigmahat and get weights
   24 genr d1=(sigmahat>0.0)
   25 genr sigma2=(d1*sigmahat)+((1-d1)*absuhat)
   26 genr wt1=1/(sigma2^2)
   27 # Estimate model by FGLS which is the same as WLS
   28 wls wt1 y const x seniors 
   29 # Testing and estimation for the Breusch-Pagan approach
   30 ols usq const x seniors sq_x sq_seniors
   31 # estimate residual s.d. from the auxiliary regression
   32 genr usqhat1=usq-$uhat
   33 # compute LM test statistic and its p-value
   34 genr LM2=$nrsq
   35 pvalue X 4 LM2
   36 # print usqhat and note that several estimates are negative
   37 print usqhat1 
   38 # replace negative values with original usqhat and get weights
   39 genr d2=(usqhat1>0.0)
   40 genr usqhat2=(d2*usqhat1)+((1-d2)*usq)
   41 genr wt2=1/usqhat2
   42 # Estimate model by FGLS which is the same as WLS
   43 wls wt2 y const x seniors 
   44 # Testing and estimation for White's procedure
   45 ols usq const x seniors sq_x sq_seniors x_seniors 
   46 genr usqhat3=usq-$uhat
   47 # compute LM test statistic and its p-value
   48 genr LM3=$nrsq
   49 pvalue X 5 LM3
   50 # print usqhat and note that several estimates are negative
   51 print usqhat3
   52 # replace negative values with original usqhat and get weights
   53 genr d3=(usqhat3>0.0)
   54 genr usqhat4=(d3*usqhat3)+((1-d3)*usq)
   55 genr wt3=1/usqhat4
   56 # Estimate model by FGLS which is the same as WLS
   57 wls wt3 y const x seniors 
   58 # Test using the Harvey-Godfrey approach
   59 ols lnusq const x seniors sq_x sq_seniors 
   60 # compute LM test statistic and its p-value
   61 genr LM4=$nrsq
   62 # since the p-value is high, we do not reject homoscedasticity
   63 pvalue X 4 LM4
   64 # Because the coefficients for x and x-squared are significant, another LM
   65 # test is done with just these
   66 ols lnusq const x sq_x 
   67 genr lnusqhat=lnusq-$uhat
   68 # compute LM test statistic and its p-value
   69 genr LM5=$nrsq
   70 pvalue X 2 LM5
   71 # since the p-value is acceptable, we reject homoscedasticity and
   72 # procede with WLS estimation
   73 genr usqhat5=exp(lnusqhat)
   74 genr wt4=1/usqhat5
   75 wls wt4 y const x seniors