[R] I am struggling with contrasts

Sorkin, John j@ork|n @end|ng |rom @om@um@ry|@nd@edu
Tue Mar 10 11:50:33 CET 2020


I have not clearly stated my question. I would like to obtain the point estimate and SE (or point estimate and 95% CI) of a linear combination of the the independent variables included in my regression model. In a simple model having a single categorical variable that has two levels (Group1 and Group2) obtaining the estimate and its SE (or the estimate and a 95% CI) requires knowing the betas produced by the model, the SEs of the betas (which are easily obtained) along with the variance covariance of the estimates. I assume that the variance covariance matrix can be obtained but working the the matrix is a real pain. I am looking for a SIMPLE way to get the point estimate and its SE without having to slog though getting all the estimates, their SEs manually adding them together and including the covariances.
For example if my model is

rate = group and group has the value 1, I want:

beta rate = beta intercept + beta group
variance rate = variance intercept + variance group + 2*covariance (intercept,group)

I suspect I can do this calculation manually, but I would really like to find a way that R will do the computation for me.

My regression model is:
fit1 <- glm(HGE ~ Group,family=quasipoisson(link="log"), data=dataForR,offset=logFU)

In SAS this can be accomplished using estimate statements; I suspect that is an R analogue of the SAS estimate statement, but I don't know that the analogue is .

Thank you,

John

Particular thanks are due to Peter Dalgaard, Berwin Turlach, and Mark Leeds who responded to my original, not well formulated posting.



Thank you,

John





John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


________________________________
From: peter dalgaard <pdalgd using gmail.com>
Sent: Tuesday, March 10, 2020 5:07 AM
To: Berwin A Turlach <Berwin.Turlach using gmail.com>
Cc: Sorkin, John <jsorkin using som.umaryland.edu>; r-help using r-project.org (r-help using r-project.org) <r-help using r-project.org>
Subject: Re: [R] I am struggling with contrasts

Yes. Contrasts, by definition, represents between-group differences, so cannot yield individual group levels. The closest you get is that the _intercept_ is the level of the base group in treatment contrasts, and relevel() will allow you to change the base level.

-pd

> On 10 Mar 2020, at 04:06 , Berwin A Turlach <Berwin.Turlach using gmail.com> wrote:
>
> G'day John,
>
> On Tue, 10 Mar 2020 01:42:46 +0000
> "Sorkin, John" <jsorkin using som.umaryland.edu> wrote:
>
>> I am running a Poisson regression with a single outcome variable,
>> HGE, and a single independent variable, a factor, Group which can be
>> one of two values, Group1, or Group2. I am trying to define contrasts
>> that will give me the values of my outcome variable (HGE) when
>> group=Group1 and when group=Group2.
>
> Not sure what you mean, but I am suspecting you are after this output:
>
> R> fit0 <- glm(HGE ~ Group - 1,family=poisson,data=dataForR,offset=logFU)
> R> summary(fit0)
>
> Cheers,
>
>        Berwin
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=02%7C01%7C%7C4b9ea7f815e0494abf0908d7c4d2770c%7C717009a620de461a88940312a395cac9%7C0%7C0%7C637194280543093844&sdata=QFyKBzxZfkXAjASSUYsSnMJ1CiZIjXDK6JEgKHrV5vg%3D&reserved=0
> PLEASE do read the posting guide https://nam03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.R-project.org%2Fposting-guide.html&data=02%7C01%7C%7C4b9ea7f815e0494abf0908d7c4d2770c%7C717009a620de461a88940312a395cac9%7C0%7C0%7C637194280543093844&sdata=pf%2BQVOSaoGq5HwJ1QjMawCArFC1yjpG9yL%2Fs5dv5wJw%3D&reserved=0
> and provide commented, minimal, self-contained, reproducible code.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com










	[[alternative HTML version deleted]]



More information about the R-help mailing list