GLSME.predict: Prediction for a new observation using parameters estimated...

Description Usage Arguments Value Author(s) References Examples

View source: R/GLSME.R

Description

The function takes parameters estimated by the GLSME function and predicts the response for a new observation of predictors. It also returns confidence intervals on the prediction. The function is still under development.

Usage

1
GLSME.predict(xo, glsme.estimate, vy, vx, alpha = 0.95)

Arguments

xo

The new observed predictors. In a intercept is in the model then a 1 has to be included for it.

glsme.estimate

The output of the GLSME function. Has to have format "long".

vy

Residual variance, both biological and measurement error.

vx

Biological variance in predictor, NOT observation variance of predictor. If there is a predictor in the model then a 0 row and column have to included for it.

alpha

Level for confidence interval.

Value

BiasCorr

Prediction using the bias corrected estimate.

  • prediction Predicted value

  • MSE Estimate of mean square error. They are calculated by the formula

    v_{y}+x_{o}^{T}(MSE[β | XO])x_{o}+ β'^{T} v_{x} β',

    where β' is the bias corrected estimate of β.

  • CI 1-α level confidence intervals. They are calculated by the formula

    √{1+1/n}*t_{α}*(v_{y}+ β'^{T} v_{x} β'),

    where t_{α} is the 1-α/2 level quantile of the t-distribution with n-k degrees of freedom, k is the number of regression parameters to estimate, β' is the bias corrected estimate of β and n is the sample size used in the estimation.

BiasUncorr

Prediction using the bias uncorrected estimate.

  • prediction Predicted value

  • MSE Estimate of mean square error. They are calculated by the formula

    v_{y}+x_{o}^{T}(MSE[β | XO])x_{o}+ β'^{T} v_{x} β',

    where β' is the bias uncorrected estimate of β.

  • CI 1-α level confidence intervals. They are calculated by the formula

    √{1+1/n}*t_{α}*(v_{y}+ β'^{T} v_{x} β'),

    where t_{α} is the 1-α/2 level quantile of the t-distribution with n-k degrees of freedom, k is the number of regression parameters to estimate, β' is the bias uncorrected estimate of β and n is the sample size used in the estimation.

Author(s)

Krzysztof Bartoszek

References

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
set.seed(12345)
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.res<-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),OutputType="long")
GLSME.predict(c(1,1), glsme.res, vy=1, vx=rbind(c(0,0),c(0,1)))

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