Hi all, I encountered this problem with parameterization in R: I have two factors in a regression. how about if I want to set constraint so that for each factor, the sum of their coefficients equals to zero(instead of choosing a reference category)? for example, I have factor(variable) A(with three categories) and factor(variable) B(with 4 categories), and I want to parameterize so that the sum of the three coefficients of A = 0, and sum of the four coefficients of B = 0? I mean how to do it in R? Oana _________________________________________________________________ Don’t just search. Find. Check out the new MSN Search!
?contr.sum And Chapter 6 of MASS would have explained all this to you, so if you have further questions please consult it. On Tue, 27 Dec 2005, Oana Mocila wrote:> I encountered this problem with parameterization in R: > > I have two factors in a regression. how about if I want to > set constraint so that for each factor, the sum of their > coefficients equals to zero(instead of choosing a reference > category)? for example, I have factor(variable) A(with three > categories) and factor(variable) B(with 4 categories), and I want > to parameterize so that the sum of the three coefficients of > A = 0, and sum of the four coefficients of B = 0? I > mean how to do it in R?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
If you are not familiar with MASS (Modern Applied Statistics with S, 4th ed, Venables and Ripley 2002, Springer), I can assure you it is an excellent reference for learning R. There are many books on R that I have not read, but among the books in my personal library, I refer to MASS fairly frequently. If it is beyond your budget and not in a local library, I encourage you to investigate the possibility of having that library obtain a copy. If the library needs justification, please explain what you know of the book, how it became recommended for you, the problems you hope it will help you solve, etc. Spencer Graves Prof Brian Ripley wrote:> ?contr.sum > > And Chapter 6 of MASS would have explained all this to you, so if you have > further questions please consult it. > > On Tue, 27 Dec 2005, Oana Mocila wrote: > > >>I encountered this problem with parameterization in R: >> >>I have two factors in a regression. how about if I want to >>set constraint so that for each factor, the sum of their >>coefficients equals to zero(instead of choosing a reference >>category)? for example, I have factor(variable) A(with three >>categories) and factor(variable) B(with 4 categories), and I want >>to parameterize so that the sum of the three coefficients of >>A = 0, and sum of the four coefficients of B = 0? I >>mean how to do it in R? > >-- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA spencer.graves at pdf.com www.pdf.com <http://www.pdf.com> Tel: 408-938-4420 Fax: 408-280-7915
Dear Prof Brian Ripley and Graves, Thank you for your replies. MASS has been very helpful! Oana>From: Spencer Graves <spencer.graves at pdf.com> >To: Prof Brian Ripley <ripley at stats.ox.ac.uk> >CC: Oana Mocila <oanaom at hotmail.com>, r-help at stat.math.ethz.ch >Subject: Re: [R] parameterization of factor in R >Date: Tue, 27 Dec 2005 12:27:05 -0800 > > If you are not familiar with MASS (Modern Applied Statistics with S, 4th >ed, Venables and Ripley 2002, Springer), I can assure you it is an >excellent reference for learning R. There are many books on R that I have >not read, but among the books in my personal library, I refer to MASS >fairly frequently. If it is beyond your budget and not in a local library, >I encourage you to investigate the possibility of having that library >obtain a copy. If the library needs justification, please explain what you >know of the book, how it became recommended for you, the problems you hope >it will help you solve, etc. > > Spencer Graves > >Prof Brian Ripley wrote: > >>?contr.sum >> >>And Chapter 6 of MASS would have explained all this to you, so if you have >>further questions please consult it. >> >>On Tue, 27 Dec 2005, Oana Mocila wrote: >> >> >>>I encountered this problem with parameterization in R: >>> >>>I have two factors in a regression. how about if I want to >>>set constraint so that for each factor, the sum of their >>>coefficients equals to zero(instead of choosing a reference >>>category)? for example, I have factor(variable) A(with three >>>categories) and factor(variable) B(with 4 categories), and I want >>>to parameterize so that the sum of the three coefficients of >>>A = 0, and sum of the four coefficients of B = 0? I >>>mean how to do it in R? >> >> > >-- >Spencer Graves, PhD >Senior Development Engineer >PDF Solutions, Inc. >333 West San Carlos Street Suite 700 >San Jose, CA 95110, USA > >spencer.graves at pdf.com >www.pdf.com <http://www.pdf.com> >Tel: 408-938-4420 >Fax: 408-280-7915