R: Expand Symbolic Polynomials in a Formula

expand.polynom {spatstat.utils} | R Documentation

## Expand Symbolic Polynomials in a Formula

### Description

Create a formula representing a polynomial, or expand polynomials in an existing formula.

### Usage

      expand.polynom(f)
      sympoly(x, y, n)

### Arguments

`f` | A formula.
`x,y` | Variable names.
`n` | Integer specifying the degree of the polynomial. (If `n` is missing, `y` will be interpreted as the degree.)

### Details

These functions expand a polynomial into its homogeneous terms and return a model formula.

`sympoly(x, n)` creates a formula whose right-hand side represents the polynomial of degree `n` in the variable `x`. Each homogeneous term `x^k` is a separate term in the formula.

`sympoly(x, y, n)` creates a formula representing the polynomial of degree `n` in the two variables `x` and `y`.

If `f` is a formula containing a term of the form `polynom(...)` then `expand.polynom(f)` replaces this term by its expansion as a sum of homogeneous terms.

### Value

A `formula`.

### Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

### See Also

`polynom`

### Examples

       sympoly(A, 4)
       sympoly(A, B, 3)
       expand.polynom(U ~ A + polynom(B, 2))

[Package spatstat.utils version 1.17-0 Index]