The R
package METests
implements tests for various hypotheses about measurement error as proposed in Wilhelm (2019). The R package contains help files describing the various commands, their syntax and gives examples.
Install the package devtools
if it isn't already:
install.packages("devtools")
Load the package devtools
:
library("devtools")
Install the package METests
:
install_github("danielwilhelm/R-ME-test")
Here is an example of how to test the null hypothesis that there is no measurement error in an explanatory variable X, using a second measurement Z and an outcome Y that depends on the true explanatory variable:
rm(list = ls(all = TRUE))
set.seed(1090)
library(METests)
# generate true explanatory variable
Xstar <- runif(100)
# generate repeated measurements X and Z
X <- Xstar + rnorm(100, 0, 0.3)
Z <- Xstar + rnorm(100, 0, 0.3)
# generate outcome
Y <- Xstar^2+Xstar/2 + rnorm(100, 0, 0.5)
# perform the test for measurement error using cross-validated bandwidth
DMTest(Y, X, Z)
Wilhelm, D. (2019), "Testing for the Presence of Measurement Error", CeMMAP Working Paper CWP48/19
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.