SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

MATRIX FIT

Name:
    MATRIX FIT (LET)
Type:
    Let Subcommand
Purpose:
    Compute linear least squares fits for each column (or row) of a matrix with an independent variable.
Description:
    This command will perform a linear least squares fit of each column (or row) of a matrix with the same independent variable. It returns the intercept and slope parameters with their corresponding standard deviations.
Syntax 1:
    LET <a0> <a0sd> <a1> <a1sd> = MATRIX COLUMN FIT <mat> <x>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mat> is a matrix for which the fits are to be generated;
                <x> is a response variable that contains the independent variable for the fit;
                <a0> is a variable where the intercepts from the fits are saved;
                <a0sd> is a variable where the standard deviations of the intercepts from the fits are saved;
                <a1> is a variable where the slopes from the fits are saved;
                <a1sd> is a variable where the standard deviations of the slopes from the fits are saved;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional and rarely used in this context.

    With this syntax, each column of <mat> is used as the dependent variable in a linear least squares fit with <x> as the independent variable. The number of rows in <mat> must be the same as the number of rows in <x>

Syntax 2:
    LET <a0> <a0sd> <a1> <a1sd> = MATRIX ROW FIT <mat> <x>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mat> is a matrix for which the fits are to be generated;
                <x> is a response variable that contains the independent variable for the fit;
                <a0> is a variable where the intercepts from the fits are saved;
                <a0sd> is a variable where the standard deviations of the intercepts from the fits are saved;
                <a1> is a variable where the slopes from the fits are saved;
                <a1sd> is a variable where the standard deviations of the slopes from the fits are saved;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional and rarely used in this context.

    With this syntax, each row of <mat> is used as the dependent variable in a linear least squares fit with <x> as the independent variable. The number of columns in <mat> must be the same as the number of rows in <x>

Examples:
    LET A0 A0SD A1 A1SD = MATRIX COLUMN FIT M X
Synonyms:
    None
Related Commands:
    FIT = Perform a linear or non-linear least squares fit.
    LINEAR SLOPE = Compute the slope from a linear least squares fit.
    LINEAR INTERCEPT = Compute the intercept from a linear least squares fit.
Applications:
    Exploratory Data Analysis
Implementation Date:
    2010/07
Program:
     
    dimension 500 columns
    skip 25
    read gear.dat y tag
    .
    let tagdist = distinct tag
    let tagdist = sort tagdist
    let ngroup = size tagdist
    .
    loop for k = 1 1 ngroup
        let aval = tagdist(k)
        let y^k  = y
        retain y^k  subset tag = aval
    end of loop
    .
    let nrow = 10
    let x = sequence 1 1 nrow
    let m = create matrix y1 y2 y3 y4 y5 y6 y7 y8 y9 y10
    set write decimals 5
    .
    let b0 b1 b0sd b1sd = matrix column fit m x
    .
    print b0 b1 b0sd b1sd
    pause
    .
    let mt = matrix transpose m
    let c0 c1 c0sd c1sd = matrix row fit mt x
    print c0 c1 c0sd c1sd
        

Date created: 9/8/2010
Last updated: 9/8/2010
Please email comments on this WWW page to alan.heckert@nist.gov.