packval {mixstock} | R Documentation

## Pack and unpack contribution and marker frequencies

### Description

Packs/unpacks source contributions and source marker frequencies into a single vector, after transforming them to an uncorrelated (and possibly unbounded) set of parameters.

### Usage

    packval(f, r, transf="part")
    packval2(x,R=2,H=3)
    unpackval(p,R=2,H=2,x.orig=NULL,transf="full",input.only=FALSE)
    unpackval2(p,R=2,H=2,transf="full",x.orig=NULL)

### Arguments

`f` | Source contributions (numeric vector, all between 0 and 1, sum equals 1)
`r` | Source marker frequencies: matrix of marker frequencies (row=marker, column=source)
`x` | a numeric vector containing (elements 1 to R) source contributions and (elements R+1 to (R+R*H)) marker frequencies in sources
`p` | a packed/transformed parameter vector
`transf` | Transform to unbounded variables? ("full","part","none") (See `p.to.q` for description/warnings.)
`R` | number of sources
`H` | number of markers
`x.orig` | original data (for extracting source/marker names)
`input.only` | return only contribution parameters?

### Value

`packval` packs source contributions and marker frequencies specified as a separate vector and a matrix: `packval2` packs them (i.e. transforms them) when they have already been run together as a vector. Either produces a numeric vector of the transformed values, with length (R-1+R*(H-1)). `unpackval` and `unpackval2` invert the operation, producing a list

`input.freq` | source contributions
`source.freq` | marker frequencies in sources

or a vector respectively.

### Author(s)

Ben Bolker

### See Also

`p.to.q`

### Examples

    data(simex)
    sourcefreq <- sweep(simex$sourcesamp,2,apply(simex$sourcesamp,2,sum),"/")
    packval(c(0.2,0.8),sourcefreq)
    packval(c(0.2,0.8),sourcefreq,transf="full")

[Package mixstock version 0.9.2 Index]