Skip to content
This repository
Browse code

MSG

  • Loading branch information...
commit 7b291938a2b11ffe1f6d36897c663004db9afc6e 1 parent 42a1d3a
Marcel van Gerven authored
6 +dml/crossvalidator.m
@@ -224,7 +224,11 @@
224 224 function y = create_test_folds(Y)
225 225
226 226 % use the same ordering for multiple datasets by reinitializing the random number generator
227   - RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));
  227 + try
  228 + RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));
  229 + catch
  230 + rand('twister',1); randn('twister',1);
  231 + end
228 232
229 233 y = cell(obj.folds,1);
230 234
7 +dml/enet.m
@@ -2,12 +2,17 @@
2 2 %ENET native implementation of elastic net algorithm.
3 3 %
4 4 % DESCRIPTION
5   -% Elastic net linear and logistic regression
  5 +% Elastic net linear and logistic regression. Note that this algorithm
  6 +% allows for the GraphNet generalization that allows coupling between
  7 +% features.
6 8 %
7 9 % REFERENCE
8 10 % Regularization paths for generalized linear models via coordinate descent
9 11 % by Friedman et al.
10 12 %
  13 +% Grosenick L, Klingenberg B, Knutson B. A family of interpretable
  14 +% multivariate models for regression and classification of whole-brain fMRI data. stanford.edu.
  15 +%
11 16 % EXAMPLE
12 17 % X = rand(10,20); Y = [1 1 1 1 1 2 2 2 2 2]';
13 18 % m = dml.enet
6 +dml/naive.m
@@ -79,7 +79,7 @@
79 79 obj.S(k,:) = obj.S(k,:) + nansum(X(Y == k,:),1);
80 80
81 81 % estimate class-conditional sum of squares
82   - mu = obj.S ./ obj.n;
  82 + mu = obj.S(k,:) ./ obj.n(k,:);
83 83
84 84 if binit
85 85
@@ -88,8 +88,8 @@
88 88 else
89 89 % use Eq 1.4 in UPDATING FORMULAE AND A PAIRWISE ALGORITHM FOR COMPUTING SAMPLE VARIANCES
90 90 % by Tony F. Chan Gene H. Golub Randall J. LeVeque
91   - obj.SS(k,:) = obj.SS(k,:) + nansum(bsxfun(@minus,X(Y==k,:),mu(k,:)).^2,1) - ...
92   - bsxfun(@rdivide,(nansum(bsxfun(@minus,X(Y==k,:),mu(k,:)),1).^2),obj.n(k,:));
  91 + obj.SS(k,:) = obj.SS(k,:) + nansum(bsxfun(@minus,X(Y==k,:),mu).^2,1) - ...
  92 + bsxfun(@rdivide,(nansum(bsxfun(@minus,X(Y==k,:),mu),1).^2),obj.n(k,:));
93 93 end
94 94
95 95 end
8 +dml/permutation.m
@@ -56,8 +56,12 @@
56 56 obj.outcome = zeros(1,obj.nperm+1);
57 57 for i=1:obj.nperm
58 58
59   - % ensure random permutation
60   - RandStream.setGlobalStream(RandStream('mt19937ar','seed',sum(100*clock)));
  59 + % ensure random permutation with backward compatibility
  60 + try
  61 + RandStream.setGlobalStream(RandStream('mt19937ar','seed',sum(100*clock)));
  62 + catch
  63 + rand('twister',sum(100*clock));
  64 + end
61 65
62 66 % create permuted data
63 67 if ndata == 1
7 +dml/statistic.m
@@ -23,6 +23,9 @@
23 23 % circular data with angles specified in radians
24 24 % using fisher's correlation coefficient.
25 25 % 'R2' : squared correlation; explained variance in the linear regression case
  26 +% 'expvar' : explicit computation of explained variance:
  27 +% (var(y) - var(y-yhat)) / var(y)
  28 +% 1 = perfect prediction, <0 = worse than chance
26 29 % 'identity' : computes the proportion of trials that are identified correctly
27 30 %
28 31 % NOTE: notation '-x' with x one of the above is also allowed. This way
@@ -123,6 +126,10 @@
123 126 [a,b] = max(corr(P',D'));
124 127 s = mean(b==1:size(P,1));
125 128
  129 + case 'expvar'
  130 +
  131 + s = (var(D) - var(D-P)) ./ var(D);
  132 +
126 133 otherwise
127 134 error('unknown statistic %s',stat);
128 135

0 comments on commit 7b29193

Please sign in to comment.
Something went wrong with that request. Please try again.