ajout d'intervalle de confiance, test wald

This commit is contained in:
François Pelletier 2014-02-26 20:03:47 -05:00
parent d8bbce7d4f
commit 348cadd3f3
6 changed files with 152 additions and 0 deletions

28
R/Wald.Test.R Normal file
View file

@ -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)
}

View file

@ -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))
}

19
R/covariance.QEE.R Normal file
View file

@ -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
}

35
man/Wald.Test.Rd Normal file
View file

@ -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
}

View file

@ -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
}

24
man/covariance.QEE.Rd Normal file
View file

@ -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
}