File: weibull.inp

package info (click to toggle)
gretl 2022c-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,552 kB
  • sloc: ansic: 409,074; sh: 4,449; makefile: 3,222; cpp: 2,777; xml: 599; perl: 364
file content (33 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Estimate Weibull duration model on Kennan strike data
# Compare W. Greene, "Econometric Analysis", 5e, Chapter 22.
# We first use the mle command, then compare the built-in
# "duration" command.

open kennan

# Initial OLS to get starting values for the coefficients
ols log(Ti) 0 Prod --quiet
scalar b0 = $coeff(0)
scalar b1 = $coeff(Prod)
scalar s = 1

# useful auxiliary variables
series Xb = b0 + b1*Prod
series Z = (l_Ti - Xb) / s
series W = 0

mle loglik = Z - log(s) - exp(Z)
  series Xb = b0 + b1*Prod
  series Z = (l_Ti - Xb) / s
  series W = -(1 - exp(Z)) / s
  deriv b0 = W
  deriv b1 = Prod * W
  deriv s = -Z/s - 1/s + exp(Z) * Z/s
end mle --hessian

printf "p = %g\n", 1/s

# compare the built-in command
duration Ti 0 Prod