Error in nlmefit function vectorizeSinglePhiGroupX
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
the cyclist
2013-7-6
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General PDEs 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!