Question

I use texreg to report the results of several random effects models (estimated using plm) in a table.

How can I add the p-value of a Hausman test (comparing each model to its fixed effects counterpart) to the goodness-of-fit measures reported by texreg? More generally, how can I report additional goodness-of-fit measures with texreg?

Was it helpful?

Solution

Assuming you have a model object called model, you should follow three steps:

1) Execute tr <- extract(model) in order to create a texreg object.

2) Manipulate this texreg object. Example:

tr@gof <- c(tr@gof, 0.5)
tr@gof.names <- c(tr@gof.names, "new row")
tr@gof.decimal <- c(tr@gof.decimal, TRUE)

3) Execute your original texreg command, but include the tr object instead of the original model. Example: screenreg(tr).

If you think a GOF measure should be included in an extract method included in the texreg package by default, you should make suggestions in the texreg forum on R-Forge.

OTHER TIPS

I found a way to add p-value of Hausman test (and other additional GOF measures) to texreg table. This method will fetch the GOF measures automatically so you do not have to do it manually. Ask if you have any questions.

Suppose that "random1" and "fixed1" are your models

First make the Hausman test into an object

ph1 <- phtest(random1, fixed1)

Then extract the coefficients of your model

sf1 <- summary(fixed1)
names1 <- rownames(sf1$coef)
co1 <- sf1$coef[, 1]
se1 <- sf1$coef[, 2]
pval1 <- sf1$coef[, 4]

Then extract your choice of GOFs

pval.ftest1 <- (summary(fixed1)$fstatistic)$p.value
rs1 <- sf1$r.squared
adj1 <- sf1$adj.r.squared
n1 <- nobs(fixed1)
phtest1 <- fp.value.fixed1

Choose which GOFs to include in the table

gof1 <- c(pval.ftest1, rs1, adj1, n1, phtest1)
gof.names1 <- c("p\\ (F-test)","R$^2$", "Adj.\\ R$^2$", "Num.\\ Obs.", "p\\ (Hausman\\ test)")

Choose decimal places for GOFs

decimal.places <- c(TRUE, TRUE, TRUE, FALSE, TRUE)

Create a texreg object

tr1 <- createTexreg(coef.names = names1, coef = co1, se = se1, pvalues = pval1, gof.names = gof.names1, gof = gof1, gof.decimal = decimal.places)

Check that everything looks OK with screenreg

screenreg(tr1)

Repeat the same thing for all of your models (fixed2, fixed3...& random2, random3...) if necessary.

Check that everything looks OK with all models before using texreg or htmlreg functions

screenreg(list(tr1, tr2, tr3, tr4, tr5))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top