Erich Striessnig
2011-Aug-04 08:48 UTC
[R] How to get the test statistic corresponding to the p-value in mtable?
Dear R-Users, I want to use mtable from package "memisc" to produce Latex-style estimation output. However, mtable() only gives me a p-value and not the corresponding test-statistic. Does anyone know how to extract it, either from a glm/anova object or mtable? Here is a short example: # Run this #################### install.packages("memisc") library(memisc) set.seed(1) data1 <- rnorm(400) dim(data1) <- c(100,4) data1 <- as.data.frame(data1) names(data1) <- c("y",paste("x",1:3,sep="")) res1 <- glm(y~x1+x2,data=data1) res2 <- glm(y~x2+x3,data=data1) mtable("Model 1"=res1,"Model 2"=res2) ############################# Cheers, Erich [[alternative HTML version deleted]]
Joshua Wiley
2011-Aug-04 08:55 UTC
[R] How to get the test statistic corresponding to the p-value in mtable?
Hi Erich, Thanks for the example. You can access the coefficient table output by a call to summary: coef(summary(res1)) so if you want the test statistic (the t value here), just extract the third column of the matrix: coef(summary(res1))[, 3] or to keep in matrixy form coef(summary(res1))[, 3, drop = FALSE] Hope this helps, Josh On Thu, Aug 4, 2011 at 1:48 AM, Erich Striessnig <striess at iiasa.ac.at> wrote:> Dear R-Users, > > I want to use mtable from package "memisc" to produce Latex-style estimation > output. However, mtable() only gives me a p-value and not the corresponding > test-statistic. Does anyone know how to extract it, either from a glm/anova > object or mtable? Here is a short example: > > # Run this #################### > install.packages("memisc") > library(memisc) > > set.seed(1) > data1 <- rnorm(400) > dim(data1) <- c(100,4) > data1 <- as.data.frame(data1) > names(data1) <- c("y",paste("x",1:3,sep="")) > > res1 <- glm(y~x1+x2,data=data1) > res2 <- glm(y~x2+x3,data=data1) > > mtable("Model 1"=res1,"Model 2"=res2) > ############################# > > Cheers, > Erich > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/