Displaying 20 results from an estimated 10000 matches similar to: "Computing and testing transition probabilities?"
2006 Jan 22
6
Making a markov transition matrix
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 state variable. The code below does this. But it's
hardcoded to the specific years that I
2004 Jun 17
2
Question on lists and vectors of lists
I have an elementary programming question. Could someone please point
me in the right direction?
I have a function which will run for thousands of companies. At each
invocation, it returns 2 numbers. I plan to do something like:
think_one_firm <- function(filename) {
# Do stuff
return(list(x=x,y=y))
}
So for each of the firms in my dataset, I will call
2006 Jan 23
0
Making a markov transition matrix - more progress
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:
#
# You are holding a dataset where firms are observed for a fixed
# (and small) set of years.
2006 Jan 19
2
Tobit estimation?
Folks,
Based on
http://www.biostat.wustl.edu/archives/html/s-news/1999-06/msg00125.html
I thought I should experiment with using survreg() to estimate tobit
models.
I start by simulating a data frame with 100 observations from a tobit model
> x1 <- runif(100)
> x2 <- runif(100)*3
> ystar <- 2 + 3*x1 - 4*x2 + rnorm(100)*2
> y <- ystar
> censored <- ystar <= 0
2004 Jul 05
2
Failing on reading a "slightly big" dataset
I have a file with 4 columns per line, all pipe delimited.
$ wc -l cmie_firm_data.text
89325 cmie_firm_data.text
$ ls -al cmie_firm_data.text
-rw-r--r-- 1 ajayshah ajayshah 4415637 Jul 5 15:25 cmie_firm_data.text
$ awk -F\| '(NF != 4)' cmie_firm_data.text
$ head cmie_firm_data.text
All figures are for the year 20030331|||
Company|GVA Less Interest (Rs. thousand)|Interest (Rs.
2007 Aug 31
2
Bugreport on integration of Sweave and latex beamer
I think I have isolated a problem with integration between Sweave and beamer.
Could you please see the file:
http://www.mayin.org/ajayshah/tmp/bugdemo.Rnw
Unfortunately, it uses some of my internal libraries, so you can't run
it. When I put it through Sweave, I get:
http://www.mayin.org/ajayshah/tmp/bugdemo.tex
which is, of course, a generic latex file which you can read and
2005 Dec 06
2
Constructing a transition matrix
Hi,
I would like to construct a transition matrix from a data frame with
annual transitions of marked plants.
plant<-c(1:6)
class<-c("seed","seed", "seed", "veg", "rep", "rep")
fate<-c("dead", "veg","veg","rep", "rep", "veg")
trans<-data.frame(plant, class, fate)
2004 Apr 29
3
Probability(Markov chain transition matrix)
Hello, My name is Maria, MBA student in Sanfransisco, USA.
In my credit scoring class, I have hard time making "transition matrix",
which explains probability especially in relation to "Markov chain model".
It is regarding people's monthly credit payment behavior. Does R have
function to caculate it? I am actually a novice in using 'R'. Please help
me!!!
Maria
2004 Oct 03
3
Making a 'joint distribution'?
Suppose I make two discrete variables --
> D <- data.frame(f1=sample(1:5,100,replace=T), f2=sample(1:5,100,replace=T))
I know I can do:
> table(D$f1, D$f2)
0 1 2 3 4
0 5 5 5 5 4
1 4 2 6 7 3
2 5 3 5 3 6
3 3 1 3 1 2
4 6 4 3 3 6
> table(D$f1)
0 1 2 3 4
24 22 22 10 22
> table(D$f2)
0 1 2 3 4
23 15 22 19 21
which is all great. But how do I produce the
2005 Aug 14
1
Panel data handling (lags, growth rates)
I have written two functions which do useful things with panel data
a.k.a. longitudinal data, where one unit of observation (a firm or a
person or an animal) is observed on a uniform time grid:
- The first function makes lagged values of variables of your choice.
- The second function makes growth rates w.r.t. q observations ago,
for variables of your choice.
These strike me as
2005 Jun 07
1
R and MLE
I learned R & MLE in the last few days. It is great! I wrote up my
explorations as
http://www.mayin.org/ajayshah/KB/R/mle/mle.html
I will be most happy if R gurus will look at this and comment on how
it can be improved.
I have a few specific questions:
* Should one use optim() or should one use stats4::mle()?
I felt that mle() wasn't adding much value compared with optim, and
2008 Mar 18
3
Puzzled at generating combinations
I have two data frames. Suppose the first has rows
r1
r2
r3
and the second has rows
R1
R2
R3
I'd like to generate the data frame:
r1 R1
r1 R2
r1 R3
r2 R1
r2 R2
r2 R3
r3 R1
r3 R2
r3 R3
How would I go about doing this? I'm sure there's a clean way to do it
but I find myself thinking in loops.
--
Ajay Shah
2004 May 27
3
Date parsing question
How do I parse a date "yyyymmdd"? I tried asking chron(s, "ymd") but
that didn't work. Would the date parsing routines of the Date class of
1.9 grok this?
--
Ajay Shah Consultant
ajayshah at mayin.org Department of Economic Affairs
http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
2008 Oct 15
2
"Heuristic optimisation"?
I wondered was people on this list felt about this article:
http://www.voxeu.org/index.php?q=node/2363
which talks about the problems of obtaining sound answers in numerical
optimisation in settings such as MLE or NLS.
--
Ajay Shah http://www.mayin.org/ajayshah
ajayshah at mayin.org http://ajayshahblog.blogspot.com
<*(:-? -
2004 Aug 17
1
An entire data frame which is a time-series?
I have :
raw <- read.table("monthly.text", skip=3, sep="|",
col.names=c("junk", "junk2",
"wpi", "g.wpi", "wpi.primary", "g.wpi.primary",
"wpi.fuel", "g.wpi.fuel", "wpi.manuf", "g.wpi.manuf",
2008 Mar 17
4
How does one do simple string concatenation?
How does one convert objects c("a","b","c") and "d" into "abcd"?
> paste(c("a","b","c"), "d")
of course yields
[1] "a d" "b d" "c d"
--
Ajay Shah http://www.mayin.org/ajayshah
ajayshah at mayin.org
2009 Mar 15
1
Stuck on building a package
Folks,
I have a personal package which used to build fine. Today when I tried
to build the package again, some errors popped up. Could you please
help? When I paste the offending function into an R it works
correctly. But the package build breaks.
$ R CMD check ansecon
* checking for working pdflatex ... OK
* using log directory '/Users/ajayshah/L/R/packages/ansecon.Rcheck'
* using R
2007 May 27
0
Not able to understand the behaviour of boot
Folks,
I have a time-series of 875 readings of the weekly returns of a stock
market index (India's Nifty). I am interested in the AR(1)
coefficient. When I do arima(r, order=c(1,0,0)) I get a statistically
significant AR1 coefficient.
If we apply the ordinary bootstrap to this problem, this involves
sampling with replacement, which destroys the time-series
structure. Hence, if we do
2004 Jun 13
0
MCMC tutorials
Hi Ajay:
A casual search of google using terms like "MCMC", "Markov Chains", "Monte
Carlo", and "tutorial" pulled up over 4000 hits. A few links that may
interest you, I thought, like:
http://csep1.phy.ornl.gov/CSEP/MC/MC.html
http://www.stat.fi/isi99/proceedings/arkisto/varasto/gree0167.pdf
http://www.maths.soton.ac.uk/staff/Sahu/utrecht/
...
and so
2007 Oct 28
1
maximizing a function
See
http://mayin.nfshost.com/ajayshah/KB/R/documents/mle/mle.html
--
Ajay Shah http://www.mayin.org/ajayshah
ajayshah at mayin.org http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.