Solve the mixed-model equations

pull/2/head
parent f2615b1048
commit eb0ca76d19

@ -164,3 +164,20 @@ for i = 1:numanimals
continue
end
% Extract the observed data
Y = data{:, 5};
% The identity matrix for random effects
Z = speye(numanimals, numanimals);
% Prompt for heritablity
h2 = str2double(input('What is the heritablity for this trait? >> '));
lambda = (1-h2)/h2;
% Use the mixed-model equations
solutions = [X'*X X'*Z; Z'*X (Z'*Z)+(inv(A).*lambda)]\[X'*Y; Z'*Y];
% Find the accuracies
diaginv = diag(inv([X'*X X'*Z; Z'*X (Z'*Z)+(inv(A).*lambda)]));
reliability = 1 - diaginv.*lambda;
Loading…
Cancel
Save