GLS {FinePop2} | R Documentation |
Generalized least squres for regression analysis considering auto correlation.
Description
This function provides a multiple regression analysis considering auto correlation of response variable using generalized least squres method (Aitken 1934). It supports lm
like format of model
. A typical model has the form response ~ terms
. Terms specification supports only first + second
form. Cross term specification of first * second
form is not supported.
Usage
GLS(model, data, omega = NULL)
Arguments
model |
Symbolic description of the model to be fitted. |
data |
Data frame containing variables in the |
omega |
A numeric matrix of auto correlation of responce variable. |
Value
coefficients |
Estimated coefficient, standard error, Z value and p value of each factor. |
variance |
Variance-covariance matrix of estimated coefficients. |
logL |
Log likelihood of fitted model. |
Author(s)
Reiichiro Nakamichi, Shuichi Kitada, Hirohisa Kishino
References
Aitken AC (1934) On Least-squares and Linear Combinations of Observations. Proceedings of the Royal Society of Edinburgh, 55, 42-48.
See Also
Examples
# Example data of Atlantic herring
data(herring)
ah.genepop.file <- tempfile()
ah.popname.file <- tempfile()
cat(herring$genepop, file=ah.genepop.file, sep="\n")
cat(herring$popname, file=ah.popname.file, sep=" ")
# Data load
popdata <- read.GENEPOP(ah.genepop.file, ah.popname.file)
# Pop-specific FST and correlation among populations
fst.popsp <- pop_specificFST(popdata, cov=TRUE)
cov.fst.popsp <- fst.popsp$cov
sd.fst.popsp <- sqrt(diag(cov.fst.popsp))
cov2.fst.popsp <- apply(cov.fst.popsp, 2, function(x){x / sd.fst.popsp})
cor.fst.popsp <- apply(cov2.fst.popsp, 1, function(x){x / sd.fst.popsp})
# Pop-pairwise FST and population structure
fst.poppair <- pop_pairwiseFST(popdata)
fst.md <- cmdscale(fst.poppair)
# GLS analysis of FST and environmental factors
test.data <- data.frame(fst=fst.md[,1], herring$environment)
GLS(fst~., scale(test.data), omega=cor.fst.popsp)