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. After beating my head 
against a wall day, I have decided to ask for help.

Please see code and below below.

DataForR <-
structure(list(Group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
                                   1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L,
                                   1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 2L, 2L, 2L,
                                   2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L,
                                   2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L,
                                   2L), .Label = c("Group1", "Group2"), class = 
"factor"), HGE = c(3,
                                   1, 0, 0, 0, 1, 0, 0, 0, 0, 3, 5, 0, 1, 0, 0, 
0, 0, 0, 0, 0, 0,
                                   0, 0, 0, 0, 1, 1, 3, 2, 0, 0, 0, 0, 3, 0, 2, 
3, 0, 2, 0, 0, 5,
                                   0, 0, 0, 1, 0, 1, 3, 3, 4, 1, 0, 0, 2, 0, 0, 
6, 2, 0, 0, 1, 4,
                                   5, 0, 3, 11, 0, 0, 0, 2), logFU = 
c(3.11397816503905, 2.68510374827232,
                                   0.991192040047273, 0.611801541105993, 
1.06925022633126, 2.57001131045749,
                                   0.527354925717201, 0.608027951722353, 
1.35812348415319, 1.99809590222588,
                                   2.73814823225949, 2.89037175789616, 
1.02290046693241, 0.58120642052779,
                                   1.03160157838515, 0.457336938815005, 
1.56760267327335, 2.29561642367795,
                                   -0.296984465114094, 0.4812251539897, 
0.606135803570315, -0.349754501094159,
                                   1.34464013381591, 1.03777062941186, 
0.604240068405416, 0.416972714959644,
                                   1.90748277192143, 1.92586939817187, 
2.84013378690079, 0.611801541105993,
                                   1.57697211118452, 1.09047743846183, 
0.412385550952738, -0.129570991408426,
                                   0.752136479035649, 1.3518538711396, 
1.44118361285158, 1.24779030782599,
                                   1.0893098960058, 1.40008768325223, 
1.36257783450257, 1.06686359035353,
                                   1.93493747038584, 0.549645615615573, 
-0.0794641713542468, -0.220542769614152,
                                   2.18753270073519, 0.613683009205699, 
1.74010061095415, 1.76596671466633,
                                   0.508740117274969, 1.71791855542817, 
1.90335053463652, 1.24679280150886,
                                   0.541597282432744, 2.16984703638892, 
1.91926871414052, 1.030363188134,
                                   1.07992015565596, 1.78886175639198, 
1.07755887947028, -0.117783035656384,
                                   1.49866152280324, 1.03530757397947, 
2.68225744654048, 1.58909347171687,
                                   1.49477500411396, 1.47749256296521, 
1.77129690199719, 1.5668782980153,
                                   2.06633519417454, 2.62758302063679)), class 
= "data.frame", row.names = c(NA,
                                   -72L))

# Show that dataForR is a dataframe.
summary(dataForR)
levels(dataForR$Group)
class(dataForR$Group)
# Fit the model.
fit0 <- glm(HGE ~ Group,family=poisson,data=dataForR,offset=logFU)
summary(fit0)

# Get value for Group1
MyContrast=list(xxx=c(1,0))
MyContrast
contrast(fit0,MyContrast)

# Get value for Group2
MyContrast=list(xxx=c(1,1))
MyContrast
contrast(fit0,MyContrast)

I hope you can help me understand how to use the contrast statement.

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)


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to