Error in nlmefit function vectorizeSinglePhiGroupX
1 view (last 30 days)
Show older comments
Hi, I am trying to use nlmefit to do a linear random effects model of some data using the following command:
beta = nlmefit(a,b,grp,[],@(PHI,X)(X*PHI),[1 0]);
where
a=[0 1 2 0 1 2 0 1 0 1]'; b=[6.4512 5.9866 4.8052 7.0858 6.2563 5.5702 7.0976 7.7617 5.8512 7.1175]'; grp=['ABC' 'ABC' 'ABC' 'ADW' 'ADW' 'ADW' 'AEC' 'AEC' 'AEL' 'AEL'];
a,b, and grp have been shortened for brevity, they are actually 118x1 vectors.
I get the following error that I do not understand:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in nlmefit>getFcns/vectorizeSinglePhiGroupX (line 1367)
fval(k) = model(phi(i,:),X(k,:),V(i,:));
Error in nlmefit>getFcns/computeFAllAndCount (line 1450)
f = modelVectorizedAllGroups(phi, X, VVectorized);
Error in nlmefit>@(Beta,b)computeFAllAndCount(phiAllGroupsFcn(Beta,b)) (line 1459)
computeFAllGroupsFcn = @(Beta,b) computeFAllAndCount(phiAllGroupsFcn(Beta,b));
Error in nlmefit>@(Beta)computeFAllGroupsFcn(Beta,bDummy) (line 478)
model = @(Beta) computeFAllGroupsFcn(Beta, bDummy);
Error in nlmefit>LMfit (line 1752)
yfit = model(beta);
Error in nlmefit (line 481)
Beta_hat = LMfit(Y,Beta_hat,LMfitOptions,model,jacobian);
Thanks in advance for any clues!
Erin
0 Comments
Accepted Answer
the cyclist
on 6 Jul 2013
The proximate cause of your error is that your function specification
@(PHI,X)(X*PHI)
has only one parameter, PHI, but you have specified a vector with two initial values, [1 0].
The following syntax will execute
beta = nlmefit(a,b,grp,[],@(PHI,X)(X*PHI),[1]);
although I don't know if that is really the function you are trying to solve.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!