[R] Help with Conditional Logit
Charles C. Berry
cberry at tajo.ucsd.edu
Fri Jul 17 17:37:32 CEST 2009
On Thu, 16 Jul 2009, Noah Silverman wrote:
> Thanks for the quick reply.
>
> I found that page and do have the survival package installed.
>
> My problem is that I don't understand a few things:
> 1) What do I input for the "formula" field? (In RapidMiner, the
> functions don't have this input.)
> 2) How do I indicate which field is the "group ID" for the subset
> grouping?
> 3) How do I indicate which field is the label?
> 4) How do I indicate which fields in my dataset are for training?
Noah,
If you are not well versed in the formula language, reread the Intro to R
and read ?formula.
The ?clogit help page is pretty terse, I see. But it actually has an
example that should guide you:
clogit(case~spontaneous+induced+strata(stratum),data=infert)
Try running the example at the bottom of the help page and browse the
'infert' data set to see what it looks like or run 'str(infert)'
===
By now you may have figured this out:
The column 'case' in the infert data.frame is what you mean by 'label' -
it distinguishes the cases from the controls in the infert data.frame and
its name goes on the l.h.s. of the formula
The 'group ID' is defined by the strata() term. see ?strata. It goes on
the r.h.s. of the formula
The 'training' variables are put on the r.h.s. of the formula in addition
to the strata() term.
HTH,
Chuck
>
> Thanks!!!
>
>
>
> On 7/16/09 12:54 PM, (Ted Harding) wrote:
>> On 16-Jul-09 19:40:20, Noah Silverman wrote:
>>
>>> Hello,
>>> I'm brand new to using R. (I've been using Rapid Miner, but would
>>> like to move over to R since it gives me much more functionality.)
>>>
>>> I'm trying to learn how to do a conditional logit model.
>>>
>>> My data has one dependent variable, 2 independent variables and a
>>> "group" variable.
>>>
>>> example:
>>>
>>> class v1 v2 group
>>> "sick" .3 .7 1
>>> "well" .2 .9 1
>>> "sick" .25 .4 1
>>> "sick" .32 .6 2
>>> "well" .21 .81 2
>>> "sick" .5 .3 2
>>>
>>> Can someone help me formulate the proper command for the clogit()
>>> function?
>>> Thanks!
>>>
>>
>> Have a look at:
>>
>> http://finzi.psych.upenn.edu/R/library/survival/html/clogit.html
>>
>> You would need to install the 'survival' package.
>>
>> To search for this sort of thing in future, go to "R Site Search" at:
>>
>> http://finzi.psych.upenn.edu/nmz.html
>>
>> and search according to the available options. For your particular
>> query, I unchecked "R-help 2008-" and "Task views", leaving only
>> "Functions", and entered "clogit" into the search box. Up came
>> various hits, amongst which the one suggested above.
>>
>> Welcome to R, and happy hunting in the future!
>> Ted.
>>
>> --------------------------------------------------------------------
>> E-Mail: (Ted Harding)<Ted.Harding at manchester.ac.uk>
>> Fax-to-email: +44 (0)870 094 0861
>> Date: 16-Jul-09 Time: 20:54:18
>> ------------------------------ XFMail ------------------------------
>>
>
> [[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.
>
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help
mailing list