adjustment: A function to calculate satistical adjustment weight

Description Usage Arguments Examples

Description

This function allows to calculate satistical adjustment weight given some margins (equalities or inequalities).

Usage

1
2
adjustment(data, weight = NULL, margins = list(), weight_min = 0.1,
  weight_max = 10, ...)

Arguments

data

a data frame.

weight

a nonnegative numeric vector (with positive sum) of length nrow(data).

margins

a list specifing the margins constrains.

weight_min

a numeric constant greater or equal to 1.

weight_max

a nonnegative numeric constant.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data <- iris
summary(data)
margins <- list(list(var_name = 'Species',value=c(setosa=0.315),
min=c(versicolor=0.45),
max=c(versicolor=0.01)))
w <- adjustment(data = data,margins = margins)$w
data$w<-w
library(dplyr)
data%>%
  group_by(Species)%>%
  summarise(eff=sum(w))%>%
  merge(data%>%summarise(eff0=sum(w)))%>%
  mutate(freq = eff/eff0)

dominiqueemmanuel/adjustement documentation built on May 15, 2019, 10:37 a.m.