R/LR.R

Defines functions L R PP

Documented in L L L PP PP R R

#' Specify the left hand and right hand side of an expression used in pims
#' 
#' These functions allow you to specify the left hand side and 
#' right hand side of a term in a pim model. The user should
#' only use this functions within a formula using the \code{\link{pim}}
#' function. Use in a different context will return an error.
#' 
#' @param x any vector specified in a formula
#' 
#' @return a vector with the pseudo-observations for x, based on the 
#' poset used to create the function. If used in a wrong context (i.e.
#' not in a call to \code{pim}), it returns \code{x} unchanged and throws
#' a warning.
#' 
#' @details These specific functions are actually not used by the 
#' function \code{\link{pim}}. \code{pim} calls the internal function
#' \code{\link{.make.posfun}} to create the actual functions \code{L}
#' and \code{R} to work with the specified posets of the model of 
#' interest.
#' 
#' The actual functions used by \code{pim} are saved in a specific environment, a \code{\link{pim.environment}}, which resides in the \code{\link{pim-class}} object returned by \code{pim}. This way of working
#' is chosen in order to avoid unnecessary copying of data.
#' 
#' The function \code{PP} serves simply as short for \code{R(x) - L(x)}. If used outside the context of a pim model, it will generate
#' multiple warnings (see section warning).
#' 
#' @section warning:
#' 
#' These functions serve only as placeholder. During the fitting process
#' of a pim, they get updated to include the posets (the indices that
#' determine which observations are compared)
#' Note that this makes the functions behave fundamentally
#' different from what you would expect R. The result of these
#' functions depends on the context in which they are called.
#' @examples
#' \dontrun{
#' pim(income~(L(foodexp) - R(foodexp)), data=Engeldata)
#' L(1:10) # Gives a warning
#' }
#' @aliases R L PP
#' @export
L <- function(x){
  warning("L() is not correctly defined. Please see ?L for more information.")  
  x
}

#' @rdname L
#' @name L
#' @export
R <- function(x){
  warning("R() is not correctly defined. Please see ?R for more information.")  
  x
}

#' @rdname L
#' @name L
#' @export
PP <- function(x){
  R(x) - L(x)
}

Try the pim package in your browser

Any scripts or data that you put into this service are public.

pim documentation built on May 2, 2019, 6:51 p.m.