demo can not run, for function lasso in matlab 2014a

1 view (last 30 days)
Hi Is there anyone who have tried the lasso in matlab 2014a? I have tried it in several PC, it doesn't work and report mistakes for either lasso or lassoglm However, it works in lower edition, e.g. matlab 2013 and matlab 2012b the demo code is from the help document like that
n = 1000; p = 250;
X = randn(n,p);
beta = randn(p,1); beta0 = randn;
Y = beta0 + X*beta + randn(n,1);
lambda = 0:.01:.5;
[B,S] = lasso(X,Y,'Lambda',lambda);
lassoPlot(B,S);
  1 Comment
N/A
N/A on 17 Jun 2015
Your code executes on 2014b. Posting the error you get might make it easier to find answers.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 17 Jun 2015
lasso() is part of the Statistics toolbox. It is possible that Stats toolbox is not installed or not licensed on some of your versions.
  2 Comments
Zhao
Zhao on 17 Jun 2015
Edited: Zhao on 17 Jun 2015
nope, I am using the campus licence and it contains the Stats toolbox and Optimization tool box. I checked the source code and find that in lasso.m , on line 626 and 872, it is
[X0,muX,sigmaX] = zscore(X,1); % line 626
[X0,~,~] = zscore(X,1); % line 872
However, the function zscour() should just have 1 argument, which is
function [x, mu, sigma] = zscore(x)
I delete the argument 1 and it can run now. I just want to know is there any other guys meet this problem in 2014a? Since there is no problems on other PCs which has matlab 2012b and 2013
Alan Weiss
Alan Weiss on 17 Jun 2015
Take a look at the code for zscore:
function [z,mu,sigma] = zscore(x,flag,dim)
So there is nothing wrong with calling zscore(X,1). Whatever the problem is, it is not because the script uses an unsupported syntax.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!