Folks,
I am holding a dataset where firms are observed for a fixed (and
small) set of years. The data is in "long" format - one record for one
firm for one point in time. A state variable is observed (a factor).
I wish to make a markov transition matrix about the time-series
evolution of that sta
Is this what you want:
set.seed(1001)
# Raw data in long format --
raw <- data.frame(name=c("f1","f1","f1","f1","f2","f2","f2","f2"),
year=c(83, 84, 85, 86, 83, 84, 85, 86),
state=sample(1:3, 8, replace=TRUE)
)
# Shift to wide format --
Ignore last reply. I sent the wrong script.
> set.seed(1001)
>
> # Raw data in long format --
> raw <- data.frame(name=c("f1","f1","f1","f1","f2","f2","f2","f2"),
+ year=c(83, 84, 85, 86, 83, 84, 85, 86),
+ state=sample(1:3, 8, replace=TRUE)
+
to:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim holtman
Sent: Sunday, 22 January 2006 11:20 AM
To: Ajay Narottam Shah
Cc: R-help
Subject: Re: [R] Making a markov transition matrix
I
See:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/42934.html
On 1/21/06, Ajay Narottam Shah <[EMAIL PROTECTED]> wrote:
> Folks,
>
> I am holding a dataset where firms are observed for a fixed (and
> small) set of years. The data is in "long" format - one record for one
> firm for one point in
On Sun, Jan 22, 2006 at 01:47:00PM +1100, [EMAIL PROTECTED] wrote:
> If this is a real problem, here is a slightly tidier version of the
> function I gave on R-help:
>
> transitionM <- function(name, year, state) {
> raw <- data.frame(name = name, state = state)[order(name, year), ]
> raw01 <-
om: Ajay Narottam Shah [mailto:[EMAIL PROTECTED]
Sent: Sunday, 22 January 2006 5:15 PM
To: R-help
Cc: [EMAIL PROTECTED]; Venables, Bill (CMIS, Cleveland)
Subject: Re: [R] Making a markov transition matrix
On Sun, Jan 22, 2006 at 01:47:00PM +1100, [EMAIL PROTECTED] wrote:
> If this is a real p
Ajay--you seem to have gotten your question answered regarding putting your
dataframe in the correct format, etc. If you haven't already, you might
want to check out the MSM package for multi-state Markov and hidden Markov
models in continuous time. It's been quite useful for some of my work
reg
Ajay,
On a similar note, there are two other packages as well for similar models:
hmm.discnp for hidden Markov models of univariate discrete non-parametric
distributions and depmix for hidden Markov models for multivariate data, ie
gaussians, multinomials etc, and combinations of these
hth, ingmar
I solved the problem in one more (and more elegant) way. So here's the
program again.
Where does R stand on the Anderson-Goodman test of 1957? I hunted
around and nobody seems to be doing this in R. Is it that there has
been much progress after 1957 and nobody uses it anymore?
# Problem statement
10 matches
Mail list logo