Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Jeffrey Pollock
> Sent: Wednesday, October 12, 2011 6:29 AM
> To: r-help at r-project.org
> Subject: [R] monotonic factors
>
> Hello all,
>
>
>
> I have an ordered factor that I would like to include in the linear
> predictor of a binomial glm, where the estimated coefficients are
> constrained to be monotonic. Does anyone know how to do this? I've
> tried
> using an ordered factor but this does not have the desired effect, an
> (artificial) example of this follows;
>
>
>
> n <- 100
>
> strings <- sample(c("low", "med", "high"), n, TRUE)
>
>
>
> x.ordered <- ordered(strings, c("low", "med", "high"))
>
> x.unordered <- factor(strings)
>
>
>
> pr <- ifelse(strings == "low", 0.4, ifelse(strings == "med", 0.3, 0.2))
>
>
>
> y <- rbinom(n, 1, pr)
>
>
>
> mod.ordered <- glm(y ~ x.ordered, binomial)
>
> mod.unordered <- glm(y ~ x.unordered, binomial)
>
>
>
> summary(mod.ordered)
>
> summary(mod.unordered)
>
> -----------------------------------------
> ********************************************** Confidentiality: The
> contents of this e-mail and any attachments transmitted with it are
> intended to be confidential to the intended recipient; and may be
> privileged or otherwise protected from disclosure. If you are not an
> intended recipient of this e-mail, do not duplicate or redistribute it
> by any means. Please delete it and any attachments and notify the
> sender that you have received it in error. This e-mail is sent by a
> William Hill PLC group company. The William Hill group companies
> include, among others, William Hill PLC (registered number 4212563),
> William Hill Organization Limited (registered number 278208), William
> Hill Credit Limited (registered number 413846), WHG (International)
> Limited (registered number 99191) and WHG Trading Limited (registered
> number 101439). Each of William Hill PLC, William Hill Organization
> Limited and William Hill Credit Limited is registered in Engl!
>
> and and Wales and has its registered office at Greenside House, 50
> Station Road, Wood Green, London N22 7TP. Each of WHG (International)
> Limited and WHG Trading Limited is registered in Gibraltar and has its
> registered office at 6/1 Waterport Place, Gibraltar. Unless
> specifically indicated otherwise, the contents of this e-mail are
> subject to contract; and are not an official statement, and do not
> necessarily represent the views, of William Hill PLC, its subsidiaries
> or affiliated companies. Please note that neither William Hill PLC, nor
> its subsidiaries and affiliated companies can accept any responsibility
> for any viruses contained within this e-mail and it is your
> responsibility to scan any emails and their attachments. William Hill
> PLC, its subsidiaries and affiliated companies may monitor e-mail
> traffic data and also the content of e-mails for effective operation of
> the e-mail system, or for security, purposes.
> *********************************************
>
> [[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.