diff options
author | jranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb> | 2012-03-27 01:03:18 +0000 |
---|---|---|
committer | jranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb> | 2012-03-27 01:03:18 +0000 |
commit | fff1fc581da5b4ff935ebd4d7ded02f750472fdc (patch) | |
tree | a18da58a5bfd013c1bd35bbc7828925084a13a76 /R/ilr.R | |
parent | 1718d434efae26de02754c6622c43f4dc9e624b9 (diff) |
Start of the transition to fitting transformed parameters.
Many things are broken now (see TODO list)
git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/kinfit/pkg/mkin@20 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
Diffstat (limited to 'R/ilr.R')
-rw-r--r-- | R/ilr.R | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/R/ilr.R b/R/ilr.R new file mode 100644 index 00000000..f2a6f1bb --- /dev/null +++ b/R/ilr.R @@ -0,0 +1,44 @@ +# $Id: ilr.R 120 2011-09-02 14:25:35Z jranke $ + +# Copyright (C) 2012 René Lehmann, Johannes Ranke +# Contact: jranke@uni-bremen.de + +# This file is part of the R package mkin + +# mkin is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program. If not, see <http://www.gnu.org/licenses/> + +ilr <- function(x) { + z <- vector() + for (i in 1:(length(x) - 1)) { + z[i] <- sqrt(i/(i+1)) * log((prod(x[1:i]))^(1/i) / x[i+1]) + } + return(z) +} + +invilr<-function(x) { + D <- length(x) + 1 + z <- c(x, 0) + y <- rep(0, D) + s <- sqrt(1:D*2:(D+1)) + q <- z/s + y[1] <- sum(q[1:D]) + for (i in 2:D) { + y[i] <- sum(q[i:D]) - sqrt((i-1)/i) * z[i-1] + } + z <- vector() + for (i in 1:D) { + z[i] <- exp(y[i])/sum(exp(y)) + } + return(z) +} |