

# \begin{code}
setobs unitvar timevar --panel-vars
# \end{code}


# \begin{code}
setobs 20 1:1 --stacked-time-series
setobs 5 1:1 --stacked-cross-section
# \end{code}


# \begin{code}
open panel.txt
genr x1 = stack(p1..p5) --length=50
genr x2 = stack(p1..p5) --offset=50 --length=50
setobs 50 1:1 --stacked-cross-section
store panel.gdt x1 x2
# \end{code}


# \begin{code}
genr x = stack(p1,p3,p5)
# \end{code}


# \begin{code}
open panel.txt
loop for i=1..20
  genr k = ($i - 1) * 50
  genr x$i = stack(p1..p5) --offset=k --length=50
endloop
setobs 50 1.01 --stacked-cross-section
store panel.gdt x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 \
  x11 x12 x13 x14 x15 x16 x17 x18 x19 x20
# \end{code}


# \begin{code}
genr time
genr year = 1960 + (5 * time)
genr markers = "%s:%d", marker, year
# \end{code}


# \begin{code}
genr Y = fracdiff(X,0.5)
# \end{code}


# \begin{code}
genr ct = hpfilt(yt)
genr gt = yt - ct
# \end{code}


# \begin{code}
set bkbp_limits 18 96
set bkbp_k 24
# \end{code}


# \begin{code}
genr index 
genr dum = ((index-1) % 30) = 0
# \end{code}


# \begin{code}
genr pmx = pmean(x)
# \end{code}


# \begin{code}
smpl (psd(x) > 0) --restrict
# \end{code}


# \begin{code}
genr xr = resample(x)
# \end{code}


# \begin{code}
? genr p1 = cdf(X, 50, 0.9)
Generated scalar p1 (ID 2) = 8.94977e-35
? genr p2 = pvalue(X, 50, 0.9)
Generated scalar p2 (ID 3) = 1
? genr test = 1 - p2
Generated scalar test (ID 4) = 0
# \end{code}


# \begin{code}
? genr p1 = cdf(X, 50, 30)
Generated scalar p1 (ID 2) = 0.0111648
? genr p2 = pvalue(X, 50, 30)
Generated scalar p2 (ID 3) = 0.988835
? genr test = 1 - p2
Generated scalar test (ID 4) = 0.0111648
# \end{code}


# \begin{code}
genr nmiss_x = sum(missing(x))
# \end{code}


# \begin{code}
genr time
genr x0 = min(zeromiss(time * ok(x)))
# \end{code}


# \begin{code}
? adf 4 x1 --c
Augmented Dickey-Fuller tests, order 4, for x1
sample size 59
unit-root null hypothesis: a = 1
  test with constant
  model: (1 - L)y = b0 + (a-1)*y(-1) + ... + e
  estimated value of (a - 1): -0.216889
  test statistic: t = -1.83491
  asymptotic p-value 0.3638
P-values based on MacKinnon (JAE, 1996)
? genr pv = $pvalue
Generated scalar pv (ID 13) = 0.363844
? label pv    
  pv=Dickey-Fuller pvalue (scalar)
# \end{code}


# \begin{code}
matrix X = { dataset }
matrix theta = { 1, 100 }'
scalar J = BFGSmax(theta, "ObjFunc(&theta, &X)")
# \end{code}


# \begin{code}
function ObjFunc (matrix *theta, matrix *X)
  scalar val = ...  # do some computation
  return scalar val
end function
# \end{code}


# \begin{code}
matrix Jac = fdjac(theta, "SumOC(&theta, &X)")
# \end{code}


# \begin{code}
function SumOC (matrix *theta, matrix *X)
  matrix V = ...  # do some computation
  return matrix V
end function
# \end{code}


# \begin{code}
genr unitdum
ols y x du_*
# \end{code}


# \begin{code}
smpl 1970:1 1979:4
# \end{code}


# \begin{code}
smpl ; 2000:4
# \end{code}


# \begin{code}
smpl 1970:1 2003:4
smpl ; 2000:4
# \end{code}


# \begin{code}
smpl +1 ;
# \end{code}


# \begin{code}
smpl +2 -1
# \end{code}


# \begin{code}
smpl gender=0 --restrict
# \end{code}


# \begin{code}
smpl income>50000 --restrict
# \end{code}


# \begin{code}
smpl --full
# \end{code}


# \begin{code}
smpl income>50000 --restrict --replace
# \end{code}


# \begin{code}
smpl year=1995 --restrict
# \end{code}


# \begin{code}
smpl firm=3 --restrict
# \end{code}


# \begin{code}
smpl 100 --random
# \end{code}


# \begin{code}
./configure 
make 
make check
make install
# \end{code}


# \begin{code}
./configure --help
# \end{code}


# \begin{code}
./configure --prefix=/usr
# \end{code}


# \begin{code}
font = Times-Roman
fontsize = 16
max = 4.0
min = 0
width = 400
height = 448
numbers = %3.2f
outliers = true
# \end{code}


# \begin{code}
salary (GENDER=1) salary (GENDER=0)
# \end{code}


# \begin{code}
ols C 0 Y
genr alpha = $coeff(0)
genr beta = $coeff(Y)
genr gamma = 1
# \end{code}


# \begin{code}
ols y 0 x1 x2
genr alpha = $coeff(0)
genr beta = $coeff(x1)
# \end{code}


# \begin{code}
set nls_toler .0001
# \end{code}


# \begin{code}
loop control-expression [ --progressive | --verbose | --quiet ]
   loop body
endloop
# \end{code}


# \begin{code}
loop while essdiff > .00001
# \end{code}


# \begin{code}
open greene22_2
open greene22_2
discrete Z8
v8 = values(Z8)
n = rows(v8)
n = rows(v8)
loop for i=1..n
  scalar xi = v8[$i]
  smpl (Z8=xi) --restrict --replace
  printf "mean(Y | Z8 = %g) = %8.5f, sd(Y | Z8 = %g) = %g\n", \
    xi, mean(Y), xi, sd(Y)
end loop
# \end{code}


# \begin{code}
loop foreach i peach pear plum
   print "$i"
endloop
# \end{code}


# \begin{code}
genr time
loop foreach i AL..WY
   ols $i const time
endloop
# \end{code}


# \begin{code}
loop for (r=0.01; r<.991; r+=.01)
# \end{code}


# \begin{code}
function function-name(parameters)
   function body
end function
# \end{code}


# \begin{code}
function myfunc(series y, list xvars, bool verbose)
# \end{code}


# \begin{code}
function myfunc(series *y, scalar *b)
# \end{code}


# \begin{code}
int order[1:12:4]
# \end{code} 


# \begin{code}
bool verbose[0]
# \end{code} 


# \begin{code}
function myfunc2(void)
# \end{code}


# \begin{code}
# function definition
function ols_ess(series y, list xvars)
  ols y 0 xvars --quiet
  scalar myess = $ess
  printf "ESS = %g\n", myess
  return scalar myess
end function
# main script
open data4-1
list xlist = 2 3 4
# function call (the return value is ignored here)
ols_ess(price, xlist)
# \end{code}


# \begin{code}
# function definition
function get_uhat(series y, list xvars)
  ols y 0 xvars --quiet
  series uh = $uhat
  return series uh
end function
# main script
open data4-1
list xlist = 2 3 4
# function call
series resid = get_uhat(price, xlist)
# \end{code}


# \begin{code}
function get_uhat_and_ess(series y, list xvars, scalar *ess)
  ols y 0 xvars --quiet
  ess = $ess
  series uh = $uhat
  return series uh
end function
# main script
open data4-1
list xlist = 2 3 4
# function call
scalar SSR
series resid = get_uhat_and_ess(price, xlist, &SSR)
# \end{code}


# \begin{code}
function get_uhat_and_ess(series y, list xvars, scalar *ess[null])
  ols y 0 xvars --quiet
  if !isnull(ess) 
     ess = $ess
  endif
  series uh = $uhat
  return series uh
end function
# \end{code}


# \begin{code}
series resid = get_uhat_and_ess(price, xlist, null)
# \end{code}


# \begin{code}
loop foreach i X
   scalar sd_$i = sd($i)
end loop
# \end{code}


# \begin{code}
function myfunc (scalar y, const list X)
# \end{code}


# \begin{code}
function myfunc (scalar y, list X[null])
# \end{code}


# \begin{code}
return scalar SSR
# \end{code}


# \begin{code}
if nelem(xlist) = 0
   funcerr "xlist must not be empty"
end if
# \end{code}


# \begin{code}
set echo on
set messages on
# \end{code}


# \begin{code}
function pc(series y)
  series foo = diff(y)/y(-1)
  return series foo
end function
# \end{code}


# \begin{code}
genr x = uniform()
genr dpcx = pc(x)
print x dpcx --byobs
# \end{code}


# \begin{code}
include pc.gfn
open np
foo = pc(iprod)
# \end{code}


# \begin{code}
gretlcli -b scriptfile > outputfile
# \end{code}


# \begin{code} 
(* 
  DATA9-6: 
  Data on log(money), log(income) and interest rate from US. 
  Source: Stock and Watson (1993) Econometrica 
  (unsmoothed data) Period is 1900-1989 (annual data). 
  Data compiled by Graham Elliott. 
*) 
lmoney lincome intrate ; 
1 1900 1989 BYOBS
# \end{code}


# \begin{code}
G0M910  Composite index of 11 leading indicators (1987=100) 
M 1948.01 - 1995.11  n = 575
currbal Balance of Payments: Balance on Current Account; SA 
Q 1960.1 - 1999.4 n = 160
# \end{code}


# \begin{code}
# Federal Reserve Board (interest rates)
# \end{code}


# \begin{code}
scalar alpha = 1
scalar p = 1

mle logl =  p*ln(alpha * x) - lngamma(p) - ln(x) - alpha * x 
end mle 
# \end{code}


# \begin{code}
alpha = 1
p = 1
# \end{code}


# \begin{code}
scalar alpha = 1
scalar p = 1

mle logl =  p*ln(ax) - lngamma(p) - ln(x) - ax 
series ax = alpha*x
params alpha p
end mle 
# \end{code}


# \begin{code}
scalar m = mean(x)
scalar alpha = m/var(x)
scalar p = m*alpha

mle logl =  p*ln(ax) - lngamma(p) - ln(x) - ax 
series ax = alpha*x
params alpha p
end mle 
# \end{code}


# \begin{code}
scalar m = mean(x)
scalar alpha = m/var(x)
scalar p = m*alpha

mle logl =  p*ln(ax) - lngamma(p) - ln(x) - ax + (1-check)*NA
series ax = alpha*x
scalar check = (alpha>0) * (p>0)
params alpha p
end mle 
# \end{code}


# \begin{code}
open djclose

series y = 100*ldiff(djclose)

scalar mu = 0.0
scalar omega = 1
scalar alpha = 0.4
scalar beta = 0.0

mle ll = -0.5*(log(h) + (e^2)/h)
  series e = y - mu
  series h = var(y)
  series h = omega + alpha*(e(-1))^2 + beta*h(-1)
  params mu omega alpha beta
end mle
# \end{code}


# \begin{code}
nulldata 1000

genr x1 = normal()
genr x2 = normal()
genr x3 = normal()

genr ystar = x1 + x2 + x3 + normal()
genr y = (ystar > 0)

scalar b0 = 0
scalar b1 = 0
scalar b2 = 0
scalar b3 = 0

mle logl = y*ln(P) + (1-y)*ln(1-P)
  series ndx = b0 + b1*x1 + b2*x2 + b3*x3
  series P = cnorm(ndx)
  params b0 b1 b2 b3
end mle --verbose
# \end{code}


# \begin{code}
mle logl = y*ln(P) + (1-y)*ln(1-P)
  series ndx = b0 + b1*x1 + b2*x2 + b3*x3
  series P = cnorm(ndx)
  series tmp = dnorm(ndx)*(y/P - (1-y)/(1-P))
  deriv b0 = tmp
  deriv b1 = tmp*x1
  deriv b2 = tmp*x2
  deriv b3 = tmp*x3
end mle --verbose
# \end{code}


# \begin{code}
series tmp = dnorm(ndx)*(y/P - (1-y)/(1-P))
print tmp
# \end{code}


# \begin{code}
list xlist = 1 2 3 4
list reglist = income price 
list empty_list = null
# \end{code}


# \begin{code}
list xlist = x1 x2 x3 x4
ols y 0 xlist
# \end{code}


# \begin{code}
list xlist = 1 2 3
list xlist = 4 5 6
# \end{code}


# \begin{code}
list xlist = xlist 5 6 7
list xlist = 9 10 xlist 11 12
# \end{code}


# \begin{code}
series xl1 = log(x1)
series xl2 = log(x2)
list xlogs = xl1 xl2
genr is1 = islist(xlogs)
genr is2 = islist(xl1)
# \end{code}


# \begin{code}
list xlist = 1 2 3
genr nl = nelem(xlist)
# \end{code}


# \begin{code}
? list xlist = x1 x2 x3
Added list 'xlist'
? list xlist print
 xlist: x1 x2 x3
# \end{code}


# \begin{code}
list xlist = x1 x2 x3
list lxlist = logs(xlist)
list difflist = diff(xlist)
# \end{code}


# \begin{code}
list xlist = x1 x2 x3
list laglist = lags(2, xlist)
# \end{code}


# \begin{code}
scalar order = 4
list laglist = lags(order, xlist)
# \end{code}


# \begin{code}
series lx = log(x)
list laglist = lags(4, lx)
# \end{code}


# \begin{code}
logs x1 x2 x3
# \end{code}


# \begin{code}
logs xlist
# \end{code}


# \begin{code}
list loglist = logs(xlist)
# \end{code}


# \begin{code}

Model 1: Logit estimates using the 32 observations 1-32
Dependent variable: GRADE

      VARIABLE       COEFFICIENT        STDERROR      T STAT       SLOPE
                                                                  (at mean)
  const               -13.0213           4.93132      -2.641
  GPA                   2.82611          1.26294       2.238      0.533859   
  TUCE                  0.0951577        0.141554      0.672      0.0179755  
  PSI                   2.37869          1.06456       2.234      0.449339   

  Mean of GRADE = 0.344
  Number of cases 'correctly predicted' = 26 (81.2%)
  f(beta'x) at mean of independent vars = 0.189
  McFadden's pseudo-R-squared = 0.374038
  Log-likelihood = -12.8896
  Likelihood ratio test: Chi-square(3) = 15.4042 (p-value 0.001502)
  Akaike information criterion (AIC) = 33.7793
  Schwarz Bayesian criterion (BIC) = 39.6422
  Hannan-Quinn criterion (HQC) = 35.7227

           Predicted
             0    1
  Actual 0  18    3
         1   3    8

Model 2: Probit estimates using the 32 observations 1-32
Dependent variable: GRADE

      VARIABLE       COEFFICIENT        STDERROR      T STAT       SLOPE
                                                                  (at mean)
  const                -7.45232          2.54247      -2.931
  GPA                   1.62581          0.693883      2.343      0.533347   
  TUCE                  0.0517288        0.0838903     0.617      0.0169697  
  PSI                   1.42633          0.595038      2.397      0.467908   

  Mean of GRADE = 0.344
  Number of cases 'correctly predicted' = 26 (81.2%)
  f(beta'x) at mean of independent vars = 0.328
  McFadden's pseudo-R-squared = 0.377478
  Log-likelihood = -12.8188
  Likelihood ratio test: Chi-square(3) = 15.5459 (p-value 0.001405)
  Akaike information criterion (AIC) = 33.6376
  Schwarz Bayesian criterion (BIC) = 39.5006
  Hannan-Quinn criterion (HQC) = 35.581

           Predicted
             0    1
  Actual 0  18    3
         1   3    8

# \end{code}


# \begin{code}
tobit depvar indvars
# \end{code}


# \begin{code}
# \documentclass[11pt]{article}
# \usepackage[latin1]{inputenc}
# \usepackage{amsmath}
# \usepackage{dcolumn,longtable}
# \begin{document}
# \thispagestyle{empty}
# \end{code}


# \begin{code}
list xlist = x1 x2 x3
discrete z1 xlist z2
# \end{code}


# \begin{code}
discrete foo
# now foo is discrete
discrete foo --reverse
# now foo is continuous
# \end{code}


# \begin{code}
nulldata 100
# generate a variable with mean 2 and variance 1
genr x = normal() + 2
# split into 4 classes
genr z = (x>0) + (x>2) + (x>4)
# now declare z as discrete
discrete z
# \end{code}


# \begin{code}
open greene22_2
discrete Z5 # mark Z5 as discrete
dummify Z5
# \end{code}


# \begin{code}
list dlist = dummify(x)
# \end{code}


# \begin{code}
open greene22_2
discrete Z5 # mark Z5 as discrete
list foo = dummify(Z5)
loop foreach i foo
  smpl $i --restrict --replace
  summary Y
end loop
smpl full
# \end{code}


# \begin{code}
open greene22_2
discrete Z5 # mark Z5 as discrete
ols Y 0 dummify(Z5)
# \end{code}


# \begin{code}
open greene19_1
freq TUCE
discrete TUCE # mark TUCE as discrete
freq TUCE
# \end{code}


# \begin{code}
Read datafile /usr/local/share/gretl/data/greene/greene19_1.gdt
periodicity: 1, maxobs: 32,
observations range: 1-32

Listing 5 variables:
  0) const    1) GPA      2) TUCE     3) PSI      4) GRADE  

? freq TUCE

Frequency distribution for TUCE, obs 1-32
number of bins = 7, mean = 21.9375, sd = 3.90151

       interval          midpt   frequency    rel.     cum.

          <  13.417     12.000        1      3.12%    3.12% *
    13.417 - 16.250     14.833        1      3.12%    6.25% *
    16.250 - 19.083     17.667        6     18.75%   25.00% ******
    19.083 - 21.917     20.500        6     18.75%   43.75% ******
    21.917 - 24.750     23.333        9     28.12%   71.88% **********
    24.750 - 27.583     26.167        7     21.88%   93.75% *******
          >= 27.583     29.000        2      6.25%  100.00% **

Test for null hypothesis of normal distribution:
Chi-square(2) = 1.872 with p-value 0.39211
? discrete TUCE # mark TUCE as discrete
? freq TUCE

Frequency distribution for TUCE, obs 1-32

          frequency    rel.     cum.

  12           1      3.12%    3.12% *
  14           1      3.12%    6.25% *
  17           3      9.38%   15.62% ***
  19           3      9.38%   25.00% ***
  20           2      6.25%   31.25% **
  21           4     12.50%   43.75% ****
  22           2      6.25%   50.00% **
  23           4     12.50%   62.50% ****
  24           3      9.38%   71.88% ***
  25           4     12.50%   84.38% ****
  26           2      6.25%   90.62% **
  27           1      3.12%   93.75% *
  28           1      3.12%   96.88% *
  29           1      3.12%  100.00% *

Test for null hypothesis of normal distribution:
Chi-square(2) = 1.872 with p-value 0.39211
# \end{code}


# \begin{code}
xtab ylist ; xlist
# \end{code}


# \begin{code}
open greene22_2
discrete Z* # mark Z1-Z8 as discrete
xtab Z1 Z4 ; Z5 Z6
# \end{code}


# \begin{code}
Cross-tabulation of Z1 (rows) against Z5 (columns)

       [   1][   2][   3][   4][   5]  TOT.
  
[   0]    20    91    75    93    36    315
[   1]    28    73    54    97    34    286

TOTAL     48   164   129   190    70    601

Pearson chi-square test = 5.48233 (4 df, p-value = 0.241287)

Cross-tabulation of Z1 (rows) against Z6 (columns)

       [   9][  12][  14][  16][  17][  18][  20]  TOT.
  
[   0]     4    36   106    70    52    45     2    315
[   1]     3     8    48    45    37    67    78    286

TOTAL      7    44   154   115    89   112    80    601

Pearson chi-square test = 123.177 (6 df, p-value = 3.50375e-24)

Cross-tabulation of Z4 (rows) against Z5 (columns)

       [   1][   2][   3][   4][   5]  TOT.
  
[   0]    17    60    35    45    14    171
[   1]    31   104    94   145    56    430

TOTAL     48   164   129   190    70    601

Pearson chi-square test = 11.1615 (4 df, p-value = 0.0248074)

Cross-tabulation of Z4 (rows) against Z6 (columns)

       [   9][  12][  14][  16][  17][  18][  20]  TOT.
  
[   0]     1     8    39    47    30    32    14    171
[   1]     6    36   115    68    59    80    66    430

TOTAL      7    44   154   115    89   112    80    601

Pearson chi-square test = 18.3426 (6 df, p-value = 0.0054306)
# \end{code}


# \begin{code}
matrix A = { 1, 2, 3 ; 4, 5, 6 }
# \end{code}


# \begin{code}
matrix A = { x1, x2, x3 }
# \end{code}


# \begin{code}
matrix A = { x, x^2 }
# \end{code}


# \begin{code}
list xlist = x1 x2 x3
matrix A = { xlist }
# \end{code}


# \begin{code}
matrix A = { dataset }
# \end{code}


# \begin{code}
matrix C = A + k
matrix D = A - k
# \end{code}


# \begin{code}
matrix C = X'Y
# \end{code}


# \begin{code}
matrix C = A / B
matrix C = inv(B) * A
# \end{code}


# \begin{code}
matrix C = A .* B
# \end{code}


# \begin{code}
matrix C = A .^ k
# \end{code}


# \begin{code}
C = A ~ B
# \end{code}


# \begin{code}
matrix B = sqrt(A)
# \end{code}


# \begin{code}
scalar m = 4
scalar n = 5
matrix A = mnormal(m,n)
# \end{code}


# \begin{code}
matrix a = mnormal(2,3)
a
matrix b = mshape(a,3,1)
b
matrix b = mshape(a,5,2)
b
# \end{code}


# \begin{code}
?   a
a

      1.2323      0.99714     -0.39078
     0.54363      0.43928     -0.48467

?   matrix b = mshape(a,3,1)
Generated matrix b
?   b
b

      1.2323
     0.54363
     0.99714

?   matrix b = mshape(a,5,2)
Replaced matrix b
?   b
b

      1.2323     -0.48467
     0.54363       1.2323
     0.99714      0.54363
     0.43928      0.99714
    -0.39078      0.43928
# \end{code}


# \begin{code}
B = qform(A, X)
# \end{code}


# \begin{code}
matrix R
matrix Q = qrdecomp(M, &R)
matrix Q = qrdecomp(M, null)
# \end{code}


# \begin{code}
matrix V
matrix E = eigensym(M, &V)
matrix E = eigensym(M, null)
# \end{code}


# \begin{code}
matrix Pi = $jalpha * $jbeta'
# \end{code}


# \begin{code}
matrix B = A[1,]
matrix B = A[2:3,3:5]
matrix B = A[2,2]
matrix idx = { 1, 2, 6 }
matrix B = A[idx,]
# \end{code}


# \begin{code}
matrix A = { 1, 2, 3; 4, 5, 6; 7, 8, 9 }
matrix B = A[1:2,2:3]
# \end{code}


# \begin{code}
matrix A = { 1, 2, 3; 4, 5, 6; 7, 8, 9 }
matrix A[2:3,2:3] = I(2)
matrix d = { 1, 1, 1 }
matrix A[diag] = d
# \end{code}


# \begin{code}
scalar x = 3
matrix x = ones(2,2) # wrong!
# \end{code}


# \begin{code}
scalar x = 3
delete x
matrix x = ones(2,2) # OK
# \end{code}


# \begin{code}
series s = x
series u1 = U[,1]
# \end{code}


# \begin{code}
matrix M = { listname }
# \end{code}


# \begin{code}
matrix M = listname
# \end{code}


# \begin{code}
list Xl = M
# \end{code}


# \begin{code}
delete M
# \end{code}


# \begin{code}
matrix M = mnormal(100,2)
M
print M
# \end{code}


# \begin{code}
arma p q ; y
# \end{code}


# \begin{code}
arma p q ; y --conditional
# \end{code}


# \begin{code}
arma p q ; y const x1 x2
# \end{code}


# \begin{code}
arma p q ; y const x1 x2 --conditional
# \end{code}


# \begin{code}
arma p q ; P Q ; y
# \end{code}


# \begin{code}
arma 1 1 ; 1 1 ; y
# \end{code}


# \begin{code}
arma p d q ; y 
# \end{code}


# \begin{code}
series tmp = y
loop for i=1..d
  tmp = diff(tmp)
end loop
arma p q ; tmp 
# \end{code}


# \begin{code}
arma p d q ; P D Q ; y 
# \end{code}


# \begin{code}
arma 1 0 0 ; 1 1 1 ; y 
# \end{code}


# \begin{code}
genr dsy = sdiff(y)
arma 1 0 ; 1 1 ; dsy 
# \end{code}


# \begin{code}
open data10-1
arma 1 1 ; r
arma 1 1 ; r --conditional
# \end{code}


# \begin{code}
matrix start = { 0, 0.85, 0.34 }
set initvals start
arma 1 1 ; y
# \end{code}


# \begin{code}
arma p q ; y --x-12-arima
# \end{code}


# \begin{code}
                  y          fc1          fc2       fcdiff
1981:1      7.964086     7.940930      0.02668      0.02668
1981:2      7.978654     7.997576      0.03349      0.03349
1981:3      8.009463     7.997503      0.01885      0.01885
1981:4      8.015625     8.033695      0.02423      0.02423
1982:1      8.014997     8.029698      0.01407      0.01407
1982:2      8.026562     8.046037      0.01634      0.01634
1982:3      8.032717     8.063636      0.01760      0.01760
1982:4      8.042249     8.081935      0.01830      0.01830
1983:1      8.062685     8.100623      0.01869      0.01869
1983:2      8.091627     8.119528      0.01891      0.01891
1983:3      8.115700     8.138554      0.01903      0.01903
1983:4      8.140811     8.157646      0.01909      0.01909
# \end{code}


# \begin{code}
arma 0 0 ; 0 1 ; y const y(-2)
# \end{code}


# \begin{code}
adf 4 x1 --c --ct
# \end{code}


# \begin{code}
kpss m y
# \end{code}


# \begin{code}
kpss n y --trend
# \end{code}


# \begin{code}
garch p q ; y const x
# \end{code}


# \begin{code}
open denmark
coint2 2 LRM LRY IBO IDE --rc --seasonal
# \end{code}


# \begin{code}
Johansen test:
Number of equations = 4
Lag order = 2
Estimation period: 1974:3 - 1987:3 (T = 53)

Case 2: Restricted constant
Rank Eigenvalue Trace test p-value   Lmax test  p-value
   0    0.43317     49.144 [0.1284]     30.087 [0.0286]
   1    0.17758     19.057 [0.7833]     10.362 [0.8017]
   2    0.11279     8.6950 [0.7645]     6.3427 [0.7483]
   3   0.043411     2.3522 [0.7088]     2.3522 [0.7076]
# \end{code}
