Intro Matlab Statistics
-
Upload
ruben-martinez-calderon -
Category
Documents
-
view
277 -
download
1
Transcript of Intro Matlab Statistics
![Page 1: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/1.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Introduction to MATLAB
Violeta Ivanova, Ph.D.Office for Educational Innovation & Technology
[email protected]://web.mit.edu/violeta/www
![Page 2: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/2.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Topics
MATLAB Interface and Basics Calculus, Linear Algebra, ODEs Graphics and Visualization Basic Programming Programming Practice Statistics and Data Analysis
![Page 3: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/3.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Resources
Class materialshttp://web.mit.edu/acmath/matlab/IAP2007 Previous sessions: InterfaceBasics, Graphics This session: Statistics <.zip, .tar>
Mathematical Tools at MIThttp://web.mit.edu/ist/topics/math
![Page 4: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/4.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
MATLAB Help Browser MATLAB
+ Data Analysis+ Preparing Data for Analysis+ Data Fitting Using Linear Regression
Curve Fitting Toolbox+ Fitting Data
Statistics Toolbox+ Descriptive Statistics+ Linear Models+ Hypothesis Tests+ Statistical Plots
![Page 5: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/5.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
MATLAB Data Analysis
Preparing DataCorrelationBasic Fitting
![Page 6: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/6.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Data Input / Output
Import Wizard for data importFile->Import Data …
File input with loadB = load(‘datain.txt’)
File output with savesave(‘dataout’, ‘A’, ‘-ascii’)
![Page 7: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/7.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Missing Data
Removing missing data Removing NaN elements from vectors>> x = x(~isnan(x)) Removing rows with NaN from matrices >> X(any(isnan(X),2),:) = []
Interpolating missing dataYI = interp1(X, Y, XI, ‘method’)Methods: ‘spline’, ‘nearest’, ‘linear’, …
![Page 8: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/8.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Correlation
DefinitionTendency of two variables to increase ordecrease together.
MeasurePearson product-moment coefficient
!X ,Y
=cov X,Y( )"
X"
Y
![Page 9: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/9.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Correlation Example Import Data: cancersmoking.dat Correlation coefficient & confidence interval
>> [R, P] = corrcoef(X);>> [i, j] = find(P < 0.05);
![Page 10: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/10.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Data Statistics Figure Editor: smokecancer.fig
Tools->
Data Statistics
![Page 11: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/11.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Basic Fitting Figure Editor : Tools->Basic Fitting …
![Page 12: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/12.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Statistics Toolbox
Probability DistributionsDescriptive StatisticsLinear & Nonlinear ModelsHypothesis TestsStatistical Plots
![Page 13: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/13.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Descriptive Statistics
Central tendency>> m = mean(X)>> gm = geomean(X)>> med = median(X)>> mod = mode(X)
Dispersion>> s = std(X)>> v = var(X)
![Page 14: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/14.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Probability Distributions
Probability density functions>> Y = exppdf(X, mu)>> Y = normpdf(X, mu, sigma)
Cumulative density functions>> Y = expcdf(X, mu)>> Y = normcdf(X, mu, sigma)
Parameter estimation>> m = expfit(data)>> [m, s] = normfit(data)
![Page 15: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/15.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Statistical Plots >> bp = boxplot(X, group)
![Page 16: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/16.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Polynomial Fitting Tool>> polytool(X, Y)
![Page 17: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/17.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Distribution Fitting Tool>> dfittool
![Page 18: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/18.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Linear Models
Definition:
y: n x 1 vector of observationsX: n x p matrix of predictorsβ: p x 1 vector of parametersε: n x 1 vector of random disturbances
y = X! + "
![Page 19: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/19.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Linear Regression
Multiple linear regression>> [B, Bint, R, Rint, stats] = regress(y, X)
B: vector of regression coefficientsBint: matrix of 95% confidence intervals for BR: vector of residualsRint: intervals for diagnosing outlinersstats: vector containing R2 statistic etc.
Residuals plot>> rcoplot(R, Rint)
![Page 20: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/20.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Hypothesis Testing
Definition: use of statistics to determine theprobability that a given hypothesis is true. Null hypothesis (observations are the result of
pure chance) and alternative hypothesis.
Test statistic to assess truth of null hypothesis.
P-value: probability of test statistic to be thatsignificant if null hypothesis were true.
Comparison of P-value to acceptable α-value.
![Page 21: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/21.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Analysis of Variance (ANOVA)
One-way ANOVA>> anova1(X,group)
![Page 22: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/22.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Multiple Comparisons
>> [p, tbl, stats]= anova1(X,group)>> [c, m] =multcompare(stats)
![Page 23: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/23.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
More Built-In Functions
Two-way ANOVA>> [P, tbl, stats] = anova2(X, reps)
Other hypothesis tests>> H = ttest(X)>> H = lillietest(X)
![Page 24: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/24.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Data Analysis Exercises Exercise One: dataanalysis.m,
rfid.dat, barcode.dat
Correlation coefficient Hypothesis testing Statistical plots ANOVA
Follow instructions in the m-file …
![Page 25: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/25.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Curve Fitting Toolbox
Curve Fitting ToolGoodness of FitAnalyzing a FitFourier Series Fit
![Page 26: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/26.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Curve Fitting Tool>> cftool
![Page 27: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/27.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Goodness of Fit Statistics
![Page 28: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/28.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Analyzing a Fit
![Page 29: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/29.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Fourier Series Fit
![Page 30: Intro Matlab Statistics](https://reader033.fdocuments.in/reader033/viewer/2022042613/547838ebb4af9f90108b4bad/html5/thumbnails/30.jpg)
Introduction to MATLAB: Data Analysis and StatisticsIAP 2007
Data Analysis Exercises Exercise Two: regression.m,
worlddata.dat, star.txt
Linear regression Polynomial fitting Probability density function fitting Goodness of Fit
Follow instructions in the m-file …