0
$\begingroup$

I have a datatable (looking like this: https://i.sstatic.net/rdt09.jpg , where I'd like to see how different weekdays affect stock prices. However, when I create use them lm() function and summary, I get an 'error':

Coefficients: (1 not defined because of singularities) with th row showing only NA's

The formula I used is lm(formula = wd$ewretd ~ fr + mo + tu + we + th).

Is there any way to see all the days?

$\endgroup$
1
  • 2
    $\begingroup$ The problem here is statistical rather than programming, so is on-topic here. However I wonder if this is a duplicate of an existing question? $\endgroup$
    – Silverfish
    Commented Nov 21, 2017 at 13:39

1 Answer 1

1
$\begingroup$

Assuming that your dataset only contains weekdays Monday through Friday, your weekday dummies are collinear with the intercept. You can suppress the intercept using -1, that is, lm(formula = wd$ewretd ~ fr + mo + tu + we + th -1)

Alternatively, encode the day of week in a factor and then include this factor as an IV. Then R will take care of all dummy encoding automatically.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.