I wrote this simple function:
"ct.planning"<-
function( tev, tref, mc, hratio, accrual, tmin, nc.c = 0, nc.i = 0 )
{
totp<-uniroot( function(x) e.ev( tref, mc, hratio, x, accrual, tmin,
nc.c,
nc.i ) - tev, c(1,50000))$root
totp
}
(Note that e.ev is another function that I wrote and it works well).
When I make a call to ct.planning, an error occurs:
Error in f(1): Object "mc" not found
I include the function e.ev also:
"e.ev"<-
function(tref, mc, hratio, yr.acc, accrual, tmin, nc.c = 0, nc.i = 0)
{
label <- c("Control", "Intervention")
#Find exponential hazard for control group
lamc <- - log(1 - mc)/tref
lamc.c <- lamc + nc.c/100
#Find exponential hazard and mortality for intervention group
lami <- lamc * hratio
lami.c <- lami + nc.i/100
mi <- 1 - exp( - lami * tref)
#Find expected deaths in control group
edc <- ((yr.acc * accrual * lamc)/(2 * lamc.c)) * (1 - exp( - lamc.c *
tmin)/(lamc.c *
accrual) * (1 - exp( - lamc.c * accrual)))
edi <- ((yr.acc * accrual * lami)/(2 * lami.c)) * (1 - exp( - lami.c *
tmin)/(lami.c *
accrual) * (1 - exp( - lami.c * accrual)))
ed <- c(edc, edi)
names(ed) <- label
cat("\nNumber of expected deaths\n")
print(ed)
cat("\nNumber of total expected deaths\n")
c(Total = edc + edi)
}
Any and all suggestions are welcome.
Thanks in advance to all.
Luca Boni
\\\|///
\\ - - //
( @ @ )
----o00o-(_)-o00o----------------------------------------------------
Luca Boni, MD
Unit of Clinical Epidemiology and Trials
Advanced Biotechnology Center-National Institute for Cancer Research
GENOVA-ITALY
Tel.: +39 10 5737477
Portable Tel.: +39 335 6777997
E-mail: boni@ermes.cba.unige.it
Ooooo
----ooooO----( )---------------------------------------------------
( ) ) /
\ ( (_/
\_)
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|