[Mne_analysis] mne.stats.linear_regression
Emma Chen
emma.chen.w at nyu.edu
Fri Dec 2 08:18:56 EST 2016
Thanks very much, Alexandre & Alik!
It does work with only three dummy variables.
Best,
Emma
On Fri, Dec 2, 2016 at 4:48 PM, Alik Widge <alik.widge at gmail.com> wrote:
> Indeed, this has a trivial solution: drop the column corresponding to your
> "base" condition, which will then load on the intercept.
>
> On Dec 2, 2016 5:49 AM, "Alexandre Gramfort" <alexandre.gramfort at telecom-
> paristech.fr> wrote:
>
>> hi Emma,
>>
>> yes in your case the intercept column is the sum of the dummy variables
>> so your design matrix is ill-posed.
>>
>> it's a standard GLM problem. Cf. articles and textbooks
>>
>> Maybe someone has a good suggestion for you.
>>
>> Alex
>>
>>
>> On Fri, Dec 2, 2016 at 11:03 AM, Emma Chen <emma.chen.w at nyu.edu> wrote:
>>
>>> Hi Mne users,
>>>
>>> Is there a way to use mne.stats.linear_regression on epoch data or stc
>>> data with *binary/categorical* predictors?
>>>
>>> In the MEG data I'm analyzing, the regressor I would like to use is a
>>> categorical variable with 4 different categories of objects indicating
>>> which type of object participants saw in each trial.
>>>
>>> I've tried to create the design_matrix with a column of intercept + 4
>>> column of dummy variables for each category. But it didn't work. Following
>>> is the error messages I got:
>>>
>>> ------------------------------------------------------------
>>> ---------------
>>>
>>> LinAlgError Traceback (most recent call
>>> last)
>>> <ipython-input-49-728b72ea06ce> in <module>()
>>> ----> 1 res=mne.stats.linear_regression(epochs_ALL, design_matrix,
>>> names)
>>> /Users/wc47/anaconda/envs/mne-python/lib/python2.7/site-packages/mne/stats/regression.pyc
>>> in linear_regression(inst, design_matrix, names)
>>> 85 logger.info(msg + ', (%s targets, %s regressors)' %
>>> 86 (np.product(data.shape[1:]), len(names)))
>>> ---> 87 lm_params = _fit_lm(data, design_matrix, names)
>>> 88 lm = namedtuple('lm', 'beta stderr t_val p_val mlog10_p_val')
>>> 89 lm_fits = {}
>>>
>>> /Users/wc47/anaconda/envs/mne-python/lib/python2.7/site-packages/mne/stats/regression.pyc
>>> in _fit_lm(data, design_matrix, names)
>>> 125 df = n_rows - n_predictors
>>> 126 sqrt_noise_var = np.sqrt(resid_sum_squares /
>>> df).reshape(data.shape[1:])
>>> --> 127 design_invcov = linalg.inv(np.dot(design_matrix.T,
>>> design_matrix))
>>> 128 unscaled_stderrs = np.sqrt(np.diag(design_invcov))
>>> 129 tiny = np.finfo(np.float64).tiny
>>>
>>> /Users/wc47/anaconda/envs/mne-python/lib/python2.7/site-packages/scipy/linalg/basic.pyc
>>> in inv(a, overwrite_a, check_finite)
>>> 685 inv_a, info = getri(lu, piv, lwork=lwork, overwrite_lu=1)
>>> 686 if info > 0:
>>> --> 687 raise LinAlgError("singular matrix")
>>> 688 if info < 0:
>>> 689 raise ValueError('illegal value in %d-th argument of
>>> internal '
>>>
>>> LinAlgError: singular matrix
>>> ------------------------------------------------------------
>>> ---------------
>>>
>>> Thanks in advance!
>>>
>>> Best,
>>> Emma
>>>
>>> ------
>>> Emma(Wei) Chen, Ph.D.
>>> Objects and Knowledge Laboratory
>>> New York University Abu Dhabi
>>> PO Box 129188
>>> Abu Dhabi, United Arab Emirates
>>>
>>> _______________________________________________
>>> Mne_analysis mailing list
>>> Mne_analysis at nmr.mgh.harvard.edu
>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>>
>>>
>>> The information in this e-mail is intended only for the person to whom
>>> it is
>>> addressed. If you believe this e-mail was sent to you in error and the
>>> e-mail
>>> contains patient information, please contact the Partners Compliance
>>> HelpLine at
>>> http://www.partners.org/complianceline . If the e-mail was sent to you
>>> in error
>>> but does not contain patient information, please contact the sender and
>>> properly
>>> dispose of the e-mail.
>>>
>>>
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>
>>
>> The information in this e-mail is intended only for the person to whom it
>> is
>> addressed. If you believe this e-mail was sent to you in error and the
>> e-mail
>> contains patient information, please contact the Partners Compliance
>> HelpLine at
>> http://www.partners.org/complianceline . If the e-mail was sent to you
>> in error
>> but does not contain patient information, please contact the sender and
>> properly
>> dispose of the e-mail.
>>
>>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>
--
------
Emma(Wei) Chen, Ph.D.
Objects and Knowledge Laboratory
New York University Abu Dhabi
PO Box 129188
Abu Dhabi, United Arab Emirates
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20161202/837ef5cd/attachment-0001.html
More information about the Mne_analysis
mailing list