An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20080723/784f20e0/attachment.pl>
estimating non-linear state space models
7 messages · Brian G. Peterson, Robert Iquiapaza, Andreas Betz +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20080723/4a26071d/attachment.pl>
Andreas wrote:
I am trying to estimate the dynamic model for equity fund's alphas and betas described here: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740 <http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740> . The nonlinear state space model is described by equations (6) and (11). (For those in a hurry: The one dimensional state follows an AR1 process. The observation equation has similarities with CAPM, but is extended to depend quadratically on the state) So far I have tried to work with the packages sspir and dse, but they don't seem to support non-linear models. I then tried to implement my own EKF code, it works for state estimation but so far I couldn't get the parameter and variance estimation running reliably.
You might try posting your code here, and being very specific about what help you need. That way everyone can benefit from an implementation of these models in R. Regards, - Brian
Just for those interested. The final version of that paper was published in Review of Financial Studies 2008 21(1):233-264; doi:10.1093/rfs/hhm049. Regards Robert Iquiapaza ri2162 at columbia.edu -------------------------------------------------- From: "Brian G. Peterson" <brian at braverock.com> Sent: Wednesday, July 23, 2008 10:03 AM To: "r_sig_finance" <r_sig_finance at greenmail.ch> Cc: <r-sig-finance at stat.math.ethz.ch> Subject: Re: [R-SIG-Finance] estimating non-linear state space models
Andreas wrote:
I am trying to estimate the dynamic model for equity fund's alphas and betas described here: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740 <http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740> . The nonlinear state space model is described by equations (6) and (11). (For those in a hurry: The one dimensional state follows an AR1 process. The observation equation has similarities with CAPM, but is extended to depend quadratically on the state) So far I have tried to work with the packages sspir and dse, but they don't seem to support non-linear models. I then tried to implement my own EKF code, it works for state estimation but so far I couldn't get the parameter and variance estimation running reliably.
You might try posting your code here, and being very specific about what help you need. That way everyone can benefit from an implementation of these models in R. Regards, - Brian
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
I had to clean up my EKF code first, after trying many different ideas I ended up with a huge mess... It's still heavily under development, but I think it could serve as a starting point. As I wrote before, state estimation seems to run OK given the true parameters. When I try to estimate the parameters by maximizing the likelihood, I end up with rather random results depending on the initial parameters I start optimizing with. I don't know if there's an error in the calculation of the likelihood, or if I'm just overstraining the ML-method by estimating model parameters and noise variances at the same time. Is this even possible? Or maybe I'm just expecting too precise results... Regards Andreas ________________________________ Von: Robert Iquiapaza [mailto:rbali at ufmg.br] Gesendet: Do 24.07.2008 03:21 An: Andreas Cc: r-sig-finance at stat.math.ethz.ch Betreff: Re: [R-SIG-Finance] estimating non-linear state space models Just for those interested. The final version of that paper was published in Review of Financial Studies 2008 21(1):233-264; doi:10.1093/rfs/hhm049. Regards Robert Iquiapaza ri2162 at columbia.edu -------------------------------------------------- From: "Brian G. Peterson" <brian at braverock.com> Sent: Wednesday, July 23, 2008 10:03 AM To: "r_sig_finance" <r_sig_finance at greenmail.ch> Cc: <r-sig-finance at stat.math.ethz.ch> Subject: Re: [R-SIG-Finance] estimating non-linear state space models
Andreas wrote:
I am trying to estimate the dynamic model for equity fund's alphas and betas described here: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740 <http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740> . The nonlinear state space model is described by equations (6) and (11). (For those in a hurry: The one dimensional state follows an AR1 process. The observation equation has similarities with CAPM, but is extended to depend quadratically on the state) So far I have tried to work with the packages sspir and dse, but they don't seem to support non-linear models. I then tried to implement my own EKF code, it works for state estimation but so far I couldn't get the parameter and variance estimation running reliably.
You might try posting your code here, and being very specific about what help you need. That way everyone can benefit from an implementation of these models in R. Regards, - Brian
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
-------------- next part -------------- An HTML attachment was scrubbed... URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20080724/b25169e1/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: ekf.R Type: application/octet-stream Size: 6166 bytes Desc: ekf.R URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20080724/b25169e1/attachment.obj>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20080724/5510c398/attachment.pl>
3 days later
Have you looked at the 'dlm' package for "Bayesian and Likelihood
Analysis of Dynamic Linear Models"? It has optional parameters 'JFF',
'JV', 'JGG', 'JW', and 'X' to support nonlinear modifications of the
standard Kalman terms 'm0', 'C0', 'FF', 'V', 'GG', 'W'. Moreover, it
has a vignette that helps learning its capabilities. This should
support your needs provided the (standardized) residuals can plausibly
be assumed to be normally distributed.
Hope this helps.
Spencer
Andreas wrote:
PS: The ML-calculation in the EFK-function shoud be: return(sum(log(Inno)) + sum(Kerror^2/Inno)) instead of Perror, I missed that line while renaming in the version I attached earlier.
________________________________
Von: r-sig-finance-bounces at stat.math.ethz.ch im Auftrag von Andreas
Gesendet: Do 24.07.2008 11:46
An: r-sig-finance at stat.math.ethz.ch
Betreff: [R-SIG-Finance] estimating non-linear state space models
I had to clean up my EKF code first, after trying many different ideas I ended up with a huge mess... It's still heavily under development, but I think it could serve as a starting point.
As I wrote before, state estimation seems to run OK given the true parameters.
When I try to estimate the parameters by maximizing the likelihood, I end up with rather random results depending on the initial parameters I start optimizing with.
I don't know if there's an error in the calculation of the likelihood, or if I'm just overstraining the ML-method by estimating model parameters and noise variances at the same time. Is this even possible? Or maybe I'm just expecting too precise results...
Regards
Andreas
________________________________
Von: Robert Iquiapaza [mailto:rbali at ufmg.br]
Gesendet: Do 24.07.2008 03:21
An: Andreas
Cc: r-sig-finance at stat.math.ethz.ch
Betreff: Re: [R-SIG-Finance] estimating non-linear state space models
Just for those interested. The final version of that paper was published in
Review of Financial Studies 2008 21(1):233-264; doi:10.1093/rfs/hhm049.
Regards
Robert Iquiapaza
ri2162 at columbia.edu
--------------------------------------------------
From: "Brian G. Peterson" <brian at braverock.com>
Sent: Wednesday, July 23, 2008 10:03 AM
To: "r_sig_finance" <r_sig_finance at greenmail.ch>
Cc: <r-sig-finance at stat.math.ethz.ch>
Subject: Re: [R-SIG-Finance] estimating non-linear state space models
Andreas wrote:
I am trying to estimate the dynamic model for equity fund's alphas and
betas described here:
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740
<http://papers.ssrn.com/sol3/papers.cfm?abstract_id=389740> . The
nonlinear state space model is described by equations (6) and (11). (For
those in a hurry: The one dimensional state follows an AR1 process. The
observation equation has similarities with CAPM, but is extended to
depend quadratically on the state)
So far I have tried to work with the packages sspir and dse, but they
don't seem to support non-linear models. I then tried to implement my own
EKF code, it works for state estimation but so far I couldn't get the
parameter and variance estimation running reliably.
You might try posting your code here, and being very specific about what
help you need. That way everyone can benefit from an implementation of
these models in R.
Regards,
- Brian
_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
[[alternative HTML version deleted]]
_______________________________________________
R-SIG-Finance at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.