[R] Variance-covariance matrix

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Wed Aug 27 11:36:04 CEST 2008


Laura Bonnett wrote:
> Hi all,
>
> Sorry to ask again but I'm still not sure how to get the full
> variance-covariance matrix.  Peter suggested a three-level treatment
> factor.  However, I thought that the censoring variable could only take
> values 0 or 1 so how do you programme such a factor.
>   
Well, not to put it too diplomatically: If you can confuse the treatment
factor and the censoring indicator, there might be more wrong with your
analysis than we originally assumed, so how about showing us a bit more
of what you actually did?

> Alternatively, is there another way to produce the required covariance?
>
> Thank you,
>
> Laura
>
> On Tue, Aug 26, 2008 at 11:37 AM, Laura Bonnett
> <l.j.bonnett at googlemail.com>wrote:
>
>   
>> The standard treatment is the same in both comparison.
>>
>> How do you do a three-level treatment factor?
>> I thought you had to have a censoring indicator which took values 0 or 1
>> not 1, 2 or 3?
>>
>> Thanks,
>>
>> Laura
>>
>> On Tue, Aug 26, 2008 at 11:05 AM, Peter Dalgaard <P.Dalgaard at biostat.ku.dk
>>     
>>> wrote:
>>>       
>>> Laura Bonnett wrote:
>>>       
>>>> Dear R help forum,
>>>>
>>>> I am using the function 'coxph' to obtain hazard ratios for the
>>>>         
>>> comparison
>>>       
>>>> of a standard treatment to new treatments.  This is easily obtained by
>>>> fitting the relevant model and then calling exp(coef(fit1)) say.
>>>>
>>>> I now want to obtain the hazard ratio for the comparison of two
>>>>         
>>> non-standard
>>>       
>>>> treatments.
>>>> >From a statistical point of view, this can be achieved by dividing the
>>>> exponentiated coefficients of 2 comparisions. E.g. to compared new
>>>>         
>>> treatment
>>>       
>>>> 1 (nt1) to new treatment 2 (nt2) we can fit 2 models:
>>>> fit1 = standard treatment vs nt1
>>>> fit2 = standard treatment vs nt2.
>>>> The required hazard ratio is therefore exp(coef(fit1))/exp(coef(fit2))
>>>>
>>>> In order to obtain an associated confidence interval for this I require
>>>>         
>>> the
>>>       
>>>> covariance of this comparison.  I know that R gives the
>>>>         
>>> variance-covariance
>>>       
>>>> matrix by the command 'fit$var'.  However, this only gives the
>>>>         
>>> covariance
>>>       
>>>> matrix for non standard drugs and not the full covariance matrix.
>>>>
>>>> Can anyone tell me how to obtain the full covariance matrix?
>>>>
>>>>
>>>>         
>>> What kind of data do you have? Is the "standard treatment group" the
>>> same in both comparisons?  If so, why not just have a three-level
>>> treatment factor and compare nt1 to nt2 directly. If the control groups
>>> are completely separate, then the covariance between fits made on
>>> independent data is of course zero.
>>>
>>>       
>>>> Thank you,
>>>>
>>>> Laura
>>>>
>>>>       [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> R-help at 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.
>>>>
>>>>         
>>> --
>>>   O__  ---- Peter Dalgaard             �ster Farimagsgade 5, Entr.B
>>>  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>>>  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
>>> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907
>>>
>>>
>>>
>>>       
>
> 	[[alternative HTML version deleted]]
>
>   
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at 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.
>   


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list