[R-sig-ME] Fitting known var-cov matrix in logistic regression model
mmackinnon at kilifi.kemri-wellcome.org
Thu Apr 21 20:46:04 CEST 2011
I wonder if someone can help me with the following problem.
I want to estimate the relationship between population allele
frequencies at a certain locus of interest and an environmental
variable. The hypothesis is that this environmental variable has
generated these different allele frequencies through differential
selection pressure on a locus under balancing selection (i.e., there is
negative selection which balances the differential positive selection on
the allele of interest). The allele frequencies are measured in 15
different populations, as are the environmental variables. However,
this environmental variable has been aggregated at the population level
so there are only 15 values that it can take.
The populations are genetically related to each other to different
degrees and so I want to reflect this structuring by including in the
model a variance-covariance matrix which captures this relatedness. I
estimated this variance-covariance matrix from a set of independent data
on SNPs at a whole lot of putatively neutral loci that are not expected
to show environmental clines.
I have already fit a logistic regression model to individual allele
data with an intercept term and a linear covariate term for the
environmental variable (see code below). I now want to add the
var-cov structure into the model. When I have done that I want to drop
the environmental variable from the model and test for its significance.
Thus I am testing for an environmentally related cline in allele
frequencies but allowing for the fact that some of the populations
‘group’ together genetically.
I have looked at corSymm in nmle as a way to fit a pre-defined
variance-cov matrix and the ‘correlation’ parameter in function gls
but can’t work out how to code my model. I also suspect I need to
use the ‘weights’ argument to account for the fact that the
variance-covariance matrix is estimated from populations of different
sizes, though I am just guessing on this!
Here is the code that I have used so far and which I now want to modify
to fit the var-cov matrix to reflect population structure.
Any help would be appreciated and thanks in advance.
#Values of the environmental variable for the 15 populations
env<-c(0.3102664, 0.2559409, 0.1693839, 0.4222649, 0.3060545,
0.3849413, 0.1421446, 0.1643560, 0.1863432, 0.1437641, 0.1126848,
0.2551449, 0.3908605, 0.1837551, 0.3115154)
#Allele frequencies in the 15 populations
freq<-c( 0.12534626, 0.09888190, 0.06529210, 0.07619048, 0.08200637,
0.06678383, 0.08702532, 0.05871560, 0.07647059, 0.07461977,
0.07801095, 0.08383234, 0.09095581, 0.06042654, 0.12130707)
#No. of people genotyped for each population , from which allele
frequencies were calculated
n<-c( 722, 1431,
#See the end of this email for the var-cov matrix that I want to fit.
#This is the code for fitting the model without the cov structure
glm.pred<-glm(freq~env,weights=n*2,family=binomial) #Note that 2
alleles per person, hence weights of n*2
#Plot observed and predicted data
#############And here is the output:###################
glm(formula = freq ~ env, family = binomial, weights = n * 2)
Min 1Q Median 3Q Max
-3.7845 -1.9236 -0.2746 1.4749 4.8131
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.68838 0.06294 -42.713 < 2e-16 ***
env 1.23044 0.23903 5.148 2.64e-07 ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’
0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 128.93 on 14 degrees of freedom
Residual deviance: 102.63 on 13 degrees of freedom
Number of Fisher Scoring iterations: 4
######End of output#########
#This is the var-cov matrix I want to fit into the linear model above.
#Visualise the population structure
This e-mail (including any attachment to it) contains information which
is confidential. It is intended only for the use of the named recipient.
If you have received this e-mail in error, please let us know by
replying to the sender, and immediately delete it from your system.
Please note, that in these circumstances, the use, disclosure,
distribution or copying of this information is strictly prohibited. We
apologize for any inconvenience that may have been caused to you.
KEMRI-Wellcome Trust Programme cannot accept any responsibility for the
accuracy or completeness of this message as it has been transmitted over
a public network. KEMRI-Wellcome Trust Programme reserves the right to
monitor all incoming and outgoing email traffic. Although the Programme
has taken reasonable precautions to ensure no viruses are present in
emails, it cannot accept responsibility for any loss or damage arising
from the use of the email or attachments. Any views expressed in this
message are those of the individual sender, except where the sender
specifically states them to be the views of KEMRI-Wellcome Trust
More information about the R-sig-mixed-models