Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Stata and R


From   Tirthankar Chakravarty <[email protected]>
To   [email protected]
Subject   Re: st: Stata and R
Date   Thu, 27 Aug 2009 10:07:43 +0100

<>

While I do not know anything about cost-effectiveness curves, here is
how the R script translates to Mata:
******************************
webuse frontier2, clear
mata
st_view(X=., ., ("lnp_l", "lncost"))
out = J(rows(X)+1, 1000, .)  // allocate the output matrix
for(i=1; i<=1000; i++)
{
	inb = X[.,1]*i -X[.,2]
	probCE = rows(select(inb, inb:>=0))/rows(X)
	out[,i] = (i \inb)  // fill it in
}
end
******************************


On Thu, Aug 27, 2009 at 6:44 AM, Frank Peter<[email protected]> wrote:
> Dear All,
>
> This is to thank everybody for all their answers, I have really learn a lot from the answers.
>
> I was trying to generate cost-effectiveness acceptability curve. The R codes I was referring to were:
> ========================================
> ceac = c()
> denom  = length(effectiveness)
> for  (n in 1000) {
>  INB = effectiveness*n - cost
>  ProbCE = length(subset(INB, INB>=0))/denom
>  ceac = rbind(ceac, c(n, INB))
> }
> ========================================
>
> Thanks
>
> Frank
> reference:
> Fenwick E, Marshall DA, Levy AR, Nichol G.     Using and interpreting cost-effectiveness acceptability curves: an example using data from a trial of management strategies for atrial fibrillation. BMC Health Serv Res. 2006 Apr 19;6:52. (http://www.biomedcentral.com/1472-6963/6/52)
>
> -------- Original Message --------
> From: Neil Shephard <[email protected]>
> Apparently from: [email protected]
> To: [email protected]
> Subject: Re: st: Stata and R
> Date: Wed, 26 Aug 2009 15:53:20 +0100
>
>> On Wed, Aug 26, 2009 at 3:44 PM, Nick Cox<[email protected]> wrote:
>> > Nothing in R restricts the idea of length to time series.
>> >
>>
>> Indeed, from ?length...
>>
>> length                 package:base                 R Documentation
>>
>> Length of an Object
>>
>> Description:
>>
>>      Get or set the length of vectors (including lists) and factors,
>>      and of any other R object for which a method has been defined.
>>
>> Usage:
>>
>>      length(x)
>>      length(x) <- value
>>
>> Arguments:
>>
>>        x: an R object.  For replacement, a vector or factor.
>>
>>    value: an integer.
>>
>> Details:
>> .....
>>
>>
>> --
>> "The combination of some data and an aching desire for an answer does
>> not ensure that a reasonable answer can be extracted from a given body
>> of data." ~ John Tukey (1986), "Sunset salvo". The American
>> Statistician 40(1).
>>
>> Email - [email protected]
>> Website - http://slack.ser.man.ac.uk/
>> Photos - http://www.flickr.com/photos/slackline/
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>



-- 
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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