Advanced Econometrics MATLAB Session
1 Introduction
• MATLAB is a powerful computer programming language. It provides a data
analysis environment based on a Matrix Programming Language which is ideal
for mathematical and statistical applications. Softwares with similar purposes
include GAUSS, Splus, R and Ox.
• MATLAB can run in the edit mode (or interactive mode), ie, executing one com-
mand at a time, interactively. It also runs in the command mode (orbatchmode),
ie, running a long MATLAB program with a series of MATLAB commands.
• The MATLAB editor is a very is flexible and power.
• A MATLAB program consists of statements and commands. If a statement ends
with a semicolon (;) nothing is printed to the screen. If a statement ends
without
a semicolon (;) the value of the variable denoted will be printed to the screen.
Here is a small example you can type in interactive mode
x=3;
x=3
z=7;
y=x+z;
a=[1 2 3]
a=[1; 2; 3]
• Routines (programs) in MATLAB end with the statement: return;
• Comments start with the sign %.
• Here is a small program that you can save in a file and execute.
2 Matrix Operations
• Summation and substraction of matrices can be done when the two matrices are
of the same dimensions. The commands are
a=[1 2 3; 4 5 6];
b=[11 12 13;14 15 16];
c=a+b;
d=a-b;
• In linear algebra , matrix multiplications and matrix divisions should be done
with care. The commands are
a=[1 2 3; 4 5 6]; % a has 2 rows and 3 columns. Row 1 contains 1
b=[2 1 0;1 3 1;0 1 4];
c=a*b; % c will be a 2× 3 matrix}
• If X is a T×K matrix, then the element in the i-th row and j-th column is :
X(i,j).
Scalars don’t need indexes. Vectors need only one index.
• X(:, 1:2) refers to all rows, columns 1 through 2 of matrix X.
• One important feature of MATLAB is element-by-element operations are allowed .
a=[1 2 3];
b=[2 3 4];
d=a+b; % a is added to the first row and the second row of b
e=a-b; % c is added to the three columns of b respectively
f=a.*b; % Element by element multiplication
g=a./b; % Element by element division
h=a. ^2 % Each element is squared
• Inverse a matrix: x=y’;
• Inverse a matrix: x=inv(y);
3 MATLAB Commands
• a=zeros(3,5); % a 3×5 matrix of zeros
• b=ones(2,4); % a 2×4 matrix of ones
• c=eye(4); % a 4×4 identity matrix
• d=i:k:j; % generating a sequence starting from i, advancing by k, stoping at j
• a=sum(x); % summation
• a=mean(x); % mean
• a=prod(x); % product
• a=median(x); % median
• a=sdt(x); % standard deviation
• a=max(x); % maximum
• a=min(x); % minimum
• a=exp(x); % exponential function
• a=log(x); % nature log function
• a=sqrt(x); % square root
• a=pi; % 3.1415926...
• a=gamma(x); % gamma function
• a=sin(x), cos(x), tan(x), arcsin(x); % trigonometric functions
• a=size(x); % dimension of matrix x
• a=length(x); % the size of the longest dimension of x
• a=det(x); % determinant of matrix x
• a=diag(x); % extracting the diagonal elements of matrix x
• y =filter(b,a,X); % This command is very useful in time series analysis and
implements
the following
• rand(’seed’,sd); % set the seed of random number generator to sd
• randn(’seed’,sd); % set the seed of random normal generator to sd
• normpdf(x) % computes the density of a standard normal distribution
• R = normrnd(MU,SIGMA,m,n) % generates normal random numbers with pa-
rameters MU and SIGMA, where scalars m and n are the row and column di-
mensions of R
Start solving your Algebra Problems
in next 5 minutes!
|
|
|
|
Algebra Helper
Download (and optional CD)
Only $39.99
|
Click to Buy Now:
OR
|
|
|
|
|
|
2Checkout.com is an authorized reseller
of goods provided by Sofmath
|
|
Attention: We are
currently running a special promotional offer
for Algebra-Answer.com visitors -- if you order
Algebra Helper by midnight of
November 21st
you will pay only $39.99
instead of our regular price of $74.99 -- this is $35 in
savings ! In order to take advantage of this
offer, you need to order by clicking on one of
the buttons on the left, not through our regular
order page.
If you order now you will also receive 30 minute live session from tutor.com for a 1$!
|
You Will Learn Algebra Better - Guaranteed!
Just take a look how incredibly simple Algebra Helper is:
Step 1
: Enter your homework problem in an easy WYSIWYG (What you see is what you get) algebra editor:
Step 2 :
Let Algebra Helper solve it:
Step 3 : Ask for an explanation for the steps you don't understand:
Algebra Helper can solve problems in all the following areas:
- simplification of algebraic expressions (operations
with polynomials (simplifying, degree, synthetic division...), exponential expressions, fractions and roots
(radicals), absolute values)
- factoring and expanding expressions
- finding LCM and GCF
-
(simplifying, rationalizing complex denominators...)
- solving linear, quadratic and many other equations
and inequalities
(including basic logarithmic and exponential equations)
- solving a system of two and three linear equations
(including Cramer's rule)
- graphing curves (lines, parabolas, hyperbolas, circles,
ellipses, equation and inequality solutions)
- graphing general functions
- operations with functions (composition, inverse, range, domain...)
- simplifying logarithms
- basic geometry and trigonometry
(similarity, calculating trig functions, right triangle...)
- arithmetic and other pre-algebra topics
(ratios, proportions, measurements...)
ORDER NOW!
|
|
|
|
Algebra Helper
Download (and optional CD)
Only $39.99
|
Click to Buy Now:
OR
|
|
|
|
|
|
2Checkout.com is an authorized reseller
of goods provided by Sofmath
|
|
|
|
|
"It
really helped me with my homework. I was
stuck on some problems and your software walked me
step by step through the process..." |
C. Sievert, KY
| |
|
|
|
Sofmath
19179 Blanco #105-234 San Antonio, TX 78258
|
Phone:
(512) 788-5675 Fax: (512) 519-1805
| | |