1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/test_general.R 3\name{phtest} 4\alias{phtest} 5\alias{phtest.formula} 6\alias{phtest.panelmodel} 7\title{Hausman Test for Panel Models} 8\usage{ 9phtest(x, ...) 10 11\method{phtest}{formula}( 12 x, 13 data, 14 model = c("within", "random"), 15 method = c("chisq", "aux"), 16 index = NULL, 17 vcov = NULL, 18 ... 19) 20 21\method{phtest}{panelmodel}(x, x2, ...) 22} 23\arguments{ 24\item{x}{an object of class \code{"panelmodel"} or \code{"formula"},} 25 26\item{\dots}{further arguments to be passed on. For the formula method, 27place argument \code{effect} here to compare, e.g., twoway models 28(\code{effect = "twoways"}) Note: Argument \code{effect} is not respected in 29the panelmodel method.} 30 31\item{data}{a \code{data.frame},} 32 33\item{model}{a character vector containing the names of two models 34(length(model) must be 2),} 35 36\item{method}{one of \code{"chisq"} or \code{"aux"},} 37 38\item{index}{an optional vector of index variables,} 39 40\item{vcov}{an optional covariance function,} 41 42\item{x2}{an object of class \code{"panelmodel"},} 43} 44\value{ 45An object of class \code{"htest"}. 46} 47\description{ 48Specification test for panel models. 49} 50\details{ 51The Hausman test (sometimes also called Durbin--Wu--Hausman test) 52is based on the difference of the vectors of coefficients of two 53different models. The \code{panelmodel} method computes the original 54version of the test based on a quadratic form 55\insertCite{HAUS:78}{plm}. The \code{formula} method, if 56\code{method="chisq"} (default), computes the original version of the 57test based on a quadratic form; if \code{method="aux"} then the 58auxiliary-regression-based version in Wooldridge (2010, 59Sec. 10.7.3.) is computed instead \insertCite{@WOOL:10 Sec.10.7.3}{plm}. 60Only the latter can be robustified by specifying a robust 61covariance estimator as a function through the argument \code{vcov} (see 62\strong{Examples}). 63 64The equivalent tests in the \strong{one-way} case using a between 65model (either "within vs. between" or "random vs. between") 66\insertCite{@see @HAUS:TAYL:81 or @BALT:13 Sec.4.3}{plm} can also 67be performed by \code{phtest}, but only for \code{test = "chisq"}, not for 68the regression-based test. NB: These equivalent tests using the 69between model do not extend to the two-ways case. There are, 70however, some other equivalent tests, 71\insertCite{@see @KANG:85 or @BALT:13 Sec.4.3.7}{plm}, 72but those are unsupported by \code{phtest}. 73} 74\examples{ 75 76data("Gasoline", package = "plm") 77form <- lgaspcar ~ lincomep + lrpmg + lcarpcap 78wi <- plm(form, data = Gasoline, model = "within") 79re <- plm(form, data = Gasoline, model = "random") 80phtest(wi, re) 81phtest(form, data = Gasoline) 82phtest(form, data = Gasoline, method = "aux") 83 84# robust Hausman test (regression-based) 85phtest(form, data = Gasoline, method = "aux", vcov = vcovHC) 86 87# robust Hausman test with vcov supplied as a 88# function and additional parameters 89phtest(form, data = Gasoline, method = "aux", 90 vcov = function(x) vcovHC(x, method="white2", type="HC3")) 91 92} 93\references{ 94\insertRef{HAUS:78}{plm} 95 96\insertRef{HAUS:TAYL:81}{plm} 97 98\insertRef{KANG:85}{plm} 99 100\insertRef{WOOL:10}{plm} 101 102\insertRef{BALT:13}{plm} 103} 104\author{ 105Yves Croissant, Giovanni Millo 106} 107\keyword{htest} 108