[R] changing model matrix restriction in lm()
Greg Snow
538280 at gmail.com
Wed Oct 23 21:36:04 CEST 2013
Also look at ?relevel
On Wed, Oct 23, 2013 at 7:45 AM, Rafael Moral
<rafa_moral2004 at yahoo.com.br> wrote:
> Thank you very much!
>
> Best,
> Rafael.
>
> --------------------------------------------
> Em qua, 23/10/13, Bert Gunter <gunter.berton at gene.com> escreveu:
>
> Assunto: Re: [R] changing model matrix restriction in lm()
>
> Cc: "r-help at r-project.org" <r-help at r-project.org>
> Data: Quarta-feira, 23 de Outubro de 2013, 11:29
>
> ?contrasts
> ?C
>
> Cheers,
> Bert
>
> On Wed, Oct 23, 2013 at 6:00 AM, Rafael Moral
>
> wrote:
> > Dear useRs,
> > I was wondering if there was a way of changing the
> model matrix restriction automatically in the formula
> statement when fitting a model using, for example, lm().
> > When we do
> >
> > set.seed(100)
> > y <- rnorm(12)
> > A <- gl(3, 4)
> > summary(lm(y ~ A))
> >
> > we obtain A1=0 as a baseline and A2 and A3 as effects.
> > However, if I want to use A2=0 as a baseline, I can do
> >
> > X <- cbind(1, model.matrix(lm(y ~ A - 1)))[,-3]
> > summary(lm(y ~ X))
> >
> > I wonder if there is a way of specifying the
> restriction in the parameters directly in the formula
> argument instead of building the desired model matrix.
> >
> > Best wishes,
> > Rafael.
> >
> > ______________________________________________
> > 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.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> (650) 467-7374
>
> ______________________________________________
> 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.
--
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com
More information about the R-help
mailing list