hypr is an R package for easy translation between experimental (null) hypotheses and contrast matrices as used for linear regression. For an extensive overview of the package functions, see the `hypr-intro`

vignette, e.g. by running `vignette("hypr-intro")`

after installing the package.

Install from CRAN within R using:

Install the development version in R using `devtools`

:

For a treatment contrast with a baseline and three treatment conditions:

```
## hypr object containing 4 null hypotheses:
## H0.1: 0 = mu1
## H0.2: 0 = mu2 - mu1
## H0.3: 0 = mu3 - mu1
## H0.4: 0 = mu4 - mu1
##
## Hypothesis matrix (transposed):
## [,1] [,2] [,3] [,4]
## mu1 1 -1 -1 -1
## mu2 0 1 0 0
## mu3 0 0 1 0
## mu4 0 0 0 1
##
## Contrast matrix:
## [,1] [,2] [,3] [,4]
## mu1 1 0 0 0
## mu2 1 1 0 0
## mu3 1 0 1 0
## mu4 1 0 0 1
```

To assign the contrast matrix to a factor `fac`

with an intermediate hypr object:

… or without an intermediate object:

For more information, see `vignette("hypr-regression")`

.

To check which reserach (null) hypotheses a given contrast matrix is testing, we can create an empty hypr object.

A treatment contrast with 4 levels (incl. the baseline) can look as follows:

```
## 2 3 4
## 1 0 0 0
## 2 1 0 0
## 3 0 1 0
## 4 0 0 1
```

We can now populate the hypr object by setting its contrast matrix. Note that the treatment contrast does not have an intercept. We thus have to add it when populating the hypr object:

Now, the hypr object contains 4 hypotheses, a hypothesis matrix and the contrast matrix identical to the treatment contrast with an intercept added:

```
## hypr object containing 4 null hypotheses:
## H0.Intercept: 0 = X1
## H0.2: 0 = -X1 + X2
## H0.3: 0 = -X1 + X3
## H0.4: 0 = -X1 + X4
##
## Hypothesis matrix (transposed):
## Intercept 2 3 4
## X1 1 -1 -1 -1
## X2 0 1 0 0
## X3 0 0 1 0
## X4 0 0 0 1
##
## Contrast matrix:
## Intercept 2 3 4
## X1 1 0 0 0
## X2 1 1 0 0
## X3 1 0 1 0
## X4 1 0 0 1
```

The derived hypotheses can be rewritten as:

For more information, see `vignette("hypr-contrasts")`

.

If you want to report a bug, are having technical difficulties or want to recommend features, it’s best to open a Github Issue. If you want to suggest a specific implementation of a feature or bug fix, you’re welcome to fork the repository and submit a pull request! Alternatively, if you are having problems or questions, you can also send an e-mail (maximilian.rabe@uni-potsdam.de).