I have a time series model (INGARCH):
lambda_t = alpha0 + alpha1*(x_(t-1)) + beta1*(lambda_(t-1))
X_t ~ poisson (lambda_t)
where t is the length of observation or data, alpha0, alpha1 and beta1 are the parameters.
X_t
is the series of data, lambda_t is the series of mean.
This model has the condition of alpha1 + beta1 < 1
.
In my estimation, I would like to add in the condition of alpha1 + beta1 <
1 in my code, I add a while loop in the log-likelihood function, but the loop cannot stop.
What could I do to solve this problem? Is there any other way to add a constraint of alpha1 + beta1 < 1
without using while loop?
Below are my code:
ll <- function(par) {
h.new = rep(0,n)
#par[1] is alpha0
#par[2] is alpha1
#par[3] is beta1
while(par[2] + par[3] < 1){
for (i in 2:n) {
h.new[i] <- par[1] + par[2] * dat[i-1] + par[3] * h.new[i-1]
}
-sum(dpois(dat, h.new, log=TRUE))
}
}
#simply generate a dataset as I have not found a suitable real dataset to fit in
set.seed(77)
n=400
dat <- rpois(n,36)
nlminb(start = c(0.1,0.1,0.1), lower = 1e-6, ll)