I want to use a function handle in grpstats which takes multiple columns of a dataset as inputs. The two columns are the lower and higher limits of a confidence interval. I wrote a function for a rough estimate of accumulated confidence intervals.
function [ci_new] = ci_estimate(ci_low_array, ci_high_array)ci_int = sqrt(sum((ci_low_array - ci_high_array).^2));ci_mean = mean(mean([ci_low_array, ci_high_array], 2));ci_new_low = ci_mean - ci_int;ci_new_high = ci_mean + ci_int;ci_new = [ci_new_low, ci_new_high];end
I'm calling the function within grpstats as follows:
ds_o = grpstats( ds_o, {'observer' }, @ci_estimate, 'DataVar', { 'ci_low', 'ci_high' } );
Have tried multiple variations of the above code, including creating a new variable 'ci' which is essentially a matrix containing both low and high values, none of which are working. In the documentation of grpstats, it says that it's possible to write a function that takes a matrix as input instead of a column of dataset, but there's no example, and I can't seem to figure out the current syntax..
Best Answer