Re: [R] reference on contr.helmert and typo on its help page.

2009-11-10 Thread Gavin Simpson
On Mon, 2009-11-09 at 19:31 -0600, Peng Yu wrote:
 On Sun, Nov 8, 2009 at 7:32 PM, John Fox j...@mcmaster.ca wrote:
  Dear Peng,
 
  I'm tempted to try to get an entry in the fortunes package but will instead
  try to answer your questions directly:
 
 I can not install 'fortunes'. What are the fortunes packages about?
  install.packages(fortunes, repos=http://R-Forge.R-project.org;)
 Warning: unable to access index for repository
 http://R-Forge.R-project.org/bin/macosx/leopard/contrib/2.9
 Warning message:
 In getDependencies(pkgs, dependencies, available, lib) :
   package ‘fortunes’ is not available

It is on CRAN. just do:

install.packages(fortunes)

Choose a repository near to you and it should install.

There appears to be a problem with R-forge and Mac OsX binaries. The
code you show above works for me on linux and R2.9.x

G

 
  I did read Section 9.1.2 and various other textbooks before posting my
  questions. But each reference uses slightly different notations and
  terminology. I get confused and would like a description that
  summaries everything so that I don't have to refer to many different
  resources. May I ask a few questions on the section in your textbook?
 
  Which variable in Section 9.1.2 is a matrix of contrasts mentioned
  in the help page of 'contr.helmert'? Which matrix of contrast in R
  corresponds to dummy regression? With different R formula, e.g. y ~ x
  vs. y ~ x -1, $X_F$ (mentioned on page 189) is different and hence
  $\beta_F$ (mentioned in eq. 9.3) is be different. So my understanding
  is that the matrix of contrast should depend on the formula. But it is
  not according to the help page of contr.helmert.
 
  If the model is simply y ~ A, for the factor A, then cbind(1, contrasts(A))
  is what I call X_B, the row-basis of the model matrix. As I explain in the
  section that you read, the level means are mu = X_B beta, and thus beta =
  X_B^-1 mu = 0 are the hypotheses tested by the contrasts. Moreover, if, as
  in Helmert contrasts, the columns of X_B are orthogonal, then so are the
  rows of X_B^-1, and the latter are simply rescalings of the former. That
  allows one conveniently to code the hypotheses directly in X_B; all this is
  also explained in that section of my book, and is essentially what Peter D.
  told you. In R, contr.treatment and contr.SAS provide dummy-variable (0/1)
  coding of regressors, differing only in the selection of the reference
  level.
 
 What is the mathematical definition of polynomial contrasts? Why
 polynomial contrasts are the default contrasts for ordered factors?
 
 __
 R-help@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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-09 Thread Peng Yu
On Sun, Nov 8, 2009 at 7:32 PM, John Fox j...@mcmaster.ca wrote:
 Dear Peng,

 I'm tempted to try to get an entry in the fortunes package but will instead
 try to answer your questions directly:

I can not install 'fortunes'. What are the fortunes packages about?
 install.packages(fortunes, repos=http://R-Forge.R-project.org;)
Warning: unable to access index for repository
http://R-Forge.R-project.org/bin/macosx/leopard/contrib/2.9
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘fortunes’ is not available

 I did read Section 9.1.2 and various other textbooks before posting my
 questions. But each reference uses slightly different notations and
 terminology. I get confused and would like a description that
 summaries everything so that I don't have to refer to many different
 resources. May I ask a few questions on the section in your textbook?

 Which variable in Section 9.1.2 is a matrix of contrasts mentioned
 in the help page of 'contr.helmert'? Which matrix of contrast in R
 corresponds to dummy regression? With different R formula, e.g. y ~ x
 vs. y ~ x -1, $X_F$ (mentioned on page 189) is different and hence
 $\beta_F$ (mentioned in eq. 9.3) is be different. So my understanding
 is that the matrix of contrast should depend on the formula. But it is
 not according to the help page of contr.helmert.

 If the model is simply y ~ A, for the factor A, then cbind(1, contrasts(A))
 is what I call X_B, the row-basis of the model matrix. As I explain in the
 section that you read, the level means are mu = X_B beta, and thus beta =
 X_B^-1 mu = 0 are the hypotheses tested by the contrasts. Moreover, if, as
 in Helmert contrasts, the columns of X_B are orthogonal, then so are the
 rows of X_B^-1, and the latter are simply rescalings of the former. That
 allows one conveniently to code the hypotheses directly in X_B; all this is
 also explained in that section of my book, and is essentially what Peter D.
 told you. In R, contr.treatment and contr.SAS provide dummy-variable (0/1)
 coding of regressors, differing only in the selection of the reference
 level.

What is the mathematical definition of polynomial contrasts? Why
polynomial contrasts are the default contrasts for ordered factors?

__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread David Winsemius


On Nov 8, 2009, at 11:03 AM, Peng Yu wrote:


I'm wondering which textbook discussed the various contrast matrices
mentioned in the help page of 'contr.helmert'. Could somebody let me
know?



My version of Modern Applied Statistics in S (aka MASS) deals with  
it in enough detail for a person with background to understand. At one  
point I asked Ripley whether later editions of MASS expanded the  
coverage of that topic but my memory is that he did not reply. Coming  
from a perspective that emphasized regression, I found it rather terse  
(2 pages), so there might be one of the more recently published texts  
that spends more time developing the concepts from basics.


Statistical Models in S also covers the topic (5 pages)  in an early  
chapter, again at a level that assumes prior training in ANOVA models.



BTW, in R version 2.9.1, there is a typo on the help page of
'contr.helmert' ('cont.helmert' should be 'contr.helmert').

__

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Gabor Grothendieck
On Sun, Nov 8, 2009 at 11:59 AM, Peng Yu pengyu...@gmail.com wrote:
 On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 On 08/11/2009 11:03 AM, Peng Yu wrote:

 I'm wondering which textbook discussed the various contrast matrices
 mentioned in the help page of 'contr.helmert'. Could somebody let me
 know?

 Doesn't the reference on that page discuss them?

 It does explain what the functions are. But I need a more basic and
 complete reference. For example, I want to understand what 'Helmert
 parametrization' (on page 33 of 'Statistical Models in S') is.


Just google for: Helmert contrasts

__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Peter Dalgaard

Gabor Grothendieck wrote:

On Sun, Nov 8, 2009 at 11:59 AM, Peng Yu pengyu...@gmail.com wrote:

On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

On 08/11/2009 11:03 AM, Peng Yu wrote:

I'm wondering which textbook discussed the various contrast matrices
mentioned in the help page of 'contr.helmert'. Could somebody let me
know?

Doesn't the reference on that page discuss them?

It does explain what the functions are. But I need a more basic and
complete reference. For example, I want to understand what 'Helmert
parametrization' (on page 33 of 'Statistical Models in S') is.



Just google for: Helmert contrasts


Or,

 contr.helmert(5)
  [,1] [,2] [,3] [,4]
1   -1   -1   -1   -1
21   -1   -1   -1
302   -1   -1
4003   -1
50004

 MASS::fractions(MASS::ginv(contr.helmert(5)))
 [,1]  [,2]  [,3]  [,4]  [,5]
[1,]  -1/2   1/2 0 0 0
[2,]  -1/6  -1/6   1/3 0 0
[3,] -1/12 -1/12 -1/12   1/4 0
[4,] -1/20 -1/20 -1/20 -1/20   1/5

and apply brains.

I.e., except for a slightly odd multiplier, the parameters represent the 
 difference between each level and the average of the preceding levels.


--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Peng Yu
On Sun, Nov 8, 2009 at 11:28 AM, Peter Dalgaard
p.dalga...@biostat.ku.dk wrote:
 Gabor Grothendieck wrote:

 On Sun, Nov 8, 2009 at 11:59 AM, Peng Yu pengyu...@gmail.com wrote:

 On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch murd...@stats.uwo.ca
 wrote:

 On 08/11/2009 11:03 AM, Peng Yu wrote:

 I'm wondering which textbook discussed the various contrast matrices
 mentioned in the help page of 'contr.helmert'. Could somebody let me
 know?

 Doesn't the reference on that page discuss them?

 It does explain what the functions are. But I need a more basic and
 complete reference. For example, I want to understand what 'Helmert
 parametrization' (on page 33 of 'Statistical Models in S') is.


 Just google for: Helmert contrasts

 Or,

 contr.helmert(5)
  [,1] [,2] [,3] [,4]
 1   -1   -1   -1   -1
 2    1   -1   -1   -1
 3    0    2   -1   -1
 4    0    0    3   -1
 5    0    0    0    4

 MASS::fractions(MASS::ginv(contr.helmert(5)))
     [,1]  [,2]  [,3]  [,4]  [,5]
 [1,]  -1/2   1/2     0     0     0
 [2,]  -1/6  -1/6   1/3     0     0
 [3,] -1/12 -1/12 -1/12   1/4     0
 [4,] -1/20 -1/20 -1/20 -1/20   1/5

 and apply brains.

 I.e., except for a slightly odd multiplier, the parameters represent the
  difference between each level and the average of the preceding levels.

I realized that my questions are what a contrast matrix is and how it
is related to hypothesis testing. For a give hypothesis, how to get
the corresponding contrast matrix in a systematical way? There are
some online materials, but they are all diffused. I have also read the
book Applied Linear Regression Models, which doesn't give a complete
descriptions on all the aspects of contrast and contrast matrix. But I
would want a textbook that gives a complete description, so that I
don't have to look around for other materials.

__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread John Fox
Dear Peng Yu,

Perhaps you're referring to my text, Applied Linear Regression Analysis and
Generalized Linear Models, since I seem to recall that you sent me a number
of questions about it. See Section 9.1.2 on linear contrasts for the answer
to your question.

I hope this helps,
 John


John Fox
Senator William McMaster 
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Peng Yu
 Sent: November-08-09 4:52 PM
 To: r-h...@stat.math.ethz.ch
 Subject: Re: [R] reference on contr.helmert and typo on its help page.
 
 On Sun, Nov 8, 2009 at 11:28 AM, Peter Dalgaard
 p.dalga...@biostat.ku.dk wrote:
  Gabor Grothendieck wrote:
 
  On Sun, Nov 8, 2009 at 11:59 AM, Peng Yu pengyu...@gmail.com wrote:
 
  On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch murd...@stats.uwo.ca
  wrote:
 
  On 08/11/2009 11:03 AM, Peng Yu wrote:
 
  I'm wondering which textbook discussed the various contrast matrices
  mentioned in the help page of 'contr.helmert'. Could somebody let me
  know?
 
  Doesn't the reference on that page discuss them?
 
  It does explain what the functions are. But I need a more basic and
  complete reference. For example, I want to understand what 'Helmert
  parametrization' (on page 33 of 'Statistical Models in S') is.
 
 
  Just google for: Helmert contrasts
 
  Or,
 
  contr.helmert(5)
   [,1] [,2] [,3] [,4]
  1   -1   -1   -1   -1
  2    1   -1   -1   -1
  3    0    2   -1   -1
  4    0    0    3   -1
  5    0    0    0    4
 
  MASS::fractions(MASS::ginv(contr.helmert(5)))
      [,1]  [,2]  [,3]  [,4]  [,5]
  [1,]  -1/2   1/2     0     0     0
  [2,]  -1/6  -1/6   1/3     0     0
  [3,] -1/12 -1/12 -1/12   1/4     0
  [4,] -1/20 -1/20 -1/20 -1/20   1/5
 
  and apply brains.
 
  I.e., except for a slightly odd multiplier, the parameters represent the
   difference between each level and the average of the preceding levels.
 
 I realized that my questions are what a contrast matrix is and how it
 is related to hypothesis testing. For a give hypothesis, how to get
 the corresponding contrast matrix in a systematical way? There are
 some online materials, but they are all diffused. I have also read the
 book Applied Linear Regression Models, which doesn't give a complete
 descriptions on all the aspects of contrast and contrast matrix. But I
 would want a textbook that gives a complete description, so that I
 don't have to look around for other materials.
 
 __
 R-help@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.

__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread Peng Yu
Dear John,

I did read Section 9.1.2 and various other textbooks before posting my
questions. But each reference uses slightly different notations and
terminology. I get confused and would like a description that
summaries everything so that I don't have to refer to many different
resources. May I ask a few questions on the section in your textbook?

Which variable in Section 9.1.2 is a matrix of contrasts mentioned
in the help page of 'contr.helmert'? Which matrix of contrast in R
corresponds to dummy regression? With different R formula, e.g. y ~ x
vs. y ~ x -1, $X_F$ (mentioned on page 189) is different and hence
$\beta_F$ (mentioned in eq. 9.3) is be different. So my understanding
is that the matrix of contrast should depend on the formula. But it is
not according to the help page of contr.helmert.

Regards,
Peng

On Sun, Nov 8, 2009 at 6:17 PM, John Fox j...@mcmaster.ca wrote:
 Dear Peng Yu,

 Perhaps you're referring to my text, Applied Linear Regression Analysis and
 Generalized Linear Models, since I seem to recall that you sent me a number
 of questions about it. See Section 9.1.2 on linear contrasts for the answer
 to your question.

 I hope this helps,
  John

 
 John Fox
 Senator William McMaster
  Professor of Social Statistics
 Department of Sociology
 McMaster University
 Hamilton, Ontario, Canada
 web: socserv.mcmaster.ca/jfox


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Peng Yu
 Sent: November-08-09 4:52 PM
 To: r-h...@stat.math.ethz.ch
 Subject: Re: [R] reference on contr.helmert and typo on its help page.

 On Sun, Nov 8, 2009 at 11:28 AM, Peter Dalgaard
 p.dalga...@biostat.ku.dk wrote:
  Gabor Grothendieck wrote:
 
  On Sun, Nov 8, 2009 at 11:59 AM, Peng Yu pengyu...@gmail.com wrote:
 
  On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch murd...@stats.uwo.ca
  wrote:
 
  On 08/11/2009 11:03 AM, Peng Yu wrote:
 
  I'm wondering which textbook discussed the various contrast matrices
  mentioned in the help page of 'contr.helmert'. Could somebody let me
  know?
 
  Doesn't the reference on that page discuss them?
 
  It does explain what the functions are. But I need a more basic and
  complete reference. For example, I want to understand what 'Helmert
  parametrization' (on page 33 of 'Statistical Models in S') is.
 
 
  Just google for: Helmert contrasts
 
  Or,
 
  contr.helmert(5)
   [,1] [,2] [,3] [,4]
  1   -1   -1   -1   -1
  2    1   -1   -1   -1
  3    0    2   -1   -1
  4    0    0    3   -1
  5    0    0    0    4
 
  MASS::fractions(MASS::ginv(contr.helmert(5)))
      [,1]  [,2]  [,3]  [,4]  [,5]
  [1,]  -1/2   1/2     0     0     0
  [2,]  -1/6  -1/6   1/3     0     0
  [3,] -1/12 -1/12 -1/12   1/4     0
  [4,] -1/20 -1/20 -1/20 -1/20   1/5
 
  and apply brains.
 
  I.e., except for a slightly odd multiplier, the parameters represent the
   difference between each level and the average of the preceding levels.

 I realized that my questions are what a contrast matrix is and how it
 is related to hypothesis testing. For a give hypothesis, how to get
 the corresponding contrast matrix in a systematical way? There are
 some online materials, but they are all diffused. I have also read the
 book Applied Linear Regression Models, which doesn't give a complete
 descriptions on all the aspects of contrast and contrast matrix. But I
 would want a textbook that gives a complete description, so that I
 don't have to look around for other materials.

 __
 R-help@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.




__
R-help@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.


Re: [R] reference on contr.helmert and typo on its help page.

2009-11-08 Thread John Fox
Dear Peng,

I'm tempted to try to get an entry in the fortunes package but will instead
try to answer your questions directly:

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Peng Yu
 Sent: November-08-09 7:41 PM
 To: r-h...@stat.math.ethz.ch
 Subject: Re: [R] reference on contr.helmert and typo on its help page.
 
 Dear John,
 
 I did read Section 9.1.2 and various other textbooks before posting my
 questions. But each reference uses slightly different notations and
 terminology. I get confused and would like a description that
 summaries everything so that I don't have to refer to many different
 resources. May I ask a few questions on the section in your textbook?
 
 Which variable in Section 9.1.2 is a matrix of contrasts mentioned
 in the help page of 'contr.helmert'? Which matrix of contrast in R
 corresponds to dummy regression? With different R formula, e.g. y ~ x
 vs. y ~ x -1, $X_F$ (mentioned on page 189) is different and hence
 $\beta_F$ (mentioned in eq. 9.3) is be different. So my understanding
 is that the matrix of contrast should depend on the formula. But it is
 not according to the help page of contr.helmert.

If the model is simply y ~ A, for the factor A, then cbind(1, contrasts(A))
is what I call X_B, the row-basis of the model matrix. As I explain in the
section that you read, the level means are mu = X_B beta, and thus beta =
X_B^-1 mu = 0 are the hypotheses tested by the contrasts. Moreover, if, as
in Helmert contrasts, the columns of X_B are orthogonal, then so are the
rows of X_B^-1, and the latter are simply rescalings of the former. That
allows one conveniently to code the hypotheses directly in X_B; all this is
also explained in that section of my book, and is essentially what Peter D.
told you. In R, contr.treatment and contr.SAS provide dummy-variable (0/1)
coding of regressors, differing only in the selection of the reference
level.

John

 
 Regards,
 Peng
 
 On Sun, Nov 8, 2009 at 6:17 PM, John Fox j...@mcmaster.ca wrote:
  Dear Peng Yu,
 
  Perhaps you're referring to my text, Applied Linear Regression Analysis
and
  Generalized Linear Models, since I seem to recall that you sent me a
number
  of questions about it. See Section 9.1.2 on linear contrasts for the
answer
  to your question.
 
  I hope this helps,
   John
 
  
  John Fox
  Senator William McMaster
   Professor of Social Statistics
  Department of Sociology
  McMaster University
  Hamilton, Ontario, Canada
  web: socserv.mcmaster.ca/jfox
 
 
  -Original Message-
  From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]
  On
  Behalf Of Peng Yu
  Sent: November-08-09 4:52 PM
  To: r-h...@stat.math.ethz.ch
  Subject: Re: [R] reference on contr.helmert and typo on its help page.
 
  On Sun, Nov 8, 2009 at 11:28 AM, Peter Dalgaard
  p.dalga...@biostat.ku.dk wrote:
   Gabor Grothendieck wrote:
  
   On Sun, Nov 8, 2009 at 11:59 AM, Peng Yu pengyu...@gmail.com
wrote:
  
   On Sun, Nov 8, 2009 at 10:11 AM, Duncan Murdoch
murd...@stats.uwo.ca
   wrote:
  
   On 08/11/2009 11:03 AM, Peng Yu wrote:
  
   I'm wondering which textbook discussed the various contrast
matrices
   mentioned in the help page of 'contr.helmert'. Could somebody let
me
   know?
  
   Doesn't the reference on that page discuss them?
  
   It does explain what the functions are. But I need a more basic and
   complete reference. For example, I want to understand what 'Helmert
   parametrization' (on page 33 of 'Statistical Models in S') is.
  
  
   Just google for: Helmert contrasts
  
   Or,
  
   contr.helmert(5)
    [,1] [,2] [,3] [,4]
   1   -1   -1   -1   -1
   2    1   -1   -1   -1
   3    0    2   -1   -1
   4    0    0    3   -1
   5    0    0    0    4
  
   MASS::fractions(MASS::ginv(contr.helmert(5)))
       [,1]  [,2]  [,3]  [,4]  [,5]
   [1,]  -1/2   1/2     0     0     0
   [2,]  -1/6  -1/6   1/3     0     0
   [3,] -1/12 -1/12 -1/12   1/4     0
   [4,] -1/20 -1/20 -1/20 -1/20   1/5
  
   and apply brains.
  
   I.e., except for a slightly odd multiplier, the parameters represent
the
    difference between each level and the average of the preceding
levels.
 
  I realized that my questions are what a contrast matrix is and how it
  is related to hypothesis testing. For a give hypothesis, how to get
  the corresponding contrast matrix in a systematical way? There are
  some online materials, but they are all diffused. I have also read the
  book Applied Linear Regression Models, which doesn't give a complete
  descriptions on all the aspects of contrast and contrast matrix. But I
  would want a textbook that gives a complete description, so that I
  don't have to look around for other materials.
 
  __
  R-help@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