Matchvars

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

Purpose

Align variables of a dataset to allow prediction with a model.

Synopsis

[mxdata, unmap] = matchvars(model,xdata,options)
[mxdata, unmap] = matchvars(labels,xdata,options)
[mxdata, unmap] = matchvars(axisscale,xdata,options)
[mxdata, mydata, unmapx, unmapy] = matchvars(model,xdata,ydata,options)
rdata = matchvars(mdata,unmap)

Description

Given a standard model structure model MATCHVARS uses either the labels stored in the model or, if no labels exist, the axisscale in the model to rearrange or interpolate the variables of a dataset object so that the model can be applied to the data. If model is a regression model, both an X and a Y block may be passed for alignment. A Y block is not required, however.

MATCHVARS WITH LABELS: When variable labels exist in both the model and the data, the variables in data are rearranged to match the variable order in model based on the labels stored in the model. Any variables required by model that do not exist in data are returned as NaN (Not a Number). These will usually be automatically replaced by the prediction routine using REPLACE.

When no labels exist in the supplied model, the axisscale is used to interpolate the data based on the setting of options.axismode (see below). Axis regions which require extrapolation are returned as NaN (Not a Number). These will usually be automatically replaced by the prediction routine using REPLACE.

If neither labels nor axisscales can be used to align variables, the dataset object is passed back without modification and unmap will be empty.

An ordinary cell or character array of strings representing labels to match or an ordinary vector representing an axisscale may be passed in place of model. Such labels or axisscale can only be used with a single dataset (i.e. xdata). If a dataset is passed in place of a model, it is considered the target and the labels or axisscales for the variables are used (in that order of preference.)

NOTE: if axisscale was used to interpolate new variables for mxdata or mydata, the unmap variable(s) will be linear vectors which simply return the original data.

Inputs

  • model = a standard model structure OR a cell or character array of labels to match labels in xdata OR a vector of axisscale (e.g. wavelength, wavenumber, etc) to match xdata using axisscale OR a dataset containing either labels or axisscales on the columns.
  • xdata = a dataset object containing the X-block data.

Optional Inputs

  • ydata = a second dataset containing the Y-block data
  • unmap = used only when performing an "undo" of a previous MATCHVARS call. This is a vector describing how to reorder the columns back to the original order, as output by the previous call to MATCHVARS. Can be used to re-order the outputs from a model, such as the T- or Q-contributions, back to the original data order.

Outputs

  • mxdata = adjusted ("matched") x-block data
  • mydata = adjusted ("matched") y-block data (not returned if no y-data passed)
  • unmapx = a vector describing how the original variable order can be obtained from the reordered data. This can be used on other model outputs such as residuals and T contributions rearranging them to be like the original data. Any column discarded from the original data will have an NaN in unmap.
See the "reorder" type of call in I/O below.
  • unmapy = same as unmapx but for the y-block (ydata) variable.
  • rdata = reverted data - output only when matchvars is called with unmap as input.

Options

  • options = a structure array with the following fields:
  • axismode: ['discrete' |{'linear'}| 'spline'] a string defining the interpolation method to use for matching variables using axisscale. If 'discrete', axisscale values must be matched exactly by data. Any other axismode will be passed to interp1 to perform interpolation. See INTERP1 for interpolation options.

See Also

interp1, matchrows, modlpred, pcapro, replace, str2cell