On Thu, 26 Dec 2019, Ivan Falconi wrote:
> Hello.
>
> Please, I need ssome help.
>
> I am trying to obtain the parameters of the Bass model (p, q , m are
> coefficient of innovation, coefficient of imitation and market potential,
> respectively) . The message I got was that after 800 iterations convergence
> was not reached.
>
> The initial parameters were obtained with Excel's Solver. I had the same
> issue before and I used the program NELREG which gave me same error but I
> used a script and was able to find convergence. I am sure the same will
> happen with greatl provided I use proper script.
This seems to work (with some help from
https://srdas.github.io/MLBook/productForecastingBassModel.html ):
<hansl>
open http://ricardo.ecn.wfu.edu/pub/gretl/apple_sales.gdt
# use quarterly iPhone sales data
smpl 2007:2 ;
series s = iPhone
series S = cum(s)
series S2 = S^2
# regress sales on cumulated sales and its square
ols s const S S2
matrix b = $coeff
# unscramble m, p and q
m1 = (-b[2] + sqrt(b[2]^2 - 4*b[1]*b[3])) / (2*b[3])
m2 = (-b[2] - sqrt(b[2]^2 - 4*b[1]*b[3])) / (2*b[3])
m = m1 > m2 ? m1 : m2
p = b[1]/m
q = -m*b[3]
# index starting in 2007Q2
series idx = seq(1,$T)'
nls s = (m*((p+q)^2/p)*empqi)/(1+(q/p)*empqi)^2
series empqi = exp(-(p+q)*idx)
params m p q
end nls
</hansl>
Allin
_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-leave@gretlml.univpm.it
Website: https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/