View source: R/functions.syn.r

syn.nested | R Documentation |

Synthesizes one variable (`y`

) from another one (`x`

)
when `y`

is nested in the categories of `x`

. A bootstrap
sample is created from the original values of `y`

within each category
of `xp`

(the synthesised values of the grouping variable).

syn.nested(y, x, xp, smoothing = "", cont.na = NA, ...)

`y` |
an original data vector of length |

`x` |
an original data vector of length |

`xp` |
a vector of length |

`smoothing` |
smoothing method. See |

`cont.na` |
when y is numeric this can be a list or a vector giving values
of |

`...` |
additional parameters. |

An example would be when `x`

is a classification
of occupations and `y`

is a more detailed sub-classification. It is
intended that `x`

is a categorical (factor) variable.
A warning will be issued if the original `y`

is not nested within `x`

.
A variable synthesised by `syn.nested()`

is automatically excluded from
predicting later variables because it will provide no extra information,
given its grouping variable.
`syn.nested()`

is also used for the final synthesis of variables in
`syn()`

when the option `numtocat`

is used to synthesise numerical
variables as groups.

A list with two components:

`res` |
a vector of length |

`fit` |
a name of the method used for synthesis ( |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.