Standard Error and confidence interval

3 次查看(过去 30 天)
Hello,
I have a 16x31 matrix, DeltaAnglesAdj, and I calculated the Standard error, columnwise:
std_err_mean = std(DeltaAnglesAdj,[],1)/sqrt(size(DeltaAnglesAdj,1)); (1x31 vector)
Then I calculated the P95:
P95 = tinv(0.975, size(DeltaAnglesAdj,1)-1);
How can I calculate the Confidence interval?
when I applied the method found on previous questions on Mathworks, it gives me error:
mean_data = mean(DeltaAnglesAdj,1); (1x31 vector)
CI95 = mean_data + std_err_mean*[-1 1]*P95;
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of
columns in the first matrix matches the number of rows in the second matrix.
To perform elementwise multiplication, use '.*'.
The error persists also after following the instruction:
CI95 = mean_data + std_err_mean*.[-1 1]*.P95;
Error: Invalid use of operator.
How can I solve this?

回答(1 个)

Star Strider
Star Strider 2020-7-20
The actual problem is that the vectors you are working with are row vectors. To create ‘CI95’ as a (2x31) matrix, you need to code it a bit differently.
Try this:
CI95 = mean_data + std_err_mean.*[-1; 1]*P95;
Then, to plot the mean and confidence intervals:
figure
plot((1:31), mean_data, (1:31), CI95)
.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by