Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MSG

  • Loading branch information...
commit 7b291938a2b11ffe1f6d36897c663004db9afc6e 1 parent 42a1d3a
Marcel van Gerven authored
6 +dml/crossvalidator.m
View
@@ -224,7 +224,11 @@
function y = create_test_folds(Y)
% use the same ordering for multiple datasets by reinitializing the random number generator
- RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));
+ try
+ RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));
+ catch
+ rand('twister',1); randn('twister',1);
+ end
y = cell(obj.folds,1);
7 +dml/enet.m
View
@@ -2,12 +2,17 @@
%ENET native implementation of elastic net algorithm.
%
% DESCRIPTION
-% Elastic net linear and logistic regression
+% Elastic net linear and logistic regression. Note that this algorithm
+% allows for the GraphNet generalization that allows coupling between
+% features.
%
% REFERENCE
% Regularization paths for generalized linear models via coordinate descent
% by Friedman et al.
%
+% Grosenick L, Klingenberg B, Knutson B. A family of interpretable
+% multivariate models for regression and classification of whole-brain fMRI data. stanford.edu.
+%
% EXAMPLE
% X = rand(10,20); Y = [1 1 1 1 1 2 2 2 2 2]';
% m = dml.enet
6 +dml/naive.m
View
@@ -79,7 +79,7 @@
obj.S(k,:) = obj.S(k,:) + nansum(X(Y == k,:),1);
% estimate class-conditional sum of squares
- mu = obj.S ./ obj.n;
+ mu = obj.S(k,:) ./ obj.n(k,:);
if binit
@@ -88,8 +88,8 @@
else
% use Eq 1.4 in UPDATING FORMULAE AND A PAIRWISE ALGORITHM FOR COMPUTING SAMPLE VARIANCES
% by Tony F. Chan Gene H. Golub Randall J. LeVeque
- obj.SS(k,:) = obj.SS(k,:) + nansum(bsxfun(@minus,X(Y==k,:),mu(k,:)).^2,1) - ...
- bsxfun(@rdivide,(nansum(bsxfun(@minus,X(Y==k,:),mu(k,:)),1).^2),obj.n(k,:));
+ obj.SS(k,:) = obj.SS(k,:) + nansum(bsxfun(@minus,X(Y==k,:),mu).^2,1) - ...
+ bsxfun(@rdivide,(nansum(bsxfun(@minus,X(Y==k,:),mu),1).^2),obj.n(k,:));
end
end
8 +dml/permutation.m
View
@@ -56,8 +56,12 @@
obj.outcome = zeros(1,obj.nperm+1);
for i=1:obj.nperm
- % ensure random permutation
- RandStream.setGlobalStream(RandStream('mt19937ar','seed',sum(100*clock)));
+ % ensure random permutation with backward compatibility
+ try
+ RandStream.setGlobalStream(RandStream('mt19937ar','seed',sum(100*clock)));
+ catch
+ rand('twister',sum(100*clock));
+ end
% create permuted data
if ndata == 1
7 +dml/statistic.m
View
@@ -23,6 +23,9 @@
% circular data with angles specified in radians
% using fisher's correlation coefficient.
% 'R2' : squared correlation; explained variance in the linear regression case
+% 'expvar' : explicit computation of explained variance:
+% (var(y) - var(y-yhat)) / var(y)
+% 1 = perfect prediction, <0 = worse than chance
% 'identity' : computes the proportion of trials that are identified correctly
%
% NOTE: notation '-x' with x one of the above is also allowed. This way
@@ -123,6 +126,10 @@
[a,b] = max(corr(P',D'));
s = mean(b==1:size(P,1));
+ case 'expvar'
+
+ s = (var(D) - var(D-P)) ./ var(D);
+
otherwise
error('unknown statistic %s',stat);
Please sign in to comment.
Something went wrong with that request. Please try again.