Skip to content

Logistic Regression with genetic component

2 messages · Danielle Duncan, Ben Bolker

#
Danielle Duncan <dlduncan2 <at> alaska.edu> writes:
You're on the right track.  paste() is probably what
you want, although you can also use interaction() to
get the interactions and then droplevels() to get
rid of the unobserved crosses.

d <- read.table(textConnection("
Present Absent   conc   Male Female
2         152                       0.13 a 1
6         121                          1 a 2
21         92                          2 b 3
24         89                          5 b 4
0        141                         10 c 5
5         95                         15 c      6"),
header=TRUE)

Either of these should give you what you want:
  
d <- droplevels(transform(d,cross=interaction(Male,Female)))
levels(d$cross)

d <- transform(d,cross=paste(Male,Female,sep="."))
levels(d$cross)

You should be a little careful -- if each cross is exposed
only to a single concentration, and if you treat cross as
a fixed effect, you will overparameterize your model.  If
you treat it as a random effect, e.g. using glmer in the
lme4 package:

glmer(cbind(Present,Absent)~conc+(1|cross),data=d)

you will effectively be fitting a model for overdispersion
(see the example in ?cbpp).