calcFY {ACCLMA}R Documentation

Calculates the appropriate FY value of each observation

Description

Calculates the aggregated mean Y value of each observation by summing the F(Y) value of the previous observation with the Y*Weight of the current observation

Usage

calcFY(mat)

Arguments

mat

A matrix containing the X,Y,Weight,FX columns after the function calcWeights,reduceSameXs and calcFX has been used on it

Value

A matrix containg the newely added FY column

Author(s)

Tal Carmi, Liat Gaziel

Examples

d <- c(1,1,3,4)
e <- c(5,6,7,8)
f <- c(1,1,1,1)
mydata <- data.frame(d,e,f)
names(mydata) <- c("X","Y","Weight")
mydata<-calcWeights(mydata)
mydata<-averageSameXs(mydata)
mydata<-calcFX(mydata)
calcFY(mydata)

## The function is currently defined as
function (mat) 
{
    mat[1, 5] = mat[1, 2] * mat[1, 3]
    n <- size(mat)
    for (i in 2:n) {
        mat[i, 5] = mat[i - 1, 5] + mat[i, 2] * mat[i, 3]
    }
    names(mat)[5] <- "FY"
    return(mat)
  }

[Package ACCLMA version 1.0 Index]