[R] how to print the full name of the factors in summary?

Bert Gunter gunter.berton at gene.com
Mon Nov 2 19:40:11 CET 2009


Jack:

You are confused!

You have specified that the factor is ordered (ordered = TRUE), so you do
_not get_ the (6, not 7 btw)single degree of freedom contrasts corresponding
to weekday names. Instead you get the (default) contrasts for an ordered
factor (.L = linear, .Q = quadratic, etc.). Also you apparently do not have
all weekdays present or maybe there is partial confounding with some of your
other factors, thus producing the singularities given in the message.

While you can read up on such matters ("contrasts") in the docs and texts
about R (V&R's MASS has a nice explanation), these issues are inherently
technical. So if you do not have the requisite statistical background, I
suggest you consult a statistician.

To paraphrase an R fortune -- if you do not know how to properly use the
statistical tools, you shouldn't be using them.

Cheers,

Bert Gunter
Genentech Nonclinical Biostatistics
 
 -----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Jen-Chien Chang
Sent: Monday, November 02, 2009 7:02 AM
To: r-help at r-project.org
Subject: [R] how to print the full name of the factors in summary?

Hi,

I am wondering if there is a simple way to fix the problem I am having. 
For unknown reason, I could not get the full name of the factors to be 
printed in the summary. I have tried to used summary.lm as well but the 
problem still persists.

SJ$Weekday <- 
factor(SJ$Weekday,1:7,c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),ordered=T
)
....
attach(SJ)
lm.SJ <- lm(Demand ~ Weekday+Month+Holiday+Season)
summary(lm.SJ)
Call:
lm(formula = Demand ~ Weekday + Month + Holiday + Season)

Residuals:
     Min      1Q  Median      3Q     Max
-69.767 -12.224  -1.378  10.857  91.376

Coefficients: (3 not defined because of singularities)
             Estimate Std. Error t value Pr(>|t|)
(Intercept)  88.7091     3.3442  26.527  < 2e-16 ***
Weekday.L    20.8132     2.8140   7.396 1.08e-12 ***
Weekday.Q   -12.7667     2.8156  -4.534 7.99e-06 ***
Weekday.C   -10.6375     2.8113  -3.784 0.000182 ***
Weekday^4    -8.3325     2.8103  -2.965 0.003238 **
---------------------------------------------

Is there a way for summary to print the full name of the factors and 
levels? Say Weekday.Tue instead Weekday.L?

Thanks!

Jack Chang

______________________________________________
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.




More information about the R-help mailing list