<div dir="ltr">Thanks very much, Alexandre &amp; Alik! <br><div>It does work with only three dummy variables. </div><div><br></div><div>Best,</div><div>Emma</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 2, 2016 at 4:48 PM, Alik Widge <span dir="ltr">&lt;<a href="mailto:alik.widge@gmail.com" target="_blank">alik.widge@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Indeed, this has a trivial solution: drop the column corresponding to your &quot;base&quot; condition, which will then load on the intercept. </p><div class="HOEnZb"><div class="h5">
<div class="gmail_extra"><br><div class="gmail_quote">On Dec 2, 2016 5:49 AM, &quot;Alexandre Gramfort&quot; &lt;<a href="mailto:alexandre.gramfort@telecom-paristech.fr" target="_blank">alexandre.gramfort@telecom-<wbr>paristech.fr</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi Emma,<div><br></div><div>yes in your case the intercept column is the sum of the dummy variables</div><div>so your design matrix is ill-posed.</div><div><br></div><div>it&#39;s a standard GLM problem. Cf. articles and textbooks</div><div><br></div><div>Maybe someone has a good suggestion for you.</div><div><br></div><div>Alex</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 2, 2016 at 11:03 AM, Emma Chen <span dir="ltr">&lt;<a href="mailto:emma.chen.w@nyu.edu" target="_blank">emma.chen.w@nyu.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Mne users,</div><div><br></div><div>Is there a way to use mne.stats.linear_regressio<wbr>n on epoch data or stc data  with <b>binary/categorical</b> predictors?  </div><div><br></div><div>In the MEG data I&#39;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. </div><div><br></div><div>I&#39;ve tried to create the design_matrix with a column of intercept + 4 column of dummy variables for each category. But it didn&#39;t work. Following is the error messages I got: </div><div><br></div><div><p class="m_9082455831119980090m_-1178134807832182735m_1877582792304663359gmail-p1">------------------------------<wbr>------------------------------<wbr>---------------</p><p class="m_9082455831119980090m_-1178134807832182735m_1877582792304663359gmail-p1">LinAlgError                               Traceback (most recent call last)<br></p>&lt;ipython-input-49-728b72ea06ce<wbr>&gt; in &lt;module&gt;()<br>----&gt; 1 res=mne.stats.linear_regressio<wbr>n(epochs_ALL, design_matrix, names)<br>/Users/wc47/anaconda/envs/mne-<wbr>python/lib/python2.7/site-pack<wbr>ages/mne/stats/regression.pyc in linear_regression(inst, design_matrix, names)<br>     85     <a href="http://logger.info" target="_blank">logger.info</a>(msg + &#39;, (%s targets, %s regressors)&#39; %<br>     86                 (np.product(data.shape[1:]), len(names)))<br>---&gt; 87     lm_params = _fit_lm(data, design_matrix, names)<br>     88     lm = namedtuple(&#39;lm&#39;, &#39;beta stderr t_val p_val mlog10_p_val&#39;)<br>     89     lm_fits = {}<br><br>/Users/wc47/anaconda/envs/mne-<wbr>python/lib/python2.7/site-pack<wbr>ages/mne/stats/regression.pyc in _fit_lm(data, design_matrix, names)<br>    125     df = n_rows - n_predictors<br>    126     sqrt_noise_var = np.sqrt(resid_sum_squares / df).reshape(data.shape[1:])<br>--&gt; 127     design_invcov = linalg.inv(np.dot(design_matri<wbr>x.T, design_matrix))<br>    128     unscaled_stderrs = np.sqrt(np.diag(design_invcov)<wbr>)<br>    129     tiny = np.finfo(np.float64).tiny<br><br>/Users/wc47/anaconda/envs/mne-<wbr>python/lib/python2.7/site-pack<wbr>ages/scipy/linalg/basic.pyc in inv(a, overwrite_a, check_finite)<br>    685         inv_a, info = getri(lu, piv, lwork=lwork, overwrite_lu=1)<br>    686     if info &gt; 0:<br>--&gt; 687         raise LinAlgError(&quot;singular matrix&quot;)<br>    688     if info &lt; 0:<br>    689         raise ValueError(&#39;illegal value in %d-th argument of internal &#39;<br><br>LinAlgError: singular matrix<br>------------------------------<wbr>------------------------------<wbr>---------------</div><div><span class="m_9082455831119980090m_-1178134807832182735m_1877582792304663359gmail-s1"><br></span></div><div>Thanks in advance!</div><div><br></div><div>Best,</div><div>Emma</div><div><br></div><div class="m_9082455831119980090m_-1178134807832182735m_1877582792304663359gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span lang="EN-US" style="font-size:small">------<br></span><span style="font-size:small">Emma(Wei) Chen, Ph.D.</span><br style="font-size:small"><span style="font-size:small">Objects and Knowledge </span><span style="font-size:small">Laboratory</span><br style="font-size:small"><span style="font-size:small">New York University Abu Dhabi</span><br style="font-size:small"><span style="font-size:small">PO Box 129188</span><br style="font-size:small"><span style="font-size:small">Abu Dhabi, United Arab Emirates</span><br></div></div></div></div></div></div>
</div>
<br>______________________________<wbr>_________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.e<wbr>du</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.e<wbr>du/mailman/listinfo/mne_analys<wbr>is</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/compli<wbr>anceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu" target="_blank">Mne_analysis@nmr.mgh.harvard.e<wbr>du</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.e<wbr>du/mailman/listinfo/mne_analys<wbr>is</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/compli<wbr>anceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div></div>
</div></div><br>______________________________<wbr>_________________<br>
Mne_analysis mailing list<br>
<a href="mailto:Mne_analysis@nmr.mgh.harvard.edu">Mne_analysis@nmr.mgh.harvard.<wbr>edu</a><br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis" rel="noreferrer" target="_blank">https://mail.nmr.mgh.harvard.<wbr>edu/mailman/listinfo/mne_<wbr>analysis</a><br>
<br>
<br>
The information in this e-mail is intended only for the person to whom it is<br>
addressed. If you believe this e-mail was sent to you in error and the e-mail<br>
contains patient information, please contact the Partners Compliance HelpLine at<br>
<a href="http://www.partners.org/complianceline" rel="noreferrer" target="_blank">http://www.partners.org/<wbr>complianceline</a> . If the e-mail was sent to you in error<br>
but does not contain patient information, please contact the sender and properly<br>
dispose of the e-mail.<br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span lang="EN-US" style="font-size:small">------<br></span><span style="font-size:small">Emma(Wei) Chen, Ph.D.</span><br style="font-size:small"><span style="font-size:small">Objects and Knowledge </span><span style="font-size:small">Laboratory</span><br style="font-size:small"><span style="font-size:small">New York University Abu Dhabi</span><br style="font-size:small"><span style="font-size:small">PO Box 129188</span><br style="font-size:small"><span style="font-size:small">Abu Dhabi, United Arab Emirates</span><br></div></div></div></div></div></div>
</div>