Contenuto principale

Fit a Two-Stage Model

What Is a Two-Stage Model?

A two-stage model fits a model to data with a hierarchical structure. If your data has local and global inputs, where some variables are fixed while varying others, then choose a two-stage model. For example, data collected in the form of spark sweeps is suited to a two-stage model. Each test sweeps a range of spark angles, with fixed engine speed, load, and air/fuel ratio within each test.

If your data inputs do not have a hierarchical structure, and all model inputs are global, at the same level, then fit a one-stage model instead. See Fit a One-Stage Model

For two-stage models, only specify a single local variable. If you want more local inputs, use a one-stage or point-by-point model instead. See Fit a One-Stage Model or Fit a Point-by-Point Model.

Import Data

Prepare your data before model fitting.

  1. In MATLAB®, on the Apps tab, in the Automotive group, click MBC Model Fitting.

  2. In the Model Browser home page, click Import Data.

    Choose whether to import from file or workspace.

    Select option Use data to fit a separate model for each operating point.

  3. Use the file browser to select a file to import.

    The Data Editor window opens.

  4. Use the Data Editor to inspect and prepare your data.

    Note

    You must define operating point groupings before two-stage modeling. See Define Operating Point Groupings. If you do not define operating point groupings, you are prompted after you try to fit models.

    You can filter, group, and edit data, and you can define new variables. See Working with Data in the Model Browser.

Fit Two-Stage Models

  1. In the Model Browser home page, click Fit Models.

  2. In the Fit Models dialog box, select a data set in the project from the Data set list.

    If you have no data loaded, you can click Import from file in the Data pane. Use the file browser to select a file to import.

    Optionally, you can select validation data as a sample of the fitting data or a separate data set.

  3. Click the Two-Stage test plan icon in the Template pane.

  4. In the Inputs and Responses pane, select data channels to use for the responses you want to model, and click the button to add to the responses.

    Note

    If you are modeling spark sweeps with a datum model, do not define responses at this step. Select local and global inputs and then click OK. To set up your datum model and local model types such as polynomial spline, use the Fit Models common task at the test plan node. See Datum Models.

    To create a boundary model, leave the Fit boundary model check box selected. A boundary model describing the limits of the operating envelope can be useful when you are creating and evaluating global models and optimization results.

  5. Select data channels to use for the local and global model inputs, and click the button to add to the responses.

  6. Click OK to fit the default model types to your selected data.

    If the data does not have operating point groupings, the Operating Point Groupings dialog box appears with default operating points defined by the global inputs. Verify or change the operating point groupings and click OK to continue model fitting.

    The toolbox calculates the fit and adds new model nodes to the Model Tree. The default global model is a Hybrid radial-basis function (RBF) which can usually produce a good fit first time.

    You can use the Model type drop-down, to override the default model type for global models.

    You can also select Convex hull or Pairwise convex hull from the Boundary model list to override the default boundary model setting.

    Default Model TypesLarge Data Settings for >2000 Operating Points
    Local model: Quadratic
    Global model: Hybrid radial-basis function (RBF)
    Global model switches to quadratic.
    Boundary model: Convex hull fit to the global inputs, and a two-stage boundary model for the local inputGlobal boundary model switches to pairwise convex hull.
    Switch when ≥ 8 inputs even when <2000 points.

    The Model Browser displays the local model view if you created a single response model, or the test plan node if you created multiple response models.

  7. View the fit of the local models to each operating point. Then view the global models at the response feature nodes.

    Functionality available for viewing and refining the model fit is described in Assess Local Models, Assess One-Stage Models and Guidelines for Selecting the Best Model Fit.

  8. When you are satisfied with the local and global models, you can build the two-stage model. Click Create Two-Stage in the Common Tasks pane.

    Note

    You can only create the two-stage if there are exactly enough response features for the model. If you add new response features, you must choose the response features to use before you can create the two-stage model.

  9. You are prompted to calculate the maximum likelihood estimate (MLE) at this point, if your global model types support MLE. You can do this now, or later by selecting Model > Calculate MLE. See Create Two-Stage Models for a detailed explanation.

    At this point, the two-stage model is calculated, and the icon changes at the local node to reflect this.

  10. After you build a single model, you should create more models for comparison, to search for the best fit. Follow the guidelines in Create Alternative Models to Compare.

See Two-Stage Models for Engines for a detailed explanation of two-stage models.

See Also

Topics