Re: [R] Bayesian Hidden Markov Models
Dear James, The distances are normalized between zero and 1, so in your case all of them will be zero. You can check that with res$Dist.for.model And do Q.NH(summary(res)[[1]]$beta, x=0) To obtain the common transition matrix. Cheers, Oscar On 29/2/12 03:59, monkeylan lanjin...@yahoo.com.cn wrote: Dear Oscar, I am extremely grateful to your help and detailed explanation of the use of RJaCGH package. But, when runing the sample codes you listed, another issue I am a little confused is as following: After runing summary(res), I have got the estimation of the random matrix Beta: Parameters of the transition functions: Normal Gain Normal 0.000 4.258 Gain2.001 0.000 But, the transition probabilty matrix Q based on the aboving Beta is more concerned in my modeling. Here, I am not sure how can I get the matrix Q. I did try the Q.NH functions.However, Shoud I set the distance parameter x be 1 or 0? I am not sure. If 1( according to my own understanding), the following result seems not reseanable. tran-matrix(c(0,2.001,4.528,0),2,2) Q.NH(beta=tran, x=1) [,1] [,2] [1,] 0.5 0.5 [2,] 0.5 0.5 Many thanks for your further help and time. James Allan --- 12年2月28日,周二, Oscar Rueda [via R] ml-node+s789695n4427760...@n4.nabble.com 写道: 发件人: Oscar Rueda [via R] ml-node+s789695n4427760...@n4.nabble.com 主题: Re: Bayesian Hidden Markov Models 收件人: monkeylan lanjin...@yahoo.com.cn 日期: 2012年2月28日,周二,下午7:02 Dear James, Basically you just need the values (y) and the positions (in your case it would be the index of the times series). The chromosome argument does not apply to your case so it can be a vector of ones. If the positions are at the same distance between (equally spaced) then the model will be homogeneous. So for example something like this would be enough: library(RJaCGH) y - c(rnorm(100,0,1), rnorm(20, 2, 1), rnorm(50, 0, 1)) Pos - 1:length(y) Chrom - rep(1, length(y)) res - RJaCGH(y=y, Pos=Pos, Chrom=Chrom) summary(res) However, it uses a Reversible Jump algorithm and therefore jumps between models with different hidden states. I would suggest you take a look at the vignette that comes with the package or the paper that is referenced there for specific details of the model it fits. Hope it helps, Oscar On 28/2/12 04:52, monkeylan [hidden email] wrote: Dear Doctor Oscar, Sorry for not noticing that you are the author of the RJaCGH package. But I noticed that hidden Markov model in your package is with non-homogeneous transition probabilities. Here in my work, the HMM is just a first-order homogeneous Markov chain, i.e. the transition matrix is constant. So, Could you please tell me how can I adjust the R functions in your package to implement my analysis? Best Regards, James Allan --- 12年2月27日,周一, Oscar Rueda [via R] [hidden email] 写道: 发件人: Oscar Rueda [via R] [hidden email] 主题: Re: Bayesian Hidden Markov Models 收件人: monkeylan [hidden email] 日期: 2012年2月27日,周一,下午6:05 Dear James, Although designed for the analysis of copy number CGH microarrays, RJaCGH uses a Bayesian HMM model. Cheers, Oscar On 27/2/12 08:32, monkeylan [hidden email] wrote: Dear R buddies, Recently, I attempt to model the US/RMB Exchange rate log-return time series with a *Hidden Markov model (first order Markov Chain mixed Normal distributions). * I have applied the RHmm package to accomplish this task, but the results are not so satisfying. So, I would like to try a *Bayesian method *for the parameter estimation of the Hidden Markov model. Could anyone kindly tell me which R package can perform Bayesian estimation of the model? Many thanks for your help and time. Best Regards, James Allan -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p442394 6 . html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Oscar M. Rueda, PhD. Postdoctoral Research Fellow, Breast Cancer Functional Genomics. Cancer Research UK Cambridge Research Institute. Li Ka Shing Centre, Robinson Way. Cambridge CB2 0RE England NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for ...{{dropped:16}} __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion
Re: [R] Bayesian Hidden Markov Models
Dear James, Basically you just need the values (y) and the positions (in your case it would be the index of the times series). The chromosome argument does not apply to your case so it can be a vector of ones. If the positions are at the same distance between (equally spaced) then the model will be homogeneous. So for example something like this would be enough: library(RJaCGH) y - c(rnorm(100,0,1), rnorm(20, 2, 1), rnorm(50, 0, 1)) Pos - 1:length(y) Chrom - rep(1, length(y)) res - RJaCGH(y=y, Pos=Pos, Chrom=Chrom) summary(res) However, it uses a Reversible Jump algorithm and therefore jumps between models with different hidden states. I would suggest you take a look at the vignette that comes with the package or the paper that is referenced there for specific details of the model it fits. Hope it helps, Oscar On 28/2/12 04:52, monkeylan lanjin...@yahoo.com.cn wrote: Dear Doctor Oscar, Sorry for not noticing that you are the author of the RJaCGH package. But I noticed that hidden Markov model in your package is with non-homogeneous transition probabilities. Here in my work, the HMM is just a first-order homogeneous Markov chain, i.e. the transition matrix is constant. So, Could you please tell me how can I adjust the R functions in your package to implement my analysis? Best Regards, James Allan --- 12年2月27日,周一, Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com 写道: 发件人: Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com 主题: Re: Bayesian Hidden Markov Models 收件人: monkeylan lanjin...@yahoo.com.cn 日期: 2012年2月27日,周一,下午6:05 Dear James, Although designed for the analysis of copy number CGH microarrays, RJaCGH uses a Bayesian HMM model. Cheers, Oscar On 27/2/12 08:32, monkeylan [hidden email] wrote: Dear R buddies, Recently, I attempt to model the US/RMB Exchange rate log-return time series with a *Hidden Markov model (first order Markov Chain mixed Normal distributions). * I have applied the RHmm package to accomplish this task, but the results are not so satisfying. So, I would like to try a *Bayesian method *for the parameter estimation of the Hidden Markov model. Could anyone kindly tell me which R package can perform Bayesian estimation of the model? Many thanks for your help and time. Best Regards, James Allan -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946 . html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Oscar M. Rueda, PhD. Postdoctoral Research Fellow, Breast Cancer Functional Genomics. Cancer Research UK Cambridge Research Institute. Li Ka Shing Centre, Robinson Way. Cambridge CB2 0RE England NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for ...{{dropped:16}} __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below:http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p44 24152.html To unsubscribe from Bayesian Hidden Markov Models, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4427000. html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] Oscar M. Rueda, PhD. Postdoctoral Research Fellow, Breast Cancer Functional Genomics. Cancer Research UK Cambridge Research Institute. Li Ka Shing Centre, Robinson Way. Cambridge CB2 0RE England NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for the above-named person(s). If you are not the intended recipient, notify the sender immediately, delete this email from your system and do not disclose or use for any purpose. We may monitor all incoming and outgoing emails in line with current legislation. We have taken steps to ensure that this email and attachments are free from any virus, but it remains your responsibility to ensure that viruses do not adversely affect you. Cancer Research UK Registered in England and Wales Company Registered Number: 4325234. Registered Charity Number: 1089464 and Scotland SC041666 Registered Office Address: Angel Building, 407 St John Street, London EC1V 4AD. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] Bayesian Hidden Markov Models
Dear Oscar,  I am extremely grateful to your help and detailed explanation of the use of RJaCGH package. But, when runing the sample codes you listed, another issue I am a little confused is as following: After runing summary(res), I have got the estimation of the random matrix Beta: Parameters of the transition functions:       Normal Gain Normal 0.000 4.258 Gain   2.001 0.000  But, the transition probabilty matrix Q based on the aboving Beta is more concerned in my modeling. Here, I am not sure how can I get the matrix Q. I did try the Q.NH functions.However, Shoud I set the distance parameter x be 1 or 0? I am not sure.   If 1( according to my own understanding), the following result seems not reseanable.  tran-matrix(c(0,2.001,4.528,0),2,2) Q.NH(beta=tran, x=1)     [,1] [,2] [1,] 0.5 0.5 [2,] 0.5 0.5  Many thanks for your further help and time.  James Allan --- 12å¹´2æ28æ¥ï¼å¨äº, Oscar Rueda [via R] ml-node+s789695n4427760...@n4.nabble.com åéï¼ å件人: Oscar Rueda [via R] ml-node+s789695n4427760...@n4.nabble.com 主é¢: Re: Bayesian Hidden Markov Models æ¶ä»¶äºº: monkeylan lanjin...@yahoo.com.cn æ¥æ: 2012å¹´2æ28æ¥,å¨äº,ä¸å7:02 Dear James, Basically you just need the values (y) and the positions (in your case it would be the index of the times series). The chromosome argument does not apply to your case so it can be a vector of ones. If the positions are at the same distance between (equally spaced) then the model will be homogeneous. So for example something like this would be enough: library(RJaCGH) y - c(rnorm(100,0,1), rnorm(20, 2, 1), rnorm(50, 0, 1)) Pos - 1:length(y) Chrom - rep(1, length(y)) res - RJaCGH(y=y, Pos=Pos, Chrom=Chrom) summary(res) However, it uses a Reversible Jump algorithm and therefore jumps between models with different hidden states. I would suggest you take a look at the vignette that comes with the package or the paper that is referenced there for specific details of the model it fits. Hope it helps, Oscar  On 28/2/12 04:52, monkeylan [hidden email] wrote: Dear Doctor Oscar,  Sorry for not noticing that you are the author of the RJaCGH package. But I noticed that hidden Markov model in your package is with non-homogeneous transition probabilities. Here in my work, the HMM is just a first-order homogeneous Markov chain, i.e. the  transition  matrix is constant.  So, Could you please tell me how can I adjust the R functions in your package to implement my analysis?  Best Regards,  James Allan --- 12å¹´2æ27æ¥ï¼å¨ä¸, Oscar Rueda [via R] [hidden email] åéï¼ å件人: Oscar Rueda [via R] [hidden email] 主é¢: Re: Bayesian Hidden Markov Models æ¶ä»¶äºº: monkeylan [hidden email] æ¥æ: 2012å¹´2æ27æ¥,å¨ä¸,ä¸å6:05 Dear James, Although designed for the analysis of copy number CGH microarrays, RJaCGH uses a Bayesian HMM model. Cheers, Oscar On 27/2/12 08:32, monkeylan [hidden email] wrote: Dear R buddies, Recently, I attempt to model the US/RMB Exchange rate log-return time series with a *Hidden Markov model (first order Markov Chain mixed Normal distributions). * I have applied the RHmm package to accomplish this task, but the results are not so satisfying. So, I would like to try a *Bayesian method *for the parameter estimation of the Hidden Markov model. Could anyone kindly tell me which R package can perform Bayesian estimation of the model? Many thanks for your help and time. Best Regards, James Allan -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946 . html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Oscar M. Rueda, PhD. Postdoctoral Research Fellow, Breast Cancer Functional Genomics. Cancer Research UK Cambridge Research Institute. Li Ka Shing Centre, Robinson Way. Cambridge CB2 0RE England NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for ...{{dropped:16}} __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below:http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p44 24152.html To unsubscribe from Bayesian Hidden Markov Models, click here. NAML -- View this message in
[R] Bayesian Hidden Markov Models
Dear R buddies, Recently, I attempt to model the US/RMB Exchange rate log-return time series with a *Hidden Markov model (first order Markov Chain mixed Normal distributions). * I have applied the RHmm package to accomplish this task, but the results are not so satisfying. So, I would like to try a *Bayesian method *for the parameter estimation of the Hidden Markov model. Could anyone kindly tell me which R package can perform Bayesian estimation of the model? Many thanks for your help and time. Best Regards, James Allan -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bayesian Hidden Markov Models
Dear James, Although designed for the analysis of copy number CGH microarrays, RJaCGH uses a Bayesian HMM model. Cheers, Oscar On 27/2/12 08:32, monkeylan lanjin...@yahoo.com.cn wrote: Dear R buddies, Recently, I attempt to model the US/RMB Exchange rate log-return time series with a *Hidden Markov model (first order Markov Chain mixed Normal distributions). * I have applied the RHmm package to accomplish this task, but the results are not so satisfying. So, I would like to try a *Bayesian method *for the parameter estimation of the Hidden Markov model. Could anyone kindly tell me which R package can perform Bayesian estimation of the model? Many thanks for your help and time. Best Regards, James Allan -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946. html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Oscar M. Rueda, PhD. Postdoctoral Research Fellow, Breast Cancer Functional Genomics. Cancer Research UK Cambridge Research Institute. Li Ka Shing Centre, Robinson Way. Cambridge CB2 0RE England NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for ...{{dropped:16}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bayesian Hidden Markov Models
Dear Oscar,  I really appreciate your help for my problem. I have taken a look at the R package RJaCGH you mentioned roughly, but I am really a little confused by the CGH microarrays background of the package. Actually, I am a graduate student, majoring Mathematical Statistics. So, I know nothing about the CGH microarrays.  Have you ever used the RJaCGH package before? If so, could you please briefly tell me how to use RJaCGH to implement a Bayesian Hidden Markov Models for my univariate time series?  Thanks again for your patience and time.  Best Regards,  James Allan  --- 12å¹´2æ27æ¥ï¼å¨ä¸, Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com åéï¼ å件人: Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com 主é¢: Re: Bayesian Hidden Markov Models æ¶ä»¶äºº: monkeylan lanjin...@yahoo.com.cn æ¥æ: 2012å¹´2æ27æ¥,å¨ä¸,ä¸å6:05 Dear James, Although designed for the analysis of copy number CGH microarrays, RJaCGH uses a Bayesian HMM model. Cheers, Oscar On 27/2/12 08:32, monkeylan [hidden email] wrote: Dear R buddies, Recently, I attempt to model the US/RMB Exchange rate log-return time series with a *Hidden Markov model (first order Markov Chain mixed Normal distributions). * I have applied the RHmm package to accomplish this task, but the results are not so satisfying. So, I would like to try a *Bayesian method *for the parameter estimation of the Hidden Markov model. Could anyone kindly tell me which R package can perform Bayesian estimation of the model? Many thanks for your help and time. Best Regards, James Allan -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946. html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Oscar M. Rueda, PhD. Postdoctoral Research Fellow, Breast Cancer Functional Genomics. Cancer Research UK Cambridge Research Institute. Li Ka Shing Centre, Robinson Way. Cambridge CB2 0RE England NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for ...{{dropped:16}} __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below:http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4424152.html To unsubscribe from Bayesian Hidden Markov Models, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4426601.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bayesian Hidden Markov Models
Dear Doctor Oscar,  Sorry for not noticing that you are the author of the RJaCGH package. But I noticed that hidden Markov model in your package is with non-homogeneous transition probabilities. Here in my work, the HMM is just a first-order homogeneous Markov chain, i.e. the transition matrix is constant.  So, Could you please tell me how can I adjust the R functions in your package to implement my analysis?  Best Regards,  James Allan --- 12å¹´2æ27æ¥ï¼å¨ä¸, Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com åéï¼ å件人: Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com 主é¢: Re: Bayesian Hidden Markov Models æ¶ä»¶äºº: monkeylan lanjin...@yahoo.com.cn æ¥æ: 2012å¹´2æ27æ¥,å¨ä¸,ä¸å6:05 Dear James, Although designed for the analysis of copy number CGH microarrays, RJaCGH uses a Bayesian HMM model. Cheers, Oscar On 27/2/12 08:32, monkeylan [hidden email] wrote: Dear R buddies, Recently, I attempt to model the US/RMB Exchange rate log-return time series with a *Hidden Markov model (first order Markov Chain mixed Normal distributions). * I have applied the RHmm package to accomplish this task, but the results are not so satisfying. So, I would like to try a *Bayesian method *for the parameter estimation of the Hidden Markov model. Could anyone kindly tell me which R package can perform Bayesian estimation of the model? Many thanks for your help and time. Best Regards, James Allan -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946. html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Oscar M. Rueda, PhD. Postdoctoral Research Fellow, Breast Cancer Functional Genomics. Cancer Research UK Cambridge Research Institute. Li Ka Shing Centre, Robinson Way. Cambridge CB2 0RE England NOTICE AND DISCLAIMER This e-mail (including any attachments) is intended for ...{{dropped:16}} __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below:http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4424152.html To unsubscribe from Bayesian Hidden Markov Models, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4427000.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.