Skip to contents

Use of one of these functions in a model is how you specify the portion of the model that is to be regarded as a response-surface component.

Usage

FO (...)
TWI (..., formula)
PQ (...)
SO (...)
PE (...)

Arguments

...

The numerical predictors for the response surface, separated by commas.

formula

Alternative way to specify two-way interactions. Use formula or ..., never both.

Details

Use FO() in the model formula in rsm to specify a first-order response surface (i.e., a linear function) in its arguments. Use TWI() to generate two-way interactions, and PQ() to generate pure quadratic terms (squares of the FO() terms). A call to SO() creates all terms in FO(), TWI(), and PQ() (in that order) for those variables. However, specifying SO() in a model formula in rsm will be replaced by the explicit sum of model terms, so that the anova table shows separate sums of squares. Other variables (such as blocks or factors) may be included in the model but should never be included in the arguments to FO or SO.

PE is used for fitting pure-error models. It should not be used in response-surface models. This function exists primarily for use by loftest, but could be useful in other linear-model contexts for fitting a model that interpolates the means at each distinct combination of argument values.

The formula argument in TWI can simplify specifying models where only certain interactions are included. For example, TWI(formula = ~x1:(x2+x3)) is equivalent to TWI(x1,x2) + TWI(x1,x3). The formula is expanded using terms, and then only the second-order terms are retained. If this results in only one term, an error condition is raised. This is necessary to prevent rsm from getting confused in identifying second-order terms.

Value

The functions FO, TWI, PQ, and SO return a matrix whose columns are the required predictors.

PE returns a factor whose levels are all the distinct combinations of arguments provided to the function.

References

Lenth RV (2009) ``Response-Surface Methods in R, Using rsm'', Journal of Statistical Software, 32(7), 1--17. doi:10.18637/jss.v032.i07

Author

Russell V. Lenth

See also

Examples

  ### See 'rsm' help for examples of FO, TWI, etc
  
  library(rsm)
  ### Test LOF for a regression model
  ChemReact.lm <- lm(Yield ~ Time*Temp, data = ChemReact1)
  PureError.lm <- update (ChemReact.lm, . ~ PE(Time,Temp))
  anova (ChemReact.lm, PureError.lm)
#> Analysis of Variance Table
#> 
#> Model 1: Yield ~ Time * Temp
#> Model 2: Yield ~ PE(Time, Temp)
#>   Res.Df    RSS Df Sum of Sq      F   Pr(>F)   
#> 1      3 8.3211                                
#> 2      2 0.0867  1    8.2344 190.02 0.005221 **
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1