Typo
yhat = X(:,[1 2 3])*beta([1 2 3],:)

On 5/21/2020 2:12 PM, Hua, Jessica wrote:

        External Email - Use Caution

I apologize for resending all of this info, but my email is acting up and every time I try to respond to the other email, my Outlook freezes.

Here is info from our thread. I modified it to include the analysis in which I found significant clusters (i.e., looking at thickness with only age and sex as covariates and not ICV):

After running the permutation and finding significant clusters, I am trying to calculate the value for each participant for these significant clusters.

The perm.th30.abs.y.ocn.dat contain the raw values, and I am trying to get the adjusted values accounting for age and sex (this is a three group design).

The X matrix was 240x12 (see attached file)

  * Column 1: 1s for Group 1 and 0s for Group 2 and 0s for Group 3
  * Column 2: 0s for Group 1 and 1s for Group 2 and 0s for Group 3
  * Column 3: 0s for Group 1 and 0s for Group 2 and 1s for Group 3
  * Column 4: Age for Group 1 and 0s for Group 2 and 0s for Group 3
  * Column 5: 0s for Group 1 and Age for Group 2 and 0s for Group 3
  * Column 6: 0s for Group 1 and 0s for Group 2 and Age for Group 3
  * Column 7: Sex for Group 1 and 0s for Group 2 and 0s for Group 3
  * Column 8: 0s for Group 1 and Sex for Group 2 and 0s for Group 3
* Column 9: 0s for Group 1 and 0s for Group 2 and Sex for Group 3 Your code:
There is not an easy way to do it, but you can do it in matlab
cd glmdir
X = load('Xg.dat');
y = load('perm.th30.abs.y.ocn.dat');
beta = inv(X'*X)*X'*y;
yhat = X(:,[1 2 3]*beta([1 2 3])

When running your code, below are the errors I got in Matlab. Do you know how I can fix the code?

>> X = load('Xg.dat');
>> y = load('perm.th30.abs.y.ocn.dat');
>> y = load('perm.th30.abs.y.ocn.dat');
>> beta = inv(X'*X)*X'*y;
>> yhat = X(:,[1 2 3]*beta([1 2 3])
 yhat = X(:,[1 2 3]*beta([1 2 3])
                                 ↑
Error: Invalid expression. When calling a function
or indexing a variable, use parentheses. Otherwise,
check for mismatched delimiters.

Did you mean:
>> yhat = X(:,[1 2 3]*beta([1 2 3]))
Error using  *
Incorrect dimensions for matrix multiplication.
Check that the number of columns in the first matrix
matches the number of rows in the second matrix. To
perform elementwise multiplication, use '.*'.

>> yhat = X(:,[1 2 3].*beta([1 2 3]))
Index in position 2 is invalid. Array indices must
be positive integers or logical values.

---

Jessica Hua, M.A.
Cognitive and Emotional Control Lab
Doctoral Candidate Clinical Psychology
University of Missouri

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

Reply via email to