# [Rd] How to use formulas for multivariate clustered data?

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Tue Jul 28 19:23:44 CEST 2009

```Klaus:

> I wrote already a couple of weeks ago but did not get any reply. Therefore
> I'll rephrase my question and hope some of you can give me some answers or
>
> In general I'm looking for information on how to program functions using
> formulas in order to write a nonparametric multivariate regression function
> with possible clustering of the data.
>
> I would assume that the formulas for my function would have the form
> y1 + y2 + y3 ~ x | z
> or
> Y ~ x | z,
>
> where y1, y2 and y3 are continuous response variables, or Y the matrix of
> responses and x an explaining variable and z a factor indicating the cluster
> membership.
>
> I'm looking for general information about writing functions using formulas.
> But more concrete I would need to know what would be the best way to make
> sure that the response should be multivariate and numeric? What is the best
> way to define the hierarchical structure, is it the "|" or is there another,
> better way? How can I restrict the number of hierarchical levels?
> And how to use in this context, the data, subset, weights and na.action
> arguments?

The CRAN package "Formula" has some functionality which might assist you
in what you want to do. It provides several tools for extracting
information from formulas like
Y ~ x1 + x2 | z

The version on R-Forge also has some tools for
y1 + y2 + y3 ~ x1 + x2 | z1 | z2 + z3
etc. But the version on R-Forge is not yet quite stable, however, we hope
to get something new to CRAN over the summer.

The package just assists you with accessing the different parts of the
formula. All the checking of types, dimensions, etc. you have to do
yourself. I hope it solves some of your problems, though...

hth,
Z

>
> Klaus
>
> --
> Klaus Nordhausen
> Researcher
> Tampere School of Public Health
> FIN-33014 University of Tampere
>
> phone:	+358 3 3551 4153
> fax:	+358 3 3551 4150
> e-mail:	Klaus.Nordhausen at uta.fi
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

```