[R] case weights-coxph (solved)

Nicholas Lewin-Koh kohnicho at comp.nus.edu.sg
Tue Sep 18 12:18:20 CEST 2001


Hi,
The following function does work

optimize.W<-function(W,k,G,Groups,cph.call,z){
  n<-length(Groups)
  grp.wt<-rep(0,n)
  for(i in 1:(length(G))){
    ind<-Groups == G[i]
    if(G[i]!=k){
      grp.wt[ind]<-W[i]
    }
    elsegrp.wt[ind]<-1
  }
  z<-data.frame(cbind(z,grp.wt=grp.wt)) #needed to make the case weights
                                        #part of the data frame
  mod<-coxph(cph.call,z,grp.wt,na.action=na.omit,singular.ok=T)
  sum(mod$residuals^2)
}

I wouldn't call this a bug, but shouldn't the case weights be a separate
vector if the user so desires?

Nicholas
















                 CH3
                  |
                  N             Nicholas Lewin-Koh
                 / \            Dept of Statistics
           N----C   C==O        Program in Ecology and Evolutionary Biology
          ||   ||   |           Iowa State University
          ||   ||   |           Ames, IA 50011
          CH    C   N--CH3      http://www.public.iastate.edu/~nlewin
            \  / \ /            nlewin at iastate.edu
             N    C
             |   ||             Currently
            CH3   O             Graphics Lab
                                School of Computing
                                National University of Singapore
     The Real Part of Coffee    kohnicho at comp.nus.edu.sg

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list