On Jan 25, 2012, at 5:24 PM, Rampagegrl wrote:

I got the code for how to do regression without an intercept out of the back
of my book and the next part of the homework asks me to do it with an
intercept. The problem is, Q1 disappears whenever I try. Here is my code:

Without the intercept:

load("tsa3.rda")

Q=factor(rep(1:4,21))
reg=lm(log(jj)~0+trend+Q,na.action=NULL)
model.matrix(reg)
   trend Q1 Q2 Q3 Q4
1  -10.00  1  0  0  0
2   -9.75  0  1  0  0
3   -9.50  0  0  1  0
4   -9.25  0  0  0  1
5   -9.00  1  0  0  0
...

now, I'm supposed to add an intercept to the regression model. I've hit a
bit of a problem.

reg=lm(log(jj)~trend+Q,na.action=NULL)
model.matrix(reg)
  (Intercept)  trend Q2 Q3 Q4
1            1 -10.00  0  0  0
2            1  -9.75  1  0  0
3            1  -9.50  0  1  0
4            1  -9.25  0  0  1
5            1  -9.00  0  0  0

Can you help me get Q1 back?  thanks.

No. You need to figure out why your instructor assigned you this Zen- like task and why the answer is as I stated. And this is not a homework help line.

--

David Winsemius, MD
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.

Reply via email to