In order to estimate the following logistic equation using nonlinear regression (NLS):
Code:
y(t) = m [ 1/(1+exp(-(c+qt) )) - 1/(1+exp(-(c+q(t-1)))) ] + u (t)
Code:
program nlmymodel
version 14
syntax varlist(min=3 max=3) [aw fw iw pw] if, at(name)
local y: word 1 of `varlist'
local t: word 2 of `varlist'
local tlag: word 3 of `varlist'
tempname m c q
scalar `m' = `at'[1,1]
scalar `c' = `at'[1,2]
scalar `q' = `at'[1,3]
tempvar expterm explterm
generate double `expterm' = exp(-1*(`c'+`q'*`t')) `if'
generate double `explterm' = exp(-1*(`c'+`q'*`tlag')) `if'
replace `y' = `m'*((1/(1+`expterm'))-(1/(1+`explterm'))) `if'
endCode:
gen tlag=t[_n-1]
Code:
nl mymodel @ y t tlag, parameters(m c q) initial(m 100 c 37.21 q 0.245)
Code:
Iteration 0: residual SS = 1.08e+14
Source | SS df MS
-------------+---------------------------------- Number of obs = 85
Model | -1.943e+13 -1 1.9434e+13 R-squared = -0.2201
Residual | 1.077e+14 85 1.2676e+12 Adj R-squared = -0.2057
-------------+---------------------------------- Root MSE = 1125877
Total | 8.831e+13 84 1.0513e+12 Res. dev. = 2610.012
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
/m | 100 . . . . .
/c | 37.21 . . . . .
/q | .245 . . . . .
------------------------------------------------------------------------------
Parameter q taken as constant term in model & ANOVA table
0 Response to Zero Iteration when using nl regression !
Post a Comment