Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uf_designmat surpressing intercept still returns only n-1 predictors #69

Open
behinger opened this issue May 18, 2019 · 1 comment
Open
Labels

Comments

@behinger
Copy link
Member

When running uf_designmat(...'formula','y~-1+cat(test)'), (with test having n levels the internal matlab function does not return n levels as I expected, but n-1 (identical to the '1+cat(test)' case.

Thanks to Pau Blanco from UPF for reporting this!

@behinger behinger added the bug label May 18, 2019
@behinger
Copy link
Member Author

Hey!
thanks for the file. I replicated the problem but have to think on a general solution.

If you don't surpress the intercept, everything works as intended, as a n-level factor will be represented by n-1 predictors + the intercept. Which what you have.

There is indeed a bug when surpressing the intercept, then the matlab backend also returns n-1 predictors, which, frankly, doesn't make much sense to me :/ I have to read into it, I opened an issue on #69 and will fix it as soon as I have time.

For now you can "hack" it as follows:

change line 120 of uf_designmat from

'codingschema','string',{'effects','reference'},'reference';

to

'codingschema','string',{'effects','reference','full'},'reference';

and add to your uf_designmat(...,'codingschema','full')

This should prevent matlab from removing the event with -1 and you should get your expected result. But beware, if you run it with full and you include an intercept, your betas will be overcomplete and not unique (you will also see a warning)! You then cannot interpret the results, except by taking so called estimable functions (differences) - ok but that might be too much detail, just be careful ;)

Best, Bene

behinger added a commit that referenced this issue May 20, 2019
…l' option as a preliminary workaround for #69. Need to think more on how to combine full with no intercept, maybe that should automatically be used?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant