[R] I am struggling with contrasts
Viechtbauer, Wolfgang (SP)
wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Tue Mar 10 12:07:13 CET 2020
The linearHypothesis() function from the 'car' package does this.
>From the help file: "The value of the linear hypothesis and its covariance matrix are returned respectively as "value" and "vcov" attributes of the object (but not printed)." For a single linear combination, vcov will be a single value and its square-root the SE.
From: R-help [mailto:r-help-bounces using r-project.org] On Behalf Of Sorkin, John
Sent: Tuesday, 10 March, 2020 11:51
To: peter dalgaard; Berwin A Turlach
Cc: r-help using r-project.org (r-help using r-project.org)
Subject: Re: [R] I am struggling with contrasts
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 .
Particular thanks are due to Peter Dalgaard, Berwin Turlach, and Mark Leeds who responded to my original, not well formulated posting.
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
Baltimore, MD 21201-1524
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
More information about the R-help