GLS: Generalized least squres for regression analysis considering...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/GLS.R

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

1
GLS(model, data, omega = NULL)

Arguments

model

Symbolic description of the model to be fitted.

data

Data frame containing variables in the model.

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

lm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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)

FinePop2 documentation built on March 26, 2020, 9:01 p.m.