Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
February 28, 2014
Lecture 4: Model fitting
1. The basics
- Suppose that we have a set of data and suppose that we have selected the type of model to
apply to the data (see Lecture
Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
April 11, 2014
Lecture 7: Classification
1. The basics
- We have so far been dealing with regression models. Now that we have covered the
fundamentals of model building, we are re
Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
March 21, 2014
Lecture 5: Model accuracy
1. The basics
- Suppose we have fit a model to a set of data. We would like to know how well the model
describes the data, that is, model
Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
March 28, 2014
Lecture 6: Model reliability
1. The basics
- Suppose we have fit a model to a set of data. In doing so, we have determined values for the
free parameters of the mod
MATLAB Examples 4 (covering Statistics Lecture 7)
Contents
Example 1: Simple 2D classification using logistic regression
Example 2: Compare solutions of different classifiers
Example 1: Simple 2D classification using logistic regression
% generate some da
Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
February 3, 2014
Lecture 2: Hypothesis testing and correlation
1. Exploring a more complex dataset: one variable, two conditions
- Suppose we measure a quantity not just for one c
Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
Lecture 1: Probability distributions and error bars
1. Exploring a simple dataset: one variable, one condition
- Let's start with the simplest possible dataset. Suppose we measure
MATLAB Examples 1 (covering Statistics Lectures 1 and 2)
Contents
Example 1: Simple data plotting
Example 2: Monte Carlo simulations of correlation values
Example 3: Use bootstrapping to obtain confidence intervals on a correlation
Example 4: Use randomiz
MATLAB Examples 3 (covering Statistics Lectures 5 and 6)
Contents
Example 1: Demonstration of various types of resampling
Example 2: Bootstrap a simple linear model
Example 3: Perform leave-one-out cross-validation for a simple linear model
Example 1: Dem
Solutions to Homework 4 (covering Statistics Lectures 5 and 6)
Contents
Problem 0
Problem 1
Problem 2
Problem 0
load('Homework4.mat');
Problem 1
% define some constants
numboots = 500;
% calculate some quantities (to make the code general)
n = length(data
Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
MATLAB Basics II
1. Figures and plotting
figure - create a figure window
hold on - hold figure so that new plot elements will add to (not replace) existing elements
plot - draw li
Statistics and Data Analysis in MATLAB
Kendrick Kay, kendrick.kay@wustl.edu
MATLAB Basics I
1. The MATLAB environment
- Variables hold things, such as numbers, matrices, strings, etc. Variable names are simple
alphanumeric strings (e.g. rec, ABC, or var12
Solutions to Homework 2 (covering Statistics Lectures 1 and 2)
Contents
Problem 0
Problem 1
Problem 2
Problem 3
Problem 4
Problem 0
load('Homework2.mat');
Problem 1
% define some stuff
sigma = 10; % standard deviation
mn = 50;
% mean
x = 0:100;
% x-values
Solutions to Homework 3 (covering Statistics Lectures 3 and 4)
Contents
Problem 0
Problem 1
Problem 2
Problem 3
Problem 4
Problem 0
load('Homework3.mat');
Problem 1
% construct regressor matrix
X = score1(:);
X(:,end+1) = 1; % need a constant regressor
%
Solutions to Homework 1: MATLAB Basics
Contents
Problem 0
Problem 1
Problem 2
Problem 3
Problem 4
Problem 5
Problem 0
load('Homework1.mat');
Problem 1
set1 = randn(1,1000);
set2 = randn(1,1000);
figure;
scatter(set1,set2,'r.');
xlabel('Condition A');
ylab
Solutions to Homework 5 (covering Statistics Lecture 7)
Contents
Problem 0
Problem 1
Problem 2
Problem 0
load('Homework5.mat');
Problem 1
% visualize the data
figure; hold on;
scatter(score1,pass1,'ko');
xlabel('Score');
ylabel('Passed?');
ax = axis;
axis