[R] Setting up a State Space Model in dlm

Michael Ash mash at econs.umass.edu
Fri Jun 10 15:28:39 CEST 2011


Thank you.    The new article linked below is excellent.  BTW, I have
had trouble getting the sample code to run.    In particular, there is
a variable k that does not appear to be set when it is used at line
227.

Here is the line where it is called:
fit <- optim(par = rep(0, 2 * k), fn = logLik, method = "BFGS",
  control = list(maxit = 500))

Here is the error message:
$ R --vanilla < kfas.R > kfas.Rlog
Error in rep.int(1, length(par)) : object 'k' not found
Calls: optim -> rep.int
Execution halted

Any advice?  Thanks.

Best,
Michael





On Fri, Jun 10, 2011 at 8:22 AM, Gavin Simpson <gavin.simpson at ucl.ac.uk> wrote:
>
> On Tue, 2011-06-07 at 17:24 +0100, Michael Ash wrote:
> > This question pertains to setting up a model in the package "dlm"
> > (dynamic linear models,
> > http://cran.r-project.org/web/packages/dlm/index.html
>
> The author of the dlm package has just published a paper on state space
> models in R including details on setting up dlm:
>
> http://www.jstatsoft.org/v41/i04
>
>



More information about the R-help mailing list