MATLAB Examples

```function regress_plot_twocategories(input_x,input_y,input_x1,input_y1,input_x2,input_y2,desc,x_label,y_label) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Name - regress_plot_twocategories % Creation Date - 18th Oct 2011 % Author: Soumya Banerjee % Website: www.cs.unm.edu/~soumya % % Acknowledgements: Dr. Melanie Moses % % Description: Takes six column vectors, a description, x label and y label and % plots the data and outputs all the statistics (r2, OLS slope, RMA slope, 95% CI % intervals) % Same syntax as plot(x,y) : x-axis data 1st followed by y-axis data % % input_x: combined column vector x % input_y: combined column vector y % input_x1: category 1 column vector x % input_y1: category 1 column vector y % input_x2: category 2 column vector x % input_y2: category 2 column vector y % desc: description of plot (goes in the title of the plot) % x_label: label for x-axis of plot % y_label: label for y-axis of plot % % Example usage: % regress_plot_twocategories([1 1 1 1 2 2 2 2 2]',[1 1.1 1.2 1.3 2.2 2.1 2.3 2 2.4]',... % [1 1 1 1]', [1 1.1 1.2 1.3]', [2 2 2 2 2]',[2.2 2.1 2.3 2 2.4]',... % 'analysis of all individuals mcmc burn-in thinning',... % 'log_1_0(M)','log_1_0(delta)') % % License - BSD % % Change History - % 18th Oct 2011 - Creation by Soumya Banerjee %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% msapop_ones = [ones(size(input_x)), input_x]; [b1 bint r rint stats] = regress(input_y,msapop_ones); display('RMA Slope') % RMA (reduced major axis) slope rmaslope = b1(2,1) / stats(1,1) ^ 0.5 display('bint') bint display('95% CI on intercept') bint(1,:) display('95% CI on slope') bint(2,:) display('r2') stats(1,1) display('OLS Slope') b1(2,1) olsslope = b1(2,1); display('p value') stats(1,3) display('b1') b1 figure plot(input_x1,input_y1,'ks','MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',10) xlabel(x_label,'fontsize',23); ylabel(y_label,'fontsize',23); title(strcat(strcat(strcat(strcat(desc,strcat(strcat(strcat(strcat('r^2 value = ',num2str(stats(1,1))), strcat('OLSslope = ',num2str(olsslope))), 'RMAslope = '),num2str(rmaslope)))),'p value = '),num2str(stats(1,3))),'fontsize',18); hold on plot(input_x2,input_y2,'ro','MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',10) % axis([-2 0.55 0.25 0.75]) % axis([1 11 1 17]) plot(input_x,olsslope .* input_x + b1(1,1),'-b'); hold on % plot([-2 -1 0 1 2 3],[5 5 5 5 5 5],'-r') % plot(plot_x,rmaslope * plot_x + 1,'-g'); plot(input_x,rmaslope * input_x + b1(1,1),'-g'); legend('Passerines','Nonpasserines','OLS slope','RMA slope','Location','NorthEast') hold off end ```
```Error using regress_plot_twocategories (line 38) Not enough input arguments. ```