File: wg_nls.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 (22 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# William Greene, Econometric Analysis, 5e, Chapter 9
open greene5_1.gdt

# Use OLS to initialize the parameters
ols realcons 0 realdpi
scalar a = $coeff[1]
scalar b = $coeff[2]
scalar g = 1.0

# Run NLS with analytical derivatives
nls realcons = a + b * (realdpi^g)
 deriv a = 1
 deriv b = realdpi^g
 deriv g = b * realdpi^g * log(realdpi)
end nls

# Compare result using numerical derivatives
nls realcons = a + b * (realdpi^g)
 params a, b, g
end nls