GLSME-package: Generalized Least Squares with Measurement Error

Description Details Author(s) References See Also Examples

Description

The code fits the general linear model with correlated data and observation error in both dependent and independent variables. The code fits the model

y = Dβ + r, r \sim N(0,V), V = σ^{2} T + V_{e} + Var[Uβ|D],

where y is a vector of observed response variables, D is an observed design matrix, β is a vector of regression parameters to be estimated, σ^{2}T is a matrix representing the true residual variance, V_{e} is a matrix of known measurement variance in the response variable, and Var[Uβ|D] is a matrix representing effects of measurement error in the predictor variables (see Hansen and Bartoszek 2012).

Details

Package: GLSME
Type: Package
Version: 1.0.5
Date: 2019-09-15
License: GPL (>= 2)
LazyLoad: yes

The code fits the general linear model with correlated data and observation error in both dependent and independent variables. The code fits the model

y = Dβ + r, r \sim N(0,V), V = σ^{2}T + V_{e} + Var[Uβ|D],

where y is a vector of observed response variables, D is an observed design matrix, β is a vector of regression parameters to be estimated, σ^{2}T is a matrix representing the true residual variance, V_{e} is a matrix of known measurement variance in the response variable, and Var[Uβ|D] is a matrix representing effects of measurement error in the predictor variables (see Hansen and Bartoszek 2012).

The estimation function is GLSME. It is an iterated (if the variance parameters are unknown) generalized least squares estimation procedure.

The motivation for the approach is that the observations and errors are correlated due to an underlying phylogeny but the program allows for any dependence structure.

In the mvSLOUCH package an alternative method of correcting for observation error is used. The error variance-covariance matrix enters the likelihood function by being added to the biological variance-covariance matrix.

Author(s)

Krzysztof Bartoszek Maintainer: <bartoszekkj@gmail.com>

References

Bartoszek, K. and Pienaar, J. and Mostad. P. and Andersson, S. and Hansen, T. F. (2012) A phylogenetic comparative method for studying multivariate adaptation. Journal of Theoretical Biology 314:204-215.

Hansen, T.F. (1997) Stabilizing selection and the comparative analysis of adaptation. Evolution 51:1341-1351.

Hansen, T.F. and Bartoszek, K. (2012) Interpreting the evolutionary regression: the interplay between observational and biological errors in phylogenetic comparative studies. Systematic Biology 61(3):413-425.

Hansen, T.F. and Pienaar, J. and Orzack, S.H. (2008) A comparative method for studying adaptation to randomly evolving environment. Evolution 62:1965-1977.

See Also

mvSLOUCH

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
n<-3 ## number of species
apetree<-ape::rtree(n)
### Define Brownian motion parameters to be able to simulate data under the Brownian motion model.
BMparameters<-list(vX0=matrix(0,nrow=2,ncol=1),Sxx=rbind(c(1,0),c(0.2,1)))
### Now simulate the data and remove the values corresponding to the internal nodes.
xydata<-mvSLOUCH::simulBMProcPhylTree(apetree,X0=BMparameters$vX0,Sigma=BMparameters$Sxx)
xydata<-xydata[(nrow(xydata)-n+1):nrow(xydata),]

x<-xydata[,1]
y<-xydata[,2]

yerror<-diag((stats::rnorm(n,mean=0,sd=0.1))^2) #create error matrix
y<-mvtnorm::rmvnorm(1,mean=y,sigma=yerror)[1,]
xerror<-diag((stats::rnorm(n,mean=0,sd=0.1))^2) #create error matrix
x<-mvtnorm::rmvnorm(1,mean=x,sigma=xerror)[1,]
GLSME(y=y, CenterPredictor=TRUE, D=cbind(rep(1, n), x), Vt=ape::vcv(apetree), 
Ve=yerror, Vd=list("F",ape::vcv(apetree)), Vu=list("F", xerror))

Example output

Loading required package: mvtnorm
Loading required package: corpcor
[1] "Finished running iteration 1 of iterated GLS. Current estimate : "
                      [,1]
                 0.8335679
x                0.1644604
ResponseVariance 0.7784966
[1] "Finished running iteration 2 of iterated GLS. Current estimate : "
                 ResponseVariance
                        0.8333517
x                       0.1640685
ResponseVariance        0.8392678
[1] "Finished running iteration 3 of iterated GLS. Current estimate : "
                      [,1]
                 0.8334249
x                0.1641899
ResponseVariance 0.8129200
$GLSestimate
       [,1]
  0.8333945
x 0.1641395

$errorGLSestim
       [,1]
  0.4569147
x 0.4032091

$BiasCorrectedGLSestimate
       [,1]
  0.8352535
x 0.1662016

$errorBiasCorrectedGLSestim
       [,1]
  0.4569147
x 0.4084535

$K
              x
  1 -0.01118528
x 0  0.98759270

$R2
          [,1]
[1,] 0.2811007

$R2BiasCorrectedModel
          [,1]
[1,] 0.2811315

$LogLikelihood
[1] -1.773932

$LogLikelihoodBiasCorrectedModel
[1] -1.773923

$PredictorVarianceConstantEstimate
                x 
0.000000 1.709717 

$ResponseVarianceConstantEstimate
[1] 0.81292

GLSME documentation built on Sept. 16, 2019, 1:03 a.m.