[R] predict() from conditional logit model?

David Winsemius dwinsemius at comcast.net
Sun Sep 15 01:53:14 CEST 2013


On Sep 12, 2013, at 8:38 PM, Marine Regis wrote:

> Hello everybody,
> 
> Thank you David for your answer. Sorry I am beginner with cox model and R software. Is it possible to do predictions from newdata which has a size equal to the vector hour <- seq(0,23.99,0.1) ? In fact, I don't know how to define parameters "cluster" and "strata" in the newdata knowing that I would like to have one prediction value for each vector value "hour <- seq(0,23.99,0.1)" and to have a prediction curve for each category "anthro", "cor", "for" (these covariates are dichotomic) ?

I'm sorry. Did you think that we would understand this question without a data example and reference to specific features of results developed with code applied to that example?

-- 
David.
> 
> Thank you very much for your help. 
> Have a good day
> Marine 
> 
>> CC: r-help at r-project.org
>> From: dwinsemius at comcast.net
>> To: marine.regis at hotmail.fr
>> Subject: Re: [R] predict() from conditional logit model?
>> Date: Thu, 12 Sep 2013 17:52:33 -0500
>> 
>> 
>> On Sep 12, 2013, at 3:31 PM, Marine Regis wrote:
>>> 
>>> Hello everybody,
>>> 
>>> I used the function clogit() (package survival) to build a  
>>> conditional logit
>>> model. This is the R output of my model :
>>> coef exp(coef) se(coef) robust se z
>>> Pr(>|z|)
>>> anthro 2.14776 8.56565 0.09352 0.53989 3.978 6.94e-05 ***
>>> cor 0.92365 2.51846 0.07757 0.41944 2.202 0.027659 *
>>> for 1.55191 4.72047 0.07513 0.41488 3.741 0.000184
>>> ***
>>> ---
>>> Signif. codes: 0 Œ***‚ 0.001 Œ**‚ 0.01 Œ*‚ 0.05 Œ.‚ 0.1 Œ ‚ 1
>>> 
>>> The covariates anthro, cor and for are dichotomic covariates (0/1).
>>> Then, I used the function predict() to calculate predicted values as  
>>> follows
>>> :
>>> 
>>> modpred <- predict(ML,type="lp")
>> 
>> You do understand that is on a log-relative-probability scale, right?  
>> And that it is relative to the mean values for the entire dataset?
>> 
>>> 
>>> and I obtained the following values for the first line of my  
>>> original data :
>>> 
>>> anthro cor for predited
>>> 1 0 1 0 0.0839679
>>> 
>>> With modpred <- predict(ML,type="expected"), I obtained :
>>> anthro cor for predited
>>> 1 0 1 0 0.09618096
>> 
>>> 
>>> My question is : from coefficients of clogit model, how can I find the
>>> predicted values 0.0839679 and 0.09618096 ?
>> 
>> You need to understand that those are really very different  
>> "predictions".
>> 
>>> In addition, how can I obtain predicted values ranged from 0 to 1 ?
>>> 
>>> Thank you very much for your help.
>> 
>> (Reading the help pages.) There does not appear to be a  
>> `predict.clogit` function but clogit objects inherit from coxph  
>> objects so reading the Details section from `predict.coxph`:
>> 
>> "The Cox model is a relative risk model; predictions of type "linear  
>> predictor", "risk", and "terms" are all relative to the sample from  
>> which they came. By default, the reference value for each of these is  
>> the mean covariate within strata. The primary underlying reason is  
>> statistical: a Cox model only predicts relative risks between pairs of  
>> subjects within the same strata, and hence the addition of a constant  
>> to any covariate, either overall or only within a particular stratum,  
>> has no effect on the fitted results. Using the reference="strata"  
>> option causes this to be true for predictions as well."
>> 
>> The predict.coxph function is fairly long:
>> 
>> getAnywhere(predict.coxph)
>> 
>> -- 
>> David Winsemius, MD
>> Alameda, CA, USA
>> 
> 		 	   		  
> 	[[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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list