-3

I have a homework about an article and the result must be in interval (0.10024, 1.0917).

As a concrete example we took the data of remission times for solid tumor patients (n=10), which is a slightly modified (breaktie) version of Statistical Methods for Survival Data Analysis, Elisa T. Lee, 1992, Example 4.2:

3, 6.5, 6.51, 10, 12, 15, 8.4+, 4+,5.7+, and 10+.

Suppose we are interested in getting a 95% confidence interval for the cumulative hazard at the time t = 9.8, ∆o (9.8). Hence θo=∆o(9.8). In this case the function g is an indicator function: g(t)=I[t9.8].

The 95% confidence interval using the empirical likelihood ratio, -2logALR, for ∆o (9.8) is (0.10024, 1.0917)
please help me to get result above. Thank you.

remissiontime<-(3,4,5.7,6.5,6.51,8.4,10,10,12,15) 
status <- c(1,0,0,1,1,0,1,0,1,1)

and my code is (actually I am not sure about this code)

library(survival)
library(emplik)
x1 = c(3,4,5.7,6.5,6.51,8.4,10,10,12,15) 
d1 = c(1,0,0,1,1,0,1,0,1,1)

KM0 <- survfit(Surv(x1,d1) ~ 1,  type="kaplan-meier", conf.type="log")
summary(KM0)

myfun <-function(t){as.numeric(t <=9.8)}

emplikH1.test(x=x1,d=d1,theta=-log(0.643),fun=myfun)


myULfun <-function(theta,x,d){

  emplikH1.test(x=x1,d=d1,theta=theta,fun=function(t){as.numeric(t <= 9.8)})}

findUL(fun=myULfun,MLE =-log(0.643),x=x1,d=d1)
Artem
  • 3,304
  • 3
  • 18
  • 41
  • 1
    This is your homework, first try to solve the problem and provide what you did so far then ask for help. – Keivan Esbati Apr 21 '19 at 06:19
  • i provided what i have done so for as you can see above. – user3043662 Apr 21 '19 at 06:29
  • 1
    It seems you just copied this code from somewhere. What do you mean you're not sure about it? – NelsonGon Apr 21 '19 at 06:43
  • i couldn't figure it out why it doest work i am not experienced thats why i asked maybe someone who can really help. if i was sure about code, dont worry would not write here. please help if you know, and sorry about lack of knowledge. – user3043662 Apr 21 '19 at 06:51
  • 2
    Welcome to SO. Your answer seems to have attracted quite a few negative votes. People who answer on SO are individuals in their free time, as such a properly formatted question is likely to attract better responses. As other comments have suggested, your question is very messy, and it is about a homework assignment. Please check out [how do i ask](https://stackoverflow.com/help/how-to-ask) and [How to make a good reproducible R example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and edit your question to their suggestions. – Oliver Apr 21 '19 at 07:10
  • 2
    In order to further help, as it is about a homework assignment, many feel strongly about these. Questions that try to obtain full answers are often downvoted and possibly not given an answer. I'd suggest reading the [Asking about homework](https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions) (first answer), which will give you a few pointers how to get good answers to homework questions, rather then receiving negative feedback (No negative feedback is not guaranteed). – Oliver Apr 21 '19 at 07:17
  • As far as I can see the `myULfun`-function "needs" a theta argument. I do not see that you are giving any value. Perhaps the error message is a bit misleading when it says `"given theta is too far away from theta0"` since it suggests that a value was actually given. – IRTFM Apr 22 '19 at 06:07

1 Answers1

0

The last line of the code you presented

findUL(fun=myULfun,MLE =-log(0.643),x=x1,d=d1)

throws an error:

Error in emplikH1.test(x = x1, d = d1, theta = theta, fun = function(t) { : given theta is too far away from theta0

Changing MLE argument of findUL from -log(0.643) to 1 cure the issue. Please see the below:

findUL(fun = myULfun, MLE = 1, x = x1, d = d1)

Output, which coincides with the one required:

$`Low`
[1] 0.1002516

$Up
[1] 1.09165

$FstepL
[1] 6.103516e-05

$FstepU
[1] 6.103516e-05

$Lvalue
[1] 3.839313

$Uvalue
[1] 3.839971
Artem
  • 3,304
  • 3
  • 18
  • 41