Matchvars: Difference between revisions
imported>Jeremy (Importing text file) |
imported>Jeremy (Importing text file) |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Align variables of a dataset to allow prediction with a model. | Align variables of a dataset to allow prediction with a model. | ||
===Synopsis=== | ===Synopsis=== | ||
:[mxdata, unmap] = matchvars(model,xdata,options) | :[mxdata, unmap] = matchvars(model,xdata,options) | ||
:[mxdata, unmap] = matchvars(labels,xdata,options) | :[mxdata, unmap] = matchvars(labels,xdata,options) | ||
:[mxdata, unmap] = matchvars(axisscale,xdata,options) | :[mxdata, unmap] = matchvars(axisscale,xdata,options) | ||
:[mxdata, mydata, unmapx, unmapy] = matchvars(model,xdata,ydata,options) | :[mxdata, mydata, unmapx, unmapy] = matchvars(model,xdata,ydata,options) | ||
:rdata = matchvars(mdata,unmap) | :rdata = matchvars(mdata,unmap) | ||
===Description=== | ===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. | 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. | 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. | ||
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. | 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. | 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. | If neither labels nor axisscales can be used to align variables, the dataset object is passed back without modification. | ||
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). | 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). | ||
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. | 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==== | ====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. | * '''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. | ||
* '''xdata''' = a dataset object containing the X-block data. | * '''xdata''' = a dataset object containing the X-block data. | ||
*'''OPTIONAL''' INPUTS: | *'''OPTIONAL''' INPUTS: | ||
* '''ydata''' = a second dataset containing the Y-block data | * '''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. | * '''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==== | ====OUTPUTS==== | ||
* '''mxdata''' = adjusted ("matched") x-block data | * '''mxdata''' = adjusted ("matched") x-block data | ||
* '''mydata''' = adjusted ("matched") y-block data (not returned if no y-data passed) | * '''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. | * '''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. | * '''See''' the "reorder" type of call in I/O below. | ||
* '''unmapy''' = same as unmapx but for the y-block (ydata) variable. | * '''unmapy''' = same as unmapx but for the y-block (ydata) variable. | ||
* '''rdata''' = reverted data - output only when matchvars is called with unmap as input. | * '''rdata''' = reverted data - output only when matchvars is called with unmap as input. | ||
===Options=== | ===Options=== | ||
* '''''options''''' = a structure array with the following fields: | * '''''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. | * '''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=== | ===See Also=== | ||
[[interp1]], [[modlpred]], [[pcapro]], [[replace]], [[str2cell]] | [[interp1]], [[modlpred]], [[pcapro]], [[replace]], [[str2cell]] |
Revision as of 14:25, 3 September 2008
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.
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.
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).
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.
- 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.