Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: assignment by indexing


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: assignment by indexing
Date   Wed, 4 Feb 2004 11:19:37 -0500

if p1, p2, etc.. just represent the same quantities at different times, I'm
not sure why you don't reshape long?

reshape long p, i(idvar) j(time)

then all your statements could be done in 2 steps:

replace p=invlogit(`lgtp1' ) in 1
replace p=p[_n-1]*`ka'+(1-p[_n-1])*`mu' in 2/l

Michael Blasnik
[email protected]

----- Original Message ----- 
From: "Ben Pelzer" <[email protected]>
To: <[email protected]>
Sent: Wednesday, February 04, 2004 9:10 AM
Subject: RE: st: assignment by indexing


> Nick,
>
> Your answer yesterday was clear. I was looking for a neat way to solve the
> problem, but finally decided to use the following set of commands for a
> similar, yet smaller, problem of only 13 timepoints:
>
>   quietly replace   `p1' = invlogit(`lgtp1');
>   quietly replace   `p2'  = `p1'  * `ka' + (1-`p1'  ) * `mu'
>   quietly replace   `p3'  = `p2'  * `ka' + (1-`p2'  ) * `mu'
>   quietly replace   `p4'  = `p3'  * `ka' + (1-`p3'  ) * `mu'
>   quietly replace   `p5'  = `p4'  * `ka' + (1-`p4'  ) * `mu'
>   quietly replace   `p6'  = `p5'  * `ka' + (1-`p5'  ) * `mu'
>   quietly replace   `p7'  = `p6'  * `ka' + (1-`p6'  ) * `mu'
>   quietly replace   `p8'  = `p7'  * `ka' + (1-`p7'  ) * `mu'
>   quietly replace   `p9'  = `p8'  * `ka' + (1-`p8'  ) * `mu'
>   quietly replace   `p10' = `p9'  * `ka' + (1-`p9'  ) * `mu'
>   quietly replace   `p11' = `p10' * `ka' + (1-`p10' ) * `mu'
>   quietly replace   `p12' = `p11' * `ka' + (1-`p11' ) * `mu'
>   quietly replace   `p13' = `p12' * `ka' + (1-`p12' ) * `mu'
>
> Here, ka and mu are the transition probs. Of course, following your
> matrix-suggestion would solve all problems but also cause some extra work,
> while copying statements is very fast... I didn't know the 'egen'
statement,
> so, I'll have a look at it right away. Thanks again, Ben.
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index