How to use depmix for HMM with intial parameters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use depmix for HMM with intial parameters

Niharika
This post was updated on .
Hello,

I have initial parameters for HMM model and I want to use depmixS4 package.
The parameters are in the form

intial_prob_matrix=matrix(c(0.07614213, 0.45177665, 0.47208122), nrow=1,
ncol=3, byrow = TRUE)

transition_matrix=matrix(c(0.46666667,0.46666667,0.06666667,
                     0.06741573,0.5617978,0.37078652,
                     0.02173913,0.3478261,0.63043478), nrow = 3, ncol = 3,
byrow = TRUE)

meanval_matrix=matrix(c(545.1737,545.1737,803.5235,
                        565.7763,673.8019,797.5283,
                        733.9332,1006.3571,1383.5395), nrow = 3, ncol = 3,
byrow = TRUE)

sigmaval_matrix=matrix(c(82.19592,13.64243,57.07868,
                         65.32724,13.38910,81.66209,
                         97.62573,71.09579,115.55612), nrow = 3, ncol = 3,
byrow = TRUE)

coeffval_matrix=matrix(c(0.1295604,0.6464059,0.2240336,
                         0.2091671,0.5267220,0.2641110,
                         0.3430697,0.3350215,0.3219088), nrow = 3, ncol =
3, byrow = TRUE)

emission_matrix=list(meanval_matrix,sigmaval_matrix,coeffval_matrix)

powerdf is a column from my dataset Data which look like something = 19.0, 18.0,
24.0...............it has some 30 thousand rows

I tried  using the code below and got an error
powerdf <- data.frame(power=Data$power)
mod= depmix( response = power~1, data = powerdf, nstates=3,
                           instart=intial_prob_matrix,
trstart=transition_matrix, respstart=emission_matrix)

 Error in makeResponseModels(response = response, data = data, nstates =
nstates,  :
  'respstart' has incorrect length, it should be 6

I cannot change my emission matrix, it would always be list of matrix (mean
, sigma and weighted coefficient mixture)

I thought to change the response but I am unable to figure out the right
response

Can someone guide me how can I solve this problem, by giving the
parameters defined above?

Thanks & Regards
Niharika Singhal

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: How to use depmix for HMM with intial parameters

Ismail SEZEN

> On 20 Sep 2017, at 11:14, niharika singhal <[hidden email]> wrote:
>
> Hello,
>
> I have initial parameters for HMM model and I want to use depmixS4 package.
> The parameters are in the form
>
> intial_prob_matrix=matrix(c(0.07614213, 0.45177665, 0.47208122), nrow=1,
> ncol=3, byrow = TRUE)
>
> transition_matrix=matrix(c(0.46666667,0.46666667,0.06666667,
>                     0.06741573,0.5617978,0.37078652,
>                     0.02173913,0.3478261,0.63043478), nrow = 3, ncol = 3,
> byrow = TRUE)
>
> meanval_matrix=matrix(c(545.1737,545.1737,803.5235,
>                        565.7763,673.8019,797.5283,
>                        733.9332,1006.3571,1383.5395), nrow = 3, ncol = 3,
> byrow = TRUE)
>
> sigmaval_matrix=matrix(c(82.19592,13.64243,57.07868,
>                         65.32724,13.38910,81.66209,
>                         97.62573,71.09579,115.55612), nrow = 3, ncol = 3,
> byrow = TRUE)
>
> coeffval_matrix=matrix(c(0.1295604,0.6464059,0.2240336,
>                         0.2091671,0.5267220,0.2641110,
>                         0.3430697,0.3350215,0.3219088), nrow = 3, ncol =
> 3, byrow = TRUE)
>
> emission_matrix=list(meanval_matrix,sigmaval_matrix,coeffval_matrix)
>
> powerdf is a column from my dataset which look like something = 19.0, 18.0,
> 24.0...............it has some 30 thousand rows
>
> I tried  using the code below and got an error
>
> mod= depmix( response = power~1, data = powerdf, nstates=3,
>                           instart=intial_prob_matrix,
> trstart=transition_matrix, respstart=emission_matrix)
>
> Error in makeResponseModels(response = response, data = data, nstates =
> nstates,  :
>  'respstart' has incorrect length, it should be 6
>
> I cannot change my emission matrix, it would always be list of matrix (mean
> , sigma and weighted coefficient mixture)
>
> I thought to change the response but I am unable to figure out the right
> response
>
> Can someone guide me how can I solve this problem, by giving the
> parameters defined above?
>
> Thanks & Regards
> Niharika Singhal

Hello Niharika,

As this is a very specific statistical question, you also should ask this kind of a question at [1]. You may get faster response.

1- https://stats.stackexchange.com

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.