[R] latex.rms and models fit with Gls
Dylan Beaudette
debeaudette at ucdavis.edu
Sat May 29 00:31:03 CEST 2010
On Friday 28 May 2010, Frank E Harrell Jr wrote:
> On 05/28/2010 03:49 PM, Dylan Beaudette wrote:
> > Hi,
> >
> > I have fit a model using the rms package with the Gls() function.
> >
> > Is there a way to get the model estimates, std errors, and p-values (i.e.
> > what you get with print(fit)) into latex format?
> >
> > I have tried:
> >
> > f<- Gls(...)
> > latex(f, file='')
> >
> > ... but I get the following error
> >
> > Error in replace.substring.wild(s, old, new, test = test, front = front,
> > : does not handle> 1 * in old
> >
> > I think that this might have something to do with the fact that I fit the
> > model with GLS. (?)
Thanks for the quick reply Frank.
> What is GLS? I thought you fit the model with Gls. And please follow
> the posting guide instead of submitting only parts of lines of code.
Right, that would have been helpful. I didn't want to paste in the enormous
example from the Gls() manual page...
> The latex method for a Gls object typesets the mathematical form of the
> fitted model formula.
OK. That would have been nice too, but why did I get the above error message?
Lets recreate my data with an example:
# fake data
w <- rnorm(50)
x <- rnorm(50)
y <- rnorm(50)
z <- rnorm(50)
p <- runif(50)
g <- rep(c('a','b'), each=25)
# sprinkle in some NA
w[sample(1:50, 4)] <- NA
# fit data with similar correlation structure
f <- Gls(p ~ y * x * (z + w), na.action='na.omit', cor=corCAR1(form= ~ z | g))
# hmmm.... "Error in terms.default(f) : no terms component"
latex(f, file='')
The attached packages are:
nlme_3.1-96 rms_3.0-0 Hmisc_3.8-0 survival_2.35-8
> To get what you want:
>
> w <- nlme:::summary.gls(f)$tTable
> w
> latex(w, ....)
Got it. Thanks-- this does exactly what I was looking for. I wonder if it
might be worth the effort to include a small snippet on this in the manual
pages...
Cheers,
Dylan
> Frank
>
> > I am looking for a simple way to get a table of estimated coeficients
> > without hand-making a table in a text editor for inclusion within a LATEX
> > document.
> >
> > Thanks!
--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
More information about the R-help
mailing list