[R] Problem with paxckage survMisc

2015-03-17 Thread Endy BlackEndy
Hi R users. I would like your help on the following strange, to me,
behavior of the package survMisc.
I have a simple routine, the following:
 proc-function(){
  rm(list=ls())
  library(survMisc)
  d-read.table(C:\\Program
Files\\R\\Data\\Survival\\HosmLem.txt,fill=TRUE,header=TRUE)
  d4-as.factor(d[,4])
  s-survfit(Surv(d[,2], d[,5])~d4)
  ctest-comp(s)$tests
  print(ctest)
}
When I run it as a routine I am  getting the following message:
Error in Surv(d[, 2], d[, 5]) : object 'd' not found
When I run it command-by-command the program works OK.
Any suggestion what it is going wrong?

The first six lines of the data used are

 id Time Age Drug Censorentdateenddate
1  15  460  1 05/15/1990 10/14/1990
2  26  351  0 09/19/1989 03/20/1990
3  38  301  1 04/21/1991 12/20/1991
4  43  301  1 01/03/1991 04/04/1991
5  5   22  360  1 09/18/1989 07/19/1991
6  61  321  0 03/18/1991 04/17/1991

The full data set can be obtained using the command
 d-read.table(http://www.ats.ucla.edu/stat/r/examples/asa/hmohiv.csv;,
sep=,, header = TRUE)

Many thanks
Endy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] survMisc

2015-03-08 Thread Endy BlackEndy
Hi R users. I have some problems with the package “survMisc”. When I am
loading it I am getting the following



 library(survMisc)

Loading required package: survival

Loading required package: splines

Loading required package: km.ci

Loading required package: ggplot2

Loading required package: data.table

data.table 1.9.4  For help type: ?data.table

*** NB: by=.EACHI is now explicit. See README to restore previous behaviour.

Loading required package: gridExtra

Loading required package: grid

Loading required package: rpart



Attaching package: ‘survMisc’



The following objects are masked from ‘package:stats’:



AIC, BIC, median, quantile



   In the above output I noticed the line with the three stars (*). In
order to restore the data.table in its previous behavior I tried to locate
the README file but I couldn’t.

   I ignored that NB in the previous output and I continue to run the
example given in the above mentioned package for the routine comp(). The
commands and the output are given below.

 ### 2 curves

 data(kidney,package=KMsurv)

 s1 - survfit(Surv(time=time, event=delta) ~ type, data=kidney )

 comp(s1)

$tne

   t  n  e   n_type=1   e_type=1   n_type=2   e_type=2

 1:  1.586 2   431
431

 2:  3.580 2   401
401

 3:  4.572 4   362
362

 4:  5.566 2   331
331

 5:  8.560 4   302  30
   2

 6:  9.554 2   271
271

 7: 10.5   50 2   251
251

 8: 11.544 2   22   1
221

 9: 15.528 4   14   2
142

10: 16.5   26 2   13   1
131

11: 18.5   22 2   11   1
  111

12: 23.5 8 24 1
41

13: 26.5 6 23 1
31



$tests

$tests$lrTests

ChiSq df p

Log-rank0  1 1

Gehan-Breslow (mod~ Wilcoxon) 0  1 1

Tarone-Ware  0  1 1

Peto-Peto  0  1 1

Mod~ Peto-Peto (Andersen)0  1 1

Flem~-Harr~ with p=1, q=1  0  1 1



$tests$supTests

 Q p

Log-rank 0 1

Gehan-Breslow (mod~ Wilcoxon)  0 1

Tarone-Ware   0 1

Peto-Peto   0 1

Mod~ Peto-Peto (Andersen) 0 1

Renyi Flem~-Harr~ with p=1, q=1 0 1



Notice the zeros (0) that corresponds to the test statistics. (To my
opinion those zeros are strongly related to the NB above).

   Next I noticed the following strange, to my opinion, thing.  More
precisely I have written the following
routine

proc-function(){

 rm(list=ls())

 library(survMisc)

 d-read.table(C:\\Program
Files\\R\\Data\\Survival\\HosmLem.txt,fill=TRUE,header=TRUE)

 d4-as.factor(d[,4])

 s-survfit(Surv(d[,2], d[,5])~d4)

 ctest-comp(s)$tests

 print(ctest)

}

The data used are those of Hosmer and Lemeshow book on Applied Survival
Analysis. The first rows of this data set follow.

id Time Age Drug Censorentdateenddate

  15  460  1   05/15/1990 10/14/1990

  26  351  0   09/19/1989 03/20/1990

  38  301  1   04/21/1991 12/20/1991

  43  301  1   01/03/1991 04/04/1991

  5   22  360  1   09/18/1989 07/19/1991

  61  321  003/18/1991 04/17/1991

When I run the function proc() I am getting the answer

 proc()

Error in Surv(d[, 2], d[, 5]) : object 'd' not found

In contrast when I run the same routine command-by-command I am getting the
following output

$lrTests

 ChiSq df p

Log-rank 0  1 1

Gehan-Breslow (mod~ Wilcoxon)  0  1 1

Tarone-Ware   0  1 1

Peto-Peto   0  1 1

Mod~ Peto-Peto (Andersen) 0  1 1

Flem~-Harr~ with p=1, q=1   0  1 1



$supTests

  Q p

Log-rank  0 1

Gehan-Breslow (mod~ Wilcoxon)   0 1

Tarone-Ware0 1

Peto-Peto0 1

Mod~ Peto-Peto (Andersen)  0 1


[R] survMisc package

2015-03-08 Thread Endy BlackEndy
Hi R users. I have some problems with the package “survMisc”. When I am
loading it I am getting the following



 library(survMisc)

Loading required package: survival

Loading required package: splines

Loading required package: km.ci

Loading required package: ggplot2

Loading required package: data.table

data.table 1.9.4  For help type: ?data.table

*** NB: by=.EACHI is now explicit. See README to restore previous behaviour.

Loading required package: gridExtra

Loading required package: grid

Loading required package: rpart



Attaching package: ‘survMisc’



The following objects are masked from ‘package:stats’:



AIC, BIC, median, quantile



   In the above output I noticed the line with the three stars (*). In
order to restore the data.table in its previous behavior I tried to locate
the README file but I couldn’t.

   I ignored that NB in the previous output and I continue to run the
example given in the above mentioned package for the routine comp(). The
commands and the output are given below.

 ### 2 curves

 data(kidney,package=KMsurv)

 s1 - survfit(Surv(time=time, event=delta) ~ type, data=kidney )

 comp(s1)

$tne

   t  n  e   n_type=1   e_type=1   n_type=2   e_type=2

 1:  1.586 2   431
431

 2:  3.580 2   401
401

 3:  4.572 4   362
362

 4:  5.566 2   331
331

 5:  8.560 4   302  30
   2

 6:  9.554 2   271
271

 7: 10.5   50 2   251
251

 8: 11.544 2   22   1
221

 9: 15.528 4   14   2
142

10: 16.5   26 2   13   1
131

11: 18.5   22 2   11   1
  111

12: 23.5 8 24 1
41

13: 26.5 6 23 1
31



$tests

$tests$lrTests

ChiSq df p

Log-rank0  1 1

Gehan-Breslow (mod~ Wilcoxon) 0  1 1

Tarone-Ware  0  1 1

Peto-Peto  0  1 1

Mod~ Peto-Peto (Andersen)0  1 1

Flem~-Harr~ with p=1, q=1  0  1 1



$tests$supTests

 Q p

Log-rank 0 1

Gehan-Breslow (mod~ Wilcoxon)  0 1

Tarone-Ware   0 1

Peto-Peto   0 1

Mod~ Peto-Peto (Andersen) 0 1

Renyi Flem~-Harr~ with p=1, q=1 0 1



Notice the zeros (0) that corresponds to the test statistics. (To my
opinion those zeros are strongly related to the NB above).

   Next I noticed the following strange, to my opinion, thing.  More
precisely I have written the following
routine

proc-function(){

 rm(list=ls())

 library(survMisc)

 d-read.table(C:\\Program
Files\\R\\Data\\Survival\\HosmLem.txt,fill=TRUE,header=TRUE)

 d4-as.factor(d[,4])

 s-survfit(Surv(d[,2], d[,5])~d4)

 ctest-comp(s)$tests

 print(ctest)

}

The data used are those of Hosmer and Lemeshow book on Applied Survival
Analysis. The first rows of this data set follow.

id Time Age Drug Censorentdateenddate

  15  460  1   05/15/1990 10/14/1990

  26  351  0   09/19/1989 03/20/1990

  38  301  1   04/21/1991 12/20/1991

  43  301  1   01/03/1991 04/04/1991

  5   22  360  1   09/18/1989 07/19/1991

  61  321  003/18/1991 04/17/1991

When I run the function proc() I am getting the answer

 proc()

Error in Surv(d[, 2], d[, 5]) : object 'd' not found

In contrast when I run the same routine command-by-command I am getting the
following output

$lrTests

 ChiSq df p

Log-rank 0  1 1

Gehan-Breslow (mod~ Wilcoxon)  0  1 1

Tarone-Ware   0  1 1

Peto-Peto   0  1 1

Mod~ Peto-Peto (Andersen) 0  1 1

Flem~-Harr~ with p=1, q=1   0  1 1



$supTests

  Q p

Log-rank  0 1

Gehan-Breslow (mod~ Wilcoxon)   0 1

Tarone-Ware0 1

Peto-Peto0 1

Mod~ Peto-Peto (Andersen)  0 1


[R] survMisc

2015-03-08 Thread Endy BlackEndy
Hi R users. I have some problems with the package “survMisc”. When I am
loading it I am getting the following



 library(survMisc)

Loading required package: survival

Loading required package: splines

Loading required package: km.ci

Loading required package: ggplot2

Loading required package: data.table

data.table 1.9.4  For help type: ?data.table

*** NB: by=.EACHI is now explicit. See README to restore previous behaviour.

Loading required package: gridExtra

Loading required package: grid

Loading required package: rpart



Attaching package: ‘survMisc’



The following objects are masked from ‘package:stats’:



AIC, BIC, median, quantile



   In the above output I noticed the line with the three stars (*). In
order to restore the data.table in its previous behavior I tried to locate
the README file but I couldn’t.

   I ignored that NB in the previous output and I continue to run the
example given in the above mentioned package for the routine comp(). The
commands and the output are given below.

 ### 2 curves

 data(kidney,package=KMsurv)

 s1 - survfit(Surv(time=time, event=delta) ~ type, data=kidney )

 comp(s1)

$tne

   t  n  e   n_type=1   e_type=1   n_type=2   e_type=2

 1:  1.586 2   431
431

 2:  3.580 2   401
401

 3:  4.572 4   362
362

 4:  5.566 2   331
331

 5:  8.560 4   302  30
   2

 6:  9.554 2   271
271

 7: 10.5   50 2   251
251

 8: 11.544 2   22   1
221

 9: 15.528 4   14   2
142

10: 16.5   26 2   13   1
131

11: 18.5   22 2   11   1
  111

12: 23.5 8 24 1
41

13: 26.5 6 23 1
31



$tests

$tests$lrTests

ChiSq df p

Log-rank0  1 1

Gehan-Breslow (mod~ Wilcoxon) 0  1 1

Tarone-Ware  0  1 1

Peto-Peto  0  1 1

Mod~ Peto-Peto (Andersen)0  1 1

Flem~-Harr~ with p=1, q=1  0  1 1



$tests$supTests

 Q p

Log-rank 0 1

Gehan-Breslow (mod~ Wilcoxon)  0 1

Tarone-Ware   0 1

Peto-Peto   0 1

Mod~ Peto-Peto (Andersen) 0 1

Renyi Flem~-Harr~ with p=1, q=1 0 1



Notice the zeros (0) that corresponds to the test statistics. (To my
opinion those zeros are strongly related to the NB above).

   Next I noticed the following strange, to my opinion, thing.  More
precisely I have written the following
routine

proc-function(){

 rm(list=ls())

 library(survMisc)

 d-read.table(C:\\Program
Files\\R\\Data\\Survival\\HosmLem.txt,fill=TRUE,header=TRUE)

 d4-as.factor(d[,4])

 s-survfit(Surv(d[,2], d[,5])~d4)

 ctest-comp(s)$tests

 print(ctest)

}

The data used are those of Hosmer and Lemeshow book on Applied Survival
Analysis. The first rows of this data set follow.

id Time Age Drug Censorentdateenddate

  15  460  1   05/15/1990 10/14/1990

  26  351  0   09/19/1989 03/20/1990

  38  301  1   04/21/1991 12/20/1991

  43  301  1   01/03/1991 04/04/1991

  5   22  360  1   09/18/1989 07/19/1991

  61  321  003/18/1991 04/17/1991

When I run the function proc() I am getting the answer

 proc()

Error in Surv(d[, 2], d[, 5]) : object 'd' not found

In contrast when I run the same routine command-by-command I am getting the
following output

$lrTests

 ChiSq df p

Log-rank 0  1 1

Gehan-Breslow (mod~ Wilcoxon)  0  1 1

Tarone-Ware   0  1 1

Peto-Peto   0  1 1

Mod~ Peto-Peto (Andersen) 0  1 1

Flem~-Harr~ with p=1, q=1   0  1 1



$supTests

  Q p

Log-rank  0 1

Gehan-Breslow (mod~ Wilcoxon)   0 1

Tarone-Ware0 1

Peto-Peto0 1

Mod~ Peto-Peto (Andersen)  0 1


[R] Package survMisc

2015-02-28 Thread Endy BlackEndy
Hi R users. I have some problems with the package “survMisc”. When I am
loading it I am getting the following



 library(survMisc)

Loading required package: survival

Loading required package: splines

Loading required package: km.ci

Loading required package: ggplot2

Loading required package: data.table

data.table 1.9.4  For help type: ?data.table

*** NB: by=.EACHI is now explicit. See README to restore previous behaviour.

Loading required package: gridExtra

Loading required package: grid

Loading required package: rpart



Attaching package: ‘survMisc’



The following objects are masked from ‘package:stats’:



AIC, BIC, median, quantile



   In the above output I noticed the line with the three stars (*). In
order to restore the data.table in its previous behavior I tried to locate
the README file but I couldn’t.

   I ignored that NB in the previous output and I continue to run the
example given in the above mentioned package for the routine comp(). The
commands and the output are given below.

 ### 2 curves

 data(kidney,package=KMsurv)

 s1 - survfit(Surv(time=time, event=delta) ~ type, data=kidney )

 comp(s1)

$tne

   t  n  e   n_type=1   e_type=1   n_type=2   e_type=2

 1:  1.586 2   431
431

 2:  3.580 2   401
401

 3:  4.572 4   362
362

 4:  5.566 2   331
331

 5:  8.560 4   302  30
   2

 6:  9.554 2   271
271

 7: 10.5   50 2   251
251

 8: 11.544 2   22   1
221

 9: 15.528 4   14   2
142

10: 16.5   26 2   13   1
131

11: 18.5   22 2   11   1
  111

12: 23.5 8 24 1
41

13: 26.5 6 23 1
31



$tests

$tests$lrTests

ChiSq df p

Log-rank0  1 1

Gehan-Breslow (mod~ Wilcoxon) 0  1 1

Tarone-Ware  0  1 1

Peto-Peto  0  1 1

Mod~ Peto-Peto (Andersen)0  1 1

Flem~-Harr~ with p=1, q=1  0  1 1



$tests$supTests

 Q p

Log-rank 0 1

Gehan-Breslow (mod~ Wilcoxon)  0 1

Tarone-Ware   0 1

Peto-Peto   0 1

Mod~ Peto-Peto (Andersen) 0 1

Renyi Flem~-Harr~ with p=1, q=1 0 1



Notice the zeros (0) that corresponds to the test statistics. (To my
opinion those zeros are strongly related to the NB above).

   Next I noticed the following strange, to my opinion, thing.  More
precisely I have written the following
routine


proc-function(){

 rm(list=ls())

 library(survMisc)

 d-read.table(C:\\Program
Files\\R\\Data\\Survival\\HosmLem.txt,fill=TRUE,header=TRUE)

 d4-as.factor(d[,4])

 s-survfit(Surv(d[,2], d[,5])~d4)

 ctest-comp(s)$tests

 print(ctest)

}

The data used are those of Hosmer and Lemeshow book on Applied Survival
Analysis. The first rows of this data set follow.

id Time Age Drug Censorentdateenddate

  15  460  1   05/15/1990 10/14/1990

  26  351  0   09/19/1989 03/20/1990

  38  301  1   04/21/1991 12/20/1991

  43  301  1   01/03/1991 04/04/1991

  5   22  360  1   09/18/1989 07/19/1991

  61  321  003/18/1991 04/17/1991

When I run the function proc() I am getting the answer

 proc()

Error in Surv(d[, 2], d[, 5]) : object 'd' not found

In contrast when I run the same routine command-by-command I am getting the
following output

$lrTests

 ChiSq df p

Log-rank 0  1 1

Gehan-Breslow (mod~ Wilcoxon)  0  1 1

Tarone-Ware   0  1 1

Peto-Peto   0  1 1

Mod~ Peto-Peto (Andersen) 0  1 1

Flem~-Harr~ with p=1, q=1   0  1 1



$supTests

  Q p

Log-rank  0 1

Gehan-Breslow (mod~ Wilcoxon)   0 1

Tarone-Ware0 1

Peto-Peto0 1

Mod~ Peto-Peto (Andersen)  0 1


[R] Programming routine comp()

2014-04-14 Thread Endy BlackEndy
 Dear R users.
I am trying to program the comp() routine in package survMisc.


I am reading the data below with d=read.table( C:\\. .
.,fill=TRUE,header=TRUE)
Then I load the packages 'survival' and 'survMisc', library(survival),
library(survMisc)
 and I run the commands
  s=survfit(Surv(d[,2], d[,3])~d[,1],
data=d)
  comp(s)

 and I am getting the error
   Error in get(t1, loc1) : object 'd[,
2]' not found
If instead I use the commands
s=survfit(Surv(T, Status)~Group,
data=d)
   comp(s)

routine comp()  runs perfectly. However when I am programing I can't see a
way to know
in advance the variable names in order to use them.
Can anybody  give me a suggestion?

 Thanks in advance
   Endy

NB. The data must be stacked in three (3) columns before red.
They are repeated in nine (9) columns for space saving.

Group T Status Group T Status Group T Status
1 2081 0 1 55 1 2 414 1
1 1602 0 1 1 1 2 2204 1
1 1496 0 1 107 1 2 1063 1
1 1462 0 1 110 1 2 481 1
1 1433 0 1 332 1 2 105 1
1 1377 0 2 2569 0 2 641 1
1 1330 0 2 2506 0 2 390 1
1 996 0 2 2409 0 2 288 1
1 226 0 2 2218 0 2 421 1
1 1199 0 2 1857 0 2 79 1
1  0 2 1829 0 2 748 1
1 530 0 2 1562 0 2 486 1
1 1182 0 2 1470 0 2 48 1
1 1167 0 2 1363 0 2 272 1
1 418 1 2 1030 0 2 1074 1
1 383 1 2 860 0 2 381 1
1 276 1 2 1258 0 2 10 1
1 104 1 2 2246 0 2 53 1
1 609 1 2 1870 0 2 80 1
1 172 1 2 1799 0 2 35 1
1 487 1 2 1709 0 2 248 1
1 662 1 2 1674 0 2 704 1
1 194 1 2 1568 0 2 211 1
1 230 1 2 1527 0 2 219 1
1 526 1 2 1324 0 2 606 1
1 122 1 2 957 0
1 129 1 2 932 0
1 74 1 2 847 0
1 122 1 2 848 0
1 86 1 2 1850 0
1 466 1 2 1843 0
1 192 1 2 1535 0
1 109 1 2 1447 0
1 55 1 2 1384 0

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Programming routine comp()

2014-04-14 Thread Endy BlackEndy
 Dear R users.
I am trying to program the comp() routine in package survMisc.


I am reading the data below with d=read.table( C:\\. .
.,fill=TRUE,header=TRUE)
Then I load the packages 'survival' and 'survMisc', library(survival),
library(survMisc)
 and I run the commands
  s=survfit(Surv(d[,2], d[,3])~d[,1],
data=d)
  comp(s)

 and I am getting the error
   Error in get(t1, loc1) : object 'd[,
2]' not found
If instead I use the commands
s=survfit(Surv(T, Status)~Group,
data=d)
   comp(s)

routine comp()  runs perfectly. However when I am programing I can't see a
way to know
in advance the variable names in order to use them.
Can anybody  give me a suggestion?

 Thanks in advance
   Endy

NB. The data must be stacked in three (3) columns before red.
They are repeated in nine (9) columns for space saving.

Group T Status Group T Status Group T Status
1 2081 0 1 55 1 2 414 1
1 1602 0 1 1 1 2 2204 1
1 1496 0 1 107 1 2 1063 1
1 1462 0 1 110 1 2 481 1
1 1433 0 1 332 1 2 105 1
1 1377 0 2 2569 0 2 641 1
1 1330 0 2 2506 0 2 390 1
1 996 0 2 2409 0 2 288 1
1 226 0 2 2218 0 2 421 1
1 1199 0 2 1857 0 2 79 1
1  0 2 1829 0 2 748 1
1 530 0 2 1562 0 2 486 1
1 1182 0 2 1470 0 2 48 1
1 1167 0 2 1363 0 2 272 1
1 418 1 2 1030 0 2 1074 1
1 383 1 2 860 0 2 381 1
1 276 1 2 1258 0 2 10 1
1 104 1 2 2246 0 2 53 1
1 609 1 2 1870 0 2 80 1
1 172 1 2 1799 0 2 35 1
1 487 1 2 1709 0 2 248 1
1 662 1 2 1674 0 2 704 1
1 194 1 2 1568 0 2 211 1
1 230 1 2 1527 0 2 219 1
1 526 1 2 1324 0 2 606 1
1 122 1 2 957 0
1 129 1 2 932 0
1 74 1 2 847 0
1 122 1 2 848 0
1 86 1 2 1850 0
1 466 1 2 1843 0
1 192 1 2 1535 0
1 109 1 2 1447 0
1 55 1 2 1384 0

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Programing routine comp()

2014-04-12 Thread Endy BlackEndy
Dear R users.
I am trying to program the comp() routine in package survMisc.


I am reading the data below with d=read.table( C:\\. .
.,fill=TRUE,header=TRUE)
Then I load the packages 'survival' and 'survMisc', library(survival),
library(survMisc)
 and I run the commands
  s=survfit(Surv(d[,2], d[,3])~d[,1],
data=d)
  comp(s)

 and I am getting the error
   Error in get(t1, loc1) : object 'd[,
2]' not found
If instead I use the commands
s=survfit(Surv(T, Status)~Group,
data=d)
   comp(s)

routine comp()  runs perfectly. However when I am programing I can't see a
way to know
in advance the variable names in order to use them.
Can anybody  give me a suggestion?

 Thanks in advance
   Endy

NB. The data must be stacked in three (3) columns before red.
They are repeated in nine (9) columns for space saving.

Group T Status Group T Status Group T Status
1 2081 0 1 55 1 2 414 1
1 1602 0 1 1 1 2 2204 1
1 1496 0 1 107 1 2 1063 1
1 1462 0 1 110 1 2 481 1
1 1433 0 1 332 1 2 105 1
1 1377 0 2 2569 0 2 641 1
1 1330 0 2 2506 0 2 390 1
1 996 0 2 2409 0 2 288 1
1 226 0 2 2218 0 2 421 1
1 1199 0 2 1857 0 2 79 1
1  0 2 1829 0 2 748 1
1 530 0 2 1562 0 2 486 1
1 1182 0 2 1470 0 2 48 1
1 1167 0 2 1363 0 2 272 1
1 418 1 2 1030 0 2 1074 1
1 383 1 2 860 0 2 381 1
1 276 1 2 1258 0 2 10 1
1 104 1 2 2246 0 2 53 1
1 609 1 2 1870 0 2 80 1
1 172 1 2 1799 0 2 35 1
1 487 1 2 1709 0 2 248 1
1 662 1 2 1674 0 2 704 1
1 194 1 2 1568 0 2 211 1
1 230 1 2 1527 0 2 219 1
1 526 1 2 1324 0 2 606 1
1 122 1 2 957 0
1 129 1 2 932 0
1 74 1 2 847 0
1 122 1 2 848 0
1 86 1 2 1850 0
1 466 1 2 1843 0
1 192 1 2 1535 0
1 109 1 2 1447 0
1 55 1 2 1384 0

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How I can program comp() routine

2014-04-10 Thread Endy BlackEndy
Group T Status  Dear R users. I am trying to program the comp()
routine in package survMisc.

   1 2081 0  I am reading the data on the left with
d=read.table( C:\\e.t.c,fill=TRUE,header=TRUE)
   1 1602 0 Then I load the packages 'survival' and
'survMisc', library(survival), library(survMisc)
   1 1496 0 and I run the commands
   1 1462 0  s=survfit(Surv(d[,2],
d[,3])~d[,1], data=d)
   1 1433 0  comp(s)

   1 1377 0 and I am getting the error
   1 1330 0   Error in get(t1, loc1) :
object 'd[, 2]' not found
   1  996 0 If instead I use the commands
   1  226 0s=survfit(Surv(T,
Status)~Group, data=d)
   1 1199 0   comp(s)

   1  0routine comp()  runs perfectly. However when
I am programing I can't see a way to know
   1  530 0 in advance the variable names in order to
use them.
   1 1182 0Can anybody  give me a suggestion?
   1 1167 0 Thanks in advance
   1  418 1   Endy

   1  383 1
   1  276 1
   1  104 1
   1  609 1
   1  172 1

   1  487 1
   1  662 1
   1  194 1
   1  230 1
   1  526 1

   1  122 1
   1  129 1
   1   74 1
   1  122 1
   1   86 1

   1  466 1
   1  192 1
   1  109 1
   1   55 1
   11 1

   1  107 1
   1  110 1
   1  332 1
   2 2569 0
   2 2506 0

   2 2409 0
   2 2218 0
   2 1857 0
   2 1829 0
   2 1562 0

   2 1470 0
   2 1363 0
   2 1030 0
   2  860 0
   2 1258 0

   2 2246 0
   2 1870 0
   2 1799 0
   2 1709 0
   2 1674 0

   2 1568 0
   2 1527 0
   2 1324 0
   2  957 0
   2  932 0

   2  847 0
   2  848 0
   2 1850 0
   2 1843 0
   2 1535 0

   2 1447 0
   2 1384 0
   2  414 1
   2 2204 1
   2 1063 1

   2  481 1
   2  105 1
   2  641 1
   2  390 1
   2  288 1

   2  421 1
   2   79 1
   2  748 1
   2  486 1
   2   48 1

   2  272 1
   2 1074 1
   2  381 1
   2   10 1
   2   53 1

   2   80 1
   2   35 1
   2  248 1
   2  704 1
   2  211 1

   2  219 1

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Survival analysis

2014-01-28 Thread Endy BlackEndy
Dear R users, how I can implement Breslow and Tarone-Ware tests for
survival analysis?
Also, is there any way I can estimate and plot the hazard function,along
the lines of the survival function in Survival Package? (The package muhaz
seems that does not do what it promises, except if I could not understand
how it works.)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] log-log link function

2013-09-13 Thread Endy BlackEndy
Hi to every body. I would like assistance on how to implement the log-log
link function for binary response. Is there any package that implements it?
Many thanks
Endy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Hosmer Lemeshow test

2013-04-23 Thread Endy BlackEndy
Hi to everybody. I use the following routine (i found it in the internet)
to compute the Hosmer-Lemeshow test in the framework of logistic regression.

hosmerlemeshow = function(obj, g=10) {
# first, check to see if we fed in the right kind of object
   stopifnot(family(obj)$family==binomial  family(obj)$link==logit)
   y = obj$model[[1]]
   # the double bracket (above) gets the index of items within an object
   if (is.factor(y))
  y = as.numeric(y)==2
   yhat = obj$fitted.values
   cutyhat=cut(yhat,quantile(yhat,0:g/g),include.lowest=TRUE)

   obs = xtabs(cbind(1 - y, y) ~ cutyhat)
   expect = xtabs(cbind(1 - yhat, yhat) ~ cutyhat)
   if (any(expect  5))
   #   warning(Some expected counts are less than 5. Use smaller number of
groups)
   chisq = sum((obs - expect)^2/expect)
   P = 1 - pchisq(chisq, g - 2)
   cat(H-L2 statistic,round(chisq,4), and its p value,P,\n)
   # by returning an object of class htest, the function will perform
like the
   # built-in hypothesis tests
   return(structure(list(
  method = c(paste(Hosmer and Lemeshow goodness-of-fit test with, g,
bins, sep= )),
  data.name = deparse(substitute(obj)),
  statistic = c(X2=chisq),
  parameter = c(df=g-2),
  p.value = P
   ), class='htest'))
   return(list(chisq=chisq,p.value=P))
}

However when i run it with the data set below i get the value NaN. Using
the same data set with SPSS i get a specific value.

FlightNo Temp ThermalDisast
1 66 0
2 70 1
3 69 0
4 68 0
5 67 0
6 72 0
7 73 0
8 70 0
9 57 1
10 63 1
11 70 1
12 78 0
13 67 0
14 53 1
15 67 0
16 75 0
17 70 0
18 81 0
19 76 0
20 79 0
21 75 1
22 76 0
23 58 1

Any suggestions will greatly appreciated.
With regards
Endy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Logistic regression

2013-04-19 Thread Endy BlackEndy
Dear colleagues I have a couple of problems related with binary logistic
regression.

The first problem is how to compute Pearson and Likelihood chi-squeared
tests for grouped data.

For the same form of data set how to compute sensitivity, specificity and
related measures.

When I speak about grouped data I mean data of the following form


Alcohol.Consum Malformed NoMalformed

   0  4817066

 1  3814464

  1-2  5   788

  3-5  1   126

  =6 1 37

(This data set has been taken from the book “Categorical data analysis by
Agresti”)

The second question is the following:is it correct to upload a grouped data
set to an ungrouped one?

The upload is achieved with the aid of the following routine

Createdataframe - function(d){

  f1 = f2 = numeric(0)

  v = d[,1]

  for(j in 2:3){

 for(i in 1:dim(d)[1]){

f1 = c( f1, rep( levels(v)[v[i]], d[i,j] ) )

 }

 f2 = c( f2, rep( 3-j, sum(d[,j]) ) )

  }

  df=data.frame(f1,f2)

  return(df)

}

My finally question is why SPSS computes the Hosmer-Lemeshow test while the
routine listed below gives NaN. (One has to put g=8 in order to get a
numeric value)

The data set is (it is also has been taken from the same book mentioned
above)


FlightNo Temp ThermalDisast

  1   66   0

  2   70   1

  3   69   0

  4   68   0

  5   67   0

  6   72   0

  7   73   0

  8   70   0

   9  57   1

 10  63   1

 11  70   1

 12  78   0

 13  67   0

 14  53   1

 15  67   0

 16 750

 17 700

 18 810

 19 760

 20 790

 21 751

 22 760

 23 58 1

and the routine used is

hosmerlemeshow = function(obj, g=10) {

  # first, check to see if we fed in the right kind of object

   stopifnot(family(obj)$family==binomial  family(obj)$link==logit)

   y = obj$model[[1]]

   # the double bracket (above) gets the index of items within an object

   if (is.factor(y))

  y = as.numeric(y)==2

  yhat = obj$fitted.values

  cutyhat=cut(yhat,quantile(yhat,0:g/g),include.lowest=TRUE)

  obs = xtabs(cbind(1 - y, y) ~ cutyhat)

  expect = xtabs(cbind(1 - yhat, yhat) ~ cutyhat)

  if (any(expect  5))

# warning(Some expected counts are less than 5. Use smaller number
of groups)

chisq = sum((obs - expect)^2/expect)

P = 1 - pchisq(chisq, g - 2)

cat(H-L2 statistic,round(chisq,4), and its p value,P,\n)

# by returning an object of class htest, the function will
perform like the

   # built-in hypothesis tests

   return(structure(list(

  method = c(paste(Hosmer and Lemeshow goodness-of-fit test with, g,
bins, sep= )),

  data.name = deparse(substitute(obj)),

  statistic = c(X2=chisq),

   parameter = c(df=g-2),

   p.value = P

  ), class='htest'))

  return(list(chisq=chisq,p.value=P))

}

I found this routine in the internet.

Thank you for your cooperation in advance. Any suggestion and/or solution
will be greatly appreciated.

With regards
Endy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Logistic Regression

2013-04-19 Thread Endy BlackEndy
Please read the attach file.
Thank you
Endy
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Logistic Regression

2013-04-19 Thread Endy BlackEndy
Dear colleagues I have a couple of problems related with binary logistic
regression.

  The first problem is how to compute Pearson and Likelihood chi-squeared
tests for grouped data.

 For the same form of data set how to compute sensitivity, specificity and
related measures.

 When I speak about grouped data I mean data of the following form



  Alcohol.Consum   Malformed NoMalformed

0
   4817066

  1
3814464

   1-2
5788

   3-5
1126

  =6
1  37



(This data set has been taken from the book “Categorical data analysis by
Agresti”)



   The second question is the following:is it correct to upload a grouped
data set to an ungrouped one?

The upload is achieved with the aid of the following routine



Createdataframe - function(d){

 f1 = f2 = numeric(0)

 v = d[,1]

 for(j in 2:3){

  for(i in 1:dim(d)[1]){

   f1 = c( f1, rep( levels(v)[v[i]], d[i,j] ) )

  }

  f2 = c( f2, rep( 3-j, sum(d[,j]) ) )

 }

 df=data.frame(f1,f2)

 return(df)

}



My finally question is why SPSS computes the Hosmer-Lemeshow test while
the routine listed below gives NaN. (One has to put g=8 in order to get a
numeric value)



The data set is (it is also has been taken from the same book mentioned
above)



FlightNo   TempThermalDisast

1  660

2  701

3  690

4  680

5  670

6  720

7  730

8  700

9  571

10631

11701

12780

13670

14531

15670

16750

17700

18810

19760

20790

21751

22760

23581



and the routine used is



hosmerlemeshow = function(obj, g=10) {

# first, check to see if we fed in the right kind of object

   stopifnot(family(obj)$family==binomial  family(obj)$link==logit)

   y = obj$model[[1]]

   # the double bracket (above) gets the index of items within an object

   if (is.factor(y))

  y = as.numeric(y)==2

   yhat = obj$fitted.values

   cutyhat=cut(yhat,quantile(yhat,0:g/g),include.lowest=TRUE)



   obs = xtabs(cbind(1 - y, y) ~ cutyhat)

   expect = xtabs(cbind(1 - yhat, yhat) ~ cutyhat)

   if (any(expect  5))

   #   warning(Some expected counts are less than 5. Use smaller number of
groups)

   chisq = sum((obs - expect)^2/expect)

   P = 1 - pchisq(chisq, g - 2)

   cat(H-L2 statistic,round(chisq,4), and its p value,P,\n)

   # by returning an object of class htest, the function will perform
like the

   # built-in hypothesis tests

   return(structure(list(

  method = c(paste(Hosmer and Lemeshow goodness-of-fit test with, g,
bins, sep= )),

  data.name = deparse(substitute(obj)),

  statistic = c(X2=chisq),

  parameter = c(df=g-2),

  p.value = P

   ), class='htest'))

   return(list(chisq=chisq,p.value=P))

}



Thank you for your cooperation in advance. Any suggestion and/or solution
will be greatly appreciated.



With regards

Endy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Logistic regression

2013-04-14 Thread Endy BlackEndy
I have a data set to be analyzed using to binary logistic regression. The
data set is iin grouped form. My question is: how I can compute
Hosmer-Lemeshow test and measures like sensitivity and specificity? Any
suggestion will be greatly appreciated.

Thank you

Endy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] sensitivity for grouped data

2013-04-09 Thread Endy BlackEndy
I could not locate any package (using RSeek.org) to compute sensitivity,
specificity and related measures, for logistic regression models with
grouped data. (For ungrouped data I know one, the SMDTools). Any suggestion
will be greatly appreciated.

Many thanks
Endy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help on qpcR package

2009-06-21 Thread Endy BlackEndy
I am using R on a Windows XP professional platform.
  The following code is part of a bigger one
 CODE
  press=function(y,x){
   library(qpcR)
   models.press=numeric(0)
   cat(\n)
   dep=y
  print(dep)
   indep=log(x)
  print(indep)
   yfit=dep-PRESS(lm(dep~indep))[[2]]
  cat(\n yfit\n)
  print(yfit)
   yfit.orig=yfit
   presid=y-yfit.orig
   press=sum(presid^2)
   cat(\n)
   cat(PRESS =,press,\n)
  }
  On the command R window I define

- Ignored:

 x=c(12,24,13,11,23,10,9,17,11,14,18)
 y=c(10,11,9,8,5,12,11,21,12,13,14)

  then I load the press source code, I run it using the x and y values
  defined before
  and I get the following

 press(x,y)
  Loading required package: drc
  Loading required package: alr3
  Loading required package: lattice
  Loading required package: magic
  Loading required package: abind
  Loading required package: MASS
  Loading required package: nlme
  Loading required package: plotrix

  'drc' has been loaded.

  Please cite R and 'drc' if used for a publication,
  for references type 'citation()' and 'citation('drc')'.

  Loading required package: gtools
  Loading required package: gplots
  Loading required package: gdata
  Loading required package: caTools
  Loading required package: bitops
  Loading required package: grid

  Attaching package: 'gplots'


  The following object(s) are masked from package:plotrix :

   plotCI


  The following object(s) are masked from package:stats :

   lowess


  'qpcR' has been loaded.

  Please cite R and the following if used for a publication:

  Spiess AN, Feig C, Ritz
  Highly accurate sigmoidal fitting of real-time PCR data by introducing
  a parameter for asymmetry.
  BMC Bioinformatics 2008, 29:221
  or
  Ritz C, Spiess AN. qpcR: an R package for sigmoidal model selection in
  quantitative real-time polymerase chain reaction analysis.
  Bioinformatics 2008, 24:1549-1551

  Newest version always available at www.dr-spiess.de/qpcR.html.


  Attaching package: 'qpcR'


  The following object(s) are masked from package:gplots :

   residplot


   [1] 12 24 13 11 23 10  9 17 11 14 18
   [1] 2.302585 2.397895 2.197225 2.079442 1.609438 2.484907 2.397895
  3.044522 2.484907 2.564949 2.639057
  Error in get(noquote(a)) : object 'dep' not found

  The error reported, as I understand it, is that the object dep it is
  not defined. Obviously, at least to me, it is defined.

  If I declare the dep and indep objects on the command R window i. e.

   dep=y
   indep=x

  and rerun the programme  then it runs correctly and gives

   press(x,y)

   [1] 12 24 13 11 23 10  9 17 11 14 18
   [1] 2.302585 2.397895 2.197225 2.079442 1.609438 2.484907 2.397895
  3.044522 2.484907 2.564949 2.639057

   yfit
   [1] 13.764062 24.199292 15.804140 15.192045 32.465326  9.547579
  9.845243  6.176015 10.521896 12.325493 14.931854

  PRESS = 248.7043

Can anybody point out what's the problem?
  Thanks in advance
  K. Karakostas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.