

Hi,
I'm calculating a conditional logit on some data stratified by group.
My understanding was that a conditional logit by definition returns a
value between 0 and 1 a a probability. Can anyone suggest why I'm
seeing results outside of the {0,1} range??
The call in R is:
m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
Then
prediction < predict(m,newdata)
A sample of the data with resulting predictive values is:
group score val_1 val_2 prediction
1 20090104_1 1 0.5913962 1.121589 1.62455210
2 20090104_1 1 0.6175472 3.249820 0.20093346
3 20090104_1 1 0.5439640 2.424501 0.46651849
4 20090104_1 0 0.3745209 2.477424 0.31263855
5 20090104_1 0 0.6329855 3.424174 0.34200448
6 20090104_1 0 0.4571999 2.770247 0.11190788
7 20090104_1 0 0.3822623 2.259422 0.50627534
8 20090104_1 0 0.2605742 4.424806 1.44566070
9 20090104_1 0 0.4449604 2.357060 0.46174993
10 20090104_1 0 0.6595178 2.246518 0.69427842
11 20090104_1 0 0.5260032 2.977887 0.02393871
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:
> Hi,
>
> I'm calculating a conditional logit on some data stratified by group.
> My understanding was that a conditional logit by definition returns a
> value between 0 and 1 a a probability. Can anyone suggest why I'm
> seeing results outside of the {0,1} range??
Probably because you did not read the help page for the function
predict.coxph. Pay special attention to the type argument.
"type=c("lp", "risk", "expected", "terms")"
>
> The call in R is:
>
> m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
>
> Then
>
> prediction < predict(m,newdata)
I do not see that you have defined any newdata.
>
>
> A sample of the data with resulting predictive values is:
> group score val_1 val_2 prediction
> 1 20090104_1 1 0.5913962 1.121589 1.62455210
> 2 20090104_1 1 0.6175472 3.249820 0.20093346
> 3 20090104_1 1 0.5439640 2.424501 0.46651849
> 4 20090104_1 0 0.3745209 2.477424 0.31263855
> 5 20090104_1 0 0.6329855 3.424174 0.34200448
> 6 20090104_1 0 0.4571999 2.770247 0.11190788
> 7 20090104_1 0 0.3822623 2.259422 0.50627534
> 8 20090104_1 0 0.2605742 4.424806 1.44566070
> 9 20090104_1 0 0.4449604 2.357060 0.46174993
> 10 20090104_1 0 0.6595178 2.246518 0.69427842
> 11 20090104_1 0 0.5260032 2.977887 0.02393871
By default (which is what you have implicitly chosen) you are
requesting "lp" = linear predictors rather than "risk".

David.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
David Winsemius, MD
West Hartford, CT
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks David,
That explains a lot. I appreciate it.

Noah
On 4/20/10 3:48 PM, David Winsemius wrote:
>
> On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:
>
>> Hi,
>>
>> I'm calculating a conditional logit on some data stratified by group.
>> My understanding was that a conditional logit by definition returns a
>> value between 0 and 1 a a probability. Can anyone suggest why I'm
>> seeing results outside of the {0,1} range??
>
> Probably because you did not read the help page for the function
> predict.coxph. Pay special attention to the type argument.
>
> "type=c("lp", "risk", "expected", "terms")"
>
>>
>> The call in R is:
>>
>> m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
>>
>> Then
>>
>> prediction < predict(m,newdata)
>
> I do not see that you have defined any newdata.
>
>>
>>
>> A sample of the data with resulting predictive values is:
>> group score val_1 val_2 prediction
>> 1 20090104_1 1 0.5913962 1.121589 1.62455210
>> 2 20090104_1 1 0.6175472 3.249820 0.20093346
>> 3 20090104_1 1 0.5439640 2.424501 0.46651849
>> 4 20090104_1 0 0.3745209 2.477424 0.31263855
>> 5 20090104_1 0 0.6329855 3.424174 0.34200448
>> 6 20090104_1 0 0.4571999 2.770247 0.11190788
>> 7 20090104_1 0 0.3822623 2.259422 0.50627534
>> 8 20090104_1 0 0.2605742 4.424806 1.44566070
>> 9 20090104_1 0 0.4449604 2.357060 0.46174993
>> 10 20090104_1 0 0.6595178 2.246518 0.69427842
>> 11 20090104_1 0 0.5260032 2.977887 0.02393871
>
> By default (which is what you have implicitly chosen) you are
> requesting "lp" = linear predictors rather than "risk".
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


I just read the help page for predict.coxph.
It indicates that the risk score is just exp(lp)
What I'm trying to find, and have seen with some other implementations
is the "conditional probability within group". Neither the lp or the
risk options seem to deliver this.
What am I missing?
N
On 4/20/10 4:22 PM, Noah Silverman wrote:
> Thanks David,
>
> That explains a lot. I appreciate it.
>
> 
> Noah
>
>
> On 4/20/10 3:48 PM, David Winsemius wrote:
>
>> On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:
>>
>>
>>> Hi,
>>>
>>> I'm calculating a conditional logit on some data stratified by group.
>>> My understanding was that a conditional logit by definition returns a
>>> value between 0 and 1 a a probability. Can anyone suggest why I'm
>>> seeing results outside of the {0,1} range??
>>>
>> Probably because you did not read the help page for the function
>> predict.coxph. Pay special attention to the type argument.
>>
>> "type=c("lp", "risk", "expected", "terms")"
>>
>>
>>> The call in R is:
>>>
>>> m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
>>>
>>> Then
>>>
>>> prediction < predict(m,newdata)
>>>
>> I do not see that you have defined any newdata.
>>
>>
>>>
>>> A sample of the data with resulting predictive values is:
>>> group score val_1 val_2 prediction
>>> 1 20090104_1 1 0.5913962 1.121589 1.62455210
>>> 2 20090104_1 1 0.6175472 3.249820 0.20093346
>>> 3 20090104_1 1 0.5439640 2.424501 0.46651849
>>> 4 20090104_1 0 0.3745209 2.477424 0.31263855
>>> 5 20090104_1 0 0.6329855 3.424174 0.34200448
>>> 6 20090104_1 0 0.4571999 2.770247 0.11190788
>>> 7 20090104_1 0 0.3822623 2.259422 0.50627534
>>> 8 20090104_1 0 0.2605742 4.424806 1.44566070
>>> 9 20090104_1 0 0.4449604 2.357060 0.46174993
>>> 10 20090104_1 0 0.6595178 2.246518 0.69427842
>>> 11 20090104_1 0 0.5260032 2.977887 0.02393871
>>>
>> By default (which is what you have implicitly chosen) you are
>> requesting "lp" = linear predictors rather than "risk".
>>
>>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On Apr 20, 2010, at 7:31 PM, Noah Silverman wrote:
> I just read the help page for predict.coxph.
>
> It indicates that the risk score is just exp(lp)
>
> What I'm trying to find, and have seen with some other implementations
> is the "conditional probability within group". Neither the lp or the
> risk options seem to deliver this.
>
> What am I missing?
>
I'm not sure that clogit lets you estimate that quantity:
http://tolstoy.newcastle.edu.au/R/help/06/02/21443.htmlDo you have citations that back up your original assumption?

David,
> N
>
>
> On 4/20/10 4:22 PM, Noah Silverman wrote:
>> Thanks David,
>>
>> That explains a lot. I appreciate it.
>>
>> 
>> Noah
>>
>>
>> On 4/20/10 3:48 PM, David Winsemius wrote:
>>
>>> On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> I'm calculating a conditional logit on some data stratified by
>>>> group.
>>>> My understanding was that a conditional logit by definition
>>>> returns a
>>>> value between 0 and 1 a a probability. Can anyone suggest why I'm
>>>> seeing results outside of the {0,1} range??
>>>>
>>> Probably because you did not read the help page for the function
>>> predict.coxph. Pay special attention to the type argument.
>>>
>>> "type=c("lp", "risk", "expected", "terms")"
>>>
>>>
>>>> The call in R is:
>>>>
>>>> m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
>>>>
>>>> Then
>>>>
>>>> prediction < predict(m,newdata)
>>>>
>>> I do not see that you have defined any newdata.
>>>
>>>
>>>>
>>>> A sample of the data with resulting predictive values is:
>>>> group score val_1 val_2
>>>> prediction
>>>> 1 20090104_1 1 0.5913962 1.121589 1.62455210
>>>> 2 20090104_1 1 0.6175472 3.249820 0.20093346
>>>> 3 20090104_1 1 0.5439640 2.424501 0.46651849
>>>> 4 20090104_1 0 0.3745209 2.477424 0.31263855
>>>> 5 20090104_1 0 0.6329855 3.424174 0.34200448
>>>> 6 20090104_1 0 0.4571999 2.770247 0.11190788
>>>> 7 20090104_1 0 0.3822623 2.259422 0.50627534
>>>> 8 20090104_1 0 0.2605742 4.424806 1.44566070
>>>> 9 20090104_1 0 0.4449604 2.357060 0.46174993
>>>> 10 20090104_1 0 0.6595178 2.246518 0.69427842
>>>> 11 20090104_1 0 0.5260032 2.977887 0.02393871
>>>>
>>> By default (which is what you have implicitly chosen) you are
>>> requesting "lp" = linear predictors rather than "risk".
>>>
>>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/rhelp>> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html>> and provide commented, minimal, selfcontained, reproducible code.
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
David Winsemius, MD
West Hartford, CT
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On Tue, 20 Apr 2010, Noah Silverman wrote:
> I just read the help page for predict.coxph.
>
> It indicates that the risk score is just exp(lp)
>
> What I'm trying to find, and have seen with some other implementations
> is the "conditional probability within group". Neither the lp or the
> risk options seem to deliver this.
exp(lp)/(1+exp(lp))
or, as Martin Maechler would prefer, qlogis(lp)
thomas
> What am I missing?
>
> N
>
>
> On 4/20/10 4:22 PM, Noah Silverman wrote:
>> Thanks David,
>>
>> That explains a lot. I appreciate it.
>>
>> 
>> Noah
>>
>>
>> On 4/20/10 3:48 PM, David Winsemius wrote:
>>
>>> On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> I'm calculating a conditional logit on some data stratified by group.
>>>> My understanding was that a conditional logit by definition returns a
>>>> value between 0 and 1 a a probability. Can anyone suggest why I'm
>>>> seeing results outside of the {0,1} range??
>>>>
>>> Probably because you did not read the help page for the function
>>> predict.coxph. Pay special attention to the type argument.
>>>
>>> "type=c("lp", "risk", "expected", "terms")"
>>>
>>>
>>>> The call in R is:
>>>>
>>>> m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
>>>>
>>>> Then
>>>>
>>>> prediction < predict(m,newdata)
>>>>
>>> I do not see that you have defined any newdata.
>>>
>>>
>>>>
>>>> A sample of the data with resulting predictive values is:
>>>> group score val_1 val_2 prediction
>>>> 1 20090104_1 1 0.5913962 1.121589 1.62455210
>>>> 2 20090104_1 1 0.6175472 3.249820 0.20093346
>>>> 3 20090104_1 1 0.5439640 2.424501 0.46651849
>>>> 4 20090104_1 0 0.3745209 2.477424 0.31263855
>>>> 5 20090104_1 0 0.6329855 3.424174 0.34200448
>>>> 6 20090104_1 0 0.4571999 2.770247 0.11190788
>>>> 7 20090104_1 0 0.3822623 2.259422 0.50627534
>>>> 8 20090104_1 0 0.2605742 4.424806 1.44566070
>>>> 9 20090104_1 0 0.4449604 2.357060 0.46174993
>>>> 10 20090104_1 0 0.6595178 2.246518 0.69427842
>>>> 11 20090104_1 0 0.5260032 2.977887 0.02393871
>>>>
>>> By default (which is what you have implicitly chosen) you are
>>> requesting "lp" = linear predictors rather than "risk".
>>>
>>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/rhelp>> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html>> and provide commented, minimal, selfcontained, reproducible code.
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
Thomas Lumley Assoc. Professor, Biostatistics
[hidden email] University of Washington, Seattle
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thomas Lumley wrote:
> On Tue, 20 Apr 2010, Noah Silverman wrote:
>
>> I just read the help page for predict.coxph.
>>
>> It indicates that the risk score is just exp(lp)
>>
>> What I'm trying to find, and have seen with some other implementations
>> is the "conditional probability within group". Neither the lp or the
>> risk options seem to deliver this.
>
> exp(lp)/(1+exp(lp))
>
> or, as Martin Maechler would prefer, qlogis(lp)
Minor correction: plogis
Frank
>
> thomas
>
>
>> What am I missing?
>>
>> N
>>
>>
>> On 4/20/10 4:22 PM, Noah Silverman wrote:
>>> Thanks David,
>>>
>>> That explains a lot. I appreciate it.
>>>
>>> 
>>> Noah
>>>
>>>
>>> On 4/20/10 3:48 PM, David Winsemius wrote:
>>>
>>>> On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm calculating a conditional logit on some data stratified by group.
>>>>> My understanding was that a conditional logit by definition returns a
>>>>> value between 0 and 1 a a probability. Can anyone suggest why I'm
>>>>> seeing results outside of the {0,1} range??
>>>>>
>>>> Probably because you did not read the help page for the function
>>>> predict.coxph. Pay special attention to the type argument.
>>>>
>>>> "type=c("lp", "risk", "expected", "terms")"
>>>>
>>>>
>>>>> The call in R is:
>>>>>
>>>>> m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
>>>>>
>>>>> Then
>>>>>
>>>>> prediction < predict(m,newdata)
>>>>>
>>>> I do not see that you have defined any newdata.
>>>>
>>>>
>>>>>
>>>>> A sample of the data with resulting predictive values is:
>>>>> group score val_1 val_2 prediction
>>>>> 1 20090104_1 1 0.5913962 1.121589 1.62455210
>>>>> 2 20090104_1 1 0.6175472 3.249820 0.20093346
>>>>> 3 20090104_1 1 0.5439640 2.424501 0.46651849
>>>>> 4 20090104_1 0 0.3745209 2.477424 0.31263855
>>>>> 5 20090104_1 0 0.6329855 3.424174 0.34200448
>>>>> 6 20090104_1 0 0.4571999 2.770247 0.11190788
>>>>> 7 20090104_1 0 0.3822623 2.259422 0.50627534
>>>>> 8 20090104_1 0 0.2605742 4.424806 1.44566070
>>>>> 9 20090104_1 0 0.4449604 2.357060 0.46174993
>>>>> 10 20090104_1 0 0.6595178 2.246518 0.69427842
>>>>> 11 20090104_1 0 0.5260032 2.977887 0.02393871
>>>>>
>>>> By default (which is what you have implicitly chosen) you are
>>>> requesting "lp" = linear predictors rather than "risk".
> Thomas Lumley Assoc. Professor, Biostatistics
> [hidden email] University of Washington, Seattle

Frank E Harrell Jr Professor and Chairman School of Medicine
Department of Biostatistics Vanderbilt University
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.
Frank Harrell
Department of Biostatistics, Vanderbilt University


On Wed, 21 Apr 2010, Frank E Harrell Jr wrote:
> Thomas Lumley wrote:
>> On Tue, 20 Apr 2010, Noah Silverman wrote:
>>
>> > I just read the help page for predict.coxph.
>> >
>> > It indicates that the risk score is just exp(lp)
>> >
>> > What I'm trying to find, and have seen with some other implementations
>> > is the "conditional probability within group". Neither the lp or the
>> > risk options seem to deliver this.
>>
>> exp(lp)/(1+exp(lp))
>>
>> or, as Martin Maechler would prefer, qlogis(lp)
>
> Minor correction: plogis
In what context is this reasonble?
It seems to me that rather strong assumptions are needed  like that the
strata are independent of the covariate(s).
The OP requested the "conditional probability within group", which I
interprete to mean something like
exp(lp)/ave( exp(lp), stratvar, FUN=sum )
when there is just one case in each stratum.
??
Chuck
>
> Frank
>
>>
>> thomas
>>
>>
>> > What am I missing?
>> >
>> > N
>> >
>> >
>> > On 4/20/10 4:22 PM, Noah Silverman wrote:
>> > > Thanks David,
>> > >
>> > > That explains a lot. I appreciate it.
>> > >
>> > > 
>> > > Noah
>> > >
>> > >
>> > > On 4/20/10 3:48 PM, David Winsemius wrote:
>> > >
>> > > > On Apr 20, 2010, at 5:59 PM, Noah Silverman wrote:
>> > > >
>> > > >
>> > > > > Hi,
>> > > > >
>> > > > > I'm calculating a conditional logit on some data stratified by
>> > > > > group.
>> > > > > My understanding was that a conditional logit by definition
>> > > > > returns a
>> > > > > value between 0 and 1 a a probability. Can anyone suggest why I'm
>> > > > > seeing results outside of the {0,1} range??
>> > > > >
>> > > > Probably because you did not read the help page for the function
>> > > > predict.coxph. Pay special attention to the type argument.
>> > > >
>> > > > "type=c("lp", "risk", "expected", "terms")"
>> > > >
>> > > >
>> > > > > The call in R is:
>> > > > >
>> > > > > m < clogit(score ~ val_1 + val_2 + strata(group), data=data)
>> > > > >
>> > > > > Then
>> > > > >
>> > > > > prediction < predict(m,newdata)
>> > > > >
>> > > > I do not see that you have defined any newdata.
>> > > >
>> > > >
>> > > > >
>> > > > > A sample of the data with resulting predictive values is:
>> > > > > group score val_1 val_2
>> > > > > prediction
>> > > > > 1 20090104_1 1 0.5913962 1.121589 1.62455210
>> > > > > 2 20090104_1 1 0.6175472 3.249820 0.20093346
>> > > > > 3 20090104_1 1 0.5439640 2.424501 0.46651849
>> > > > > 4 20090104_1 0 0.3745209 2.477424 0.31263855
>> > > > > 5 20090104_1 0 0.6329855 3.424174 0.34200448
>> > > > > 6 20090104_1 0 0.4571999 2.770247 0.11190788
>> > > > > 7 20090104_1 0 0.3822623 2.259422 0.50627534
>> > > > > 8 20090104_1 0 0.2605742 4.424806 1.44566070
>> > > > > 9 20090104_1 0 0.4449604 2.357060 0.46174993
>> > > > > 10 20090104_1 0 0.6595178 2.246518 0.69427842
>> > > > > 11 20090104_1 0 0.5260032 2.977887 0.02393871
>> > > > >
>> > > > By default (which is what you have implicitly chosen) you are
>> > > > requesting "lp" = linear predictors rather than "risk".
>
>> Thomas Lumley Assoc. Professor, Biostatistics
>> [hidden email] University of Washington, Seattle
>
>
> 
> Frank E Harrell Jr Professor and Chairman School of Medicine
> Department of Biostatistics Vanderbilt University
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>
Charles C. Berry (858) 5342098
Dept of Family/Preventive Medicine
E mailto: [hidden email] UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 920930901
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

