diff --git a/R/Wald.Test.R b/R/Wald.Test.R new file mode 100644 index 0000000..8cebac5 --- /dev/null +++ b/R/Wald.Test.R @@ -0,0 +1,28 @@ +# Wald test for estimating equations +# +# Author: Francois Pelletier +# +# LGPL-3.0 +############################################################################### + + +#' Wald test for estimating equations +#' @param param Estimated parameters +#' @param n Size of estimation sample +#' @param R Matrix of linear coefficients of the constraints +#' @param r vector of linear constants of the constraints +#' @param eqn.covariance Covariance matrix of the estimating equations +#' @param eqn.gradient Gradient matrix of the estimating equations +#' @param alpha level of confidence +#' @return A list containing the statistic, p-value and reject of the null hypothesis +#' +#' @author François Pelletier +Wald.Test <- function(param,n,R,r,eqn.covariance,eqn.gradient,alpha=0.05) +{ + wald.stat <- n * t(R %*% param - r) %*% + ginv(R %*% eqn.gradient %*% eqn.covariance %*% + t(eqn.gradient) %*% t(R)) %*% + (R %*% param - r) + PV <- pchisq(wald.stat,nrow(R)) + list(wald.stat=wald.stat, p.value=PV, reject=PV>1-alpha) +} \ No newline at end of file diff --git a/R/confidence.interval.QEE.R b/R/confidence.interval.QEE.R new file mode 100644 index 0000000..80a6d7c --- /dev/null +++ b/R/confidence.interval.QEE.R @@ -0,0 +1,22 @@ +# Confidence interval for QEE estimates +# +# Author: Francois Pelletier +# +# LGPL-3.0 +############################################################################### + +#' Confidence interval for QEE estimates +#' +#' Uses covariance.GEE +#' @param param Vector of parameters of the distribution function +#' @param covariance Covariance matrix +#' @param alpha confidence level +#' @return 3 line matrix with lower bound, estimate and upper bound +#' +#' @author François Pelletier +confidence.interval.QEE <- function(param,covariance,n,alpha=0.05) +{ + cbind(LOWER=param - sqrt(diag(covariance))*qt(alpha,n,lower=F), + ESTIMATE=param, + UPPER=param + sqrt(diag(covariance))*qt(alpha,n,lower=F)) +} \ No newline at end of file diff --git a/R/covariance.QEE.R b/R/covariance.QEE.R new file mode 100644 index 0000000..16eef5c --- /dev/null +++ b/R/covariance.QEE.R @@ -0,0 +1,19 @@ +# Covariance matrix using the component matrix M and V from QEE +# +# Author: Francois Pelletier +# +# LGPL-3.0 +############################################################################### + +#' Covariance matrix using the component matrix M and V from QEE +#' +#' Covariance matrix using the component matrix M and V from QEE +#' @param M Gradient matrix +#' @param V Covariance matrix of equations +#' @param n Sample size +#' @return Weighted covariance matrix +#' @author François Pelletier +covariance.QEE <- function(M,V,n) ## Omega +{ + ginv(M %*% ginv(V) %*% t(M))/n +} \ No newline at end of file diff --git a/man/Wald.Test.Rd b/man/Wald.Test.Rd new file mode 100644 index 0000000..7ad895d --- /dev/null +++ b/man/Wald.Test.Rd @@ -0,0 +1,35 @@ +\name{Wald.Test} +\alias{Wald.Test} +\title{Wald test for estimating equations} +\usage{ +Wald.Test(param, n, R, r, eqn.covariance, eqn.gradient, alpha = 0.05) +} +\arguments{ + \item{param}{Estimated parameters} + + \item{n}{Size of estimation sample} + + \item{R}{Matrix of linear coefficients of the + constraints} + + \item{r}{vector of linear constants of the constraints} + + \item{eqn.covariance}{Covariance matrix of the estimating + equations} + + \item{eqn.gradient}{Gradient matrix of the estimating + equations} + + \item{alpha}{level of confidence} +} +\value{ +A list containing the statistic, p-value and reject of the +null hypothesis +} +\description{ +Wald test for estimating equations +} +\author{ +François Pelletier +} + diff --git a/man/confidence.interval.QEE.Rd b/man/confidence.interval.QEE.Rd new file mode 100644 index 0000000..968200c --- /dev/null +++ b/man/confidence.interval.QEE.Rd @@ -0,0 +1,24 @@ +\name{confidence.interval.QEE} +\alias{confidence.interval.QEE} +\title{Confidence interval for QEE estimates} +\usage{ +confidence.interval.QEE(param, covariance, n, alpha = 0.05) +} +\arguments{ + \item{param}{Vector of parameters of the distribution + function} + + \item{covariance}{Covariance matrix} + + \item{alpha}{confidence level} +} +\value{ +3 line matrix with lower bound, estimate and upper bound +} +\description{ +Uses covariance.GEE +} +\author{ +François Pelletier +} + diff --git a/man/covariance.QEE.Rd b/man/covariance.QEE.Rd new file mode 100644 index 0000000..30834ff --- /dev/null +++ b/man/covariance.QEE.Rd @@ -0,0 +1,24 @@ +\name{covariance.QEE} +\alias{covariance.QEE} +\title{Covariance matrix using the component matrix M and V from QEE} +\usage{ +covariance.QEE(M, V, n) +} +\arguments{ + \item{M}{Gradient matrix} + + \item{V}{Covariance matrix of equations} + + \item{n}{Sample size} +} +\value{ +Weighted covariance matrix +} +\description{ +Covariance matrix using the component matrix M and V from +QEE +} +\author{ +François Pelletier +} +