From: Robert Smith asdf on
i have x-y data as such (i hope that the pic works): http://img175.imageshack.us/i/77916937.jpg/
where there are multiple y values for every x. how do i calculate an average value for each x and how do i make the 90% confidence interval and plot them?

any suggestions?
From: us on
"Robert Smith asdf" <bainit83remove(a)thisyahoo.com> wrote in message <hpkqf2$k9u$1(a)fred.mathworks.com>...
> i have x-y data as such (i hope that the pic works): http://img175.imageshack.us/i/77916937.jpg/
> where there are multiple y values for every x. how do i calculate an average value for each x and how do i make the 90% confidence interval and plot them?
>
> any suggestions?

a hint:
- assuming your X-vals are equal for all Y-vals...
- otherwise, use a consolidating algo...

help mean; % <- all vectorized...
help var; % <- + with appropriate scaling... or
help std;

us
From: Robert Smith asdf on
"Robert Smith asdf" <bainit83remove(a)thisyahoo.com> wrote in message <hpkqf2$k9u$1(a)fred.mathworks.com>...
> i have x-y data as such (i hope that the pic works): http://img175.imageshack.us/i/77916937.jpg/
> where there are multiple y values for every x. how do i calculate an average value for each x and how do i make the 90% confidence interval and plot them?
>
> any suggestions?
there are multiple y for each x (not the same number also).
From: Tom Lane on
>> i have x-y data as such (i hope that the pic works):
>> http://img175.imageshack.us/i/77916937.jpg/
>> where there are multiple y values for every x. how do i calculate an
>> average value for each x and how do i make the 90% confidence interval
>> and plot them?
>>
>> any suggestions?
> there are multiple y for each x (not the same number also).

Robert, in general the errorbar function is good for plotting averages error
limits. It requires that you calculate those averages and limits separately,
though.

The plot you pointed out looks a lot like x/y data where you could imagine
fitting y=f(x)+error and asking for error limits around that. But I think
you're asking how to compute averages of y values at the distinct x values.
So take a look at this code and see if you can figure out how to adapt it to
your situation (for example to specify the confidence level):

x = randi(20,120,1);
y = x + randn(size(x));
plot(x,y,'bx')
[m,ci,g] = grpstats(y,x,{'mean' 'meanci' 'gname'})
g = str2num(char(g));
line(g,m,'color','r')
line(g,ci,'color','r','linestyle',':')

-- Tom


From: Rob Campbell on
"Tom Lane" <tlane(a)mathworks.com> wrote in message <hpnocn$bcs$1(a)fred.mathworks.com>...
> >> i have x-y data as such (i hope that the pic works):
> >> http://img175.imageshack.us/i/77916937.jpg/
> >> where there are multiple y values for every x. how do i calculate an
> >> average value for each x and how do i make the 90% confidence interval
> >> and plot them?
> >>
>
I have a function on the FEX that may do what you want:
http://www.mathworks.com/matlabcentral/fileexchange/26311-shadederrorbar

You can feed it the raw data and can tell it where to draw the line and CI using function handles. To get the SEM you can feed in other one of my functions as a function handle.
http://www.mathworks.com/matlabcentral/fileexchange/26508-notboxplot-alternative-to-box-plots

To plot the mean and a 95% confidence interval for the mean you simply do:
shadedErrorBar(x,y,{@mean,@SEM_calc});

You can easily change the 95% to any other number (see help SEM_calc, SEM_calc is in the second link). You can also remove the shaded error region from the shaded plot if you don't like it: shaded error bar returns all the plot object handles, so apply delete to those you don't want. You can also (obviously) over-plot your raw data onto the shaded area.