[R] retrieving weights from a polr object

John Fox jfox at mcmaster.ca
Sun Sep 28 15:17:27 CEST 2008


Dear Yihui,

Yes, that's right. The reason that I missed it is that I checked a model
that had been fit without a weights argument, that doesn't work even for an
"lm" object (but does for a "multinom" object, produced by multinom() in the
nnet package, which is what threw me off).

Thank you very much,
 John

> -----Original Message-----
> From: Yihui Xie [mailto:xieyihui at gmail.com]
> Sent: September-28-08 1:33 AM
> To: John Fox
> Cc: r-help at r-project.org
> Subject: Re: [R] retrieving weights from a polr object
> 
> Hi John,
> 
> Aren't they in the component 'model' of the fitted object?
> 
> ##
> > options(contrasts = c("contr.treatment", "contr.poly"))
> > house.plr <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data =
housing)
> > head(house.plr$model)
>      Sat   Infl  Type Cont (weights)
> 1    Low    Low Tower  Low        21
> 2 Medium    Low Tower  Low        21
> 3   High    Low Tower  Low        28
> 4    Low Medium Tower  Low        34
> 5 Medium Medium Tower  Low        22
> 6   High Medium Tower  Low        36
> > house.plr$model$'(weights)'
>  [1] 21 21 28 34 22 36 10 11 36 61 23 17 43 35 40 26 18 54 13  9 10  8
>  8 12  6  7  9 18  6  7 15 13 13  7  5 11 14 19 37 17 23 40  3  5 23
> 78 46 43 48 45 86
> [52] 15 25 62 20 23 20 10 22 24  7 10 21 57 23 13 31 21 13  5  6 13
> ##
> 
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui at gmail.com>
> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
> Mobile: +86-15810805877
> Homepage: http://www.yihui.name
> School of Statistics, Room 1037, Mingde Main Building,
> Renmin University of China, Beijing, 100872, China
> 
> 
> 
> On Sun, Sep 28, 2008 at 3:00 AM, John Fox <jfox at mcmaster.ca> wrote:
> > Dear list members,
> >
> > The polr() function in the MASS package takes an optional weights
argument
> > for case weights. Is there any way to retrieve the case weights from the
> > fitted "polr" object? Examining both the object and the code, I don't
see
> > how this can be done, but perhaps I've missed something.
> >
> > Any help would be appreciated.
> >
> > John
> >
> > ------------------------------
> > John Fox, Professor
> > Department of Sociology
> > McMaster University
> > Hamilton, Ontario, Canada
> > web: socserv.mcmaster.ca/jfox
> >
> > ______________________________________________
> > 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.
> >



More information about the R-help mailing list