[R] predict() from conditional logit model?

David Winsemius dwinsemius at comcast.net
Fri Sep 13 00:52:33 CEST 2013


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



More information about the R-help mailing list