AggrSml2NumVar: Aggregated comparison of two numerical variables

AggrSml2NumVarR Documentation

Aggregated comparison of two numerical variables

Description

Calculating aggregated values for two numerical variables, useful for comparison of the variables

Usage

AggrSml2NumVar(data, xVar, yVar, strataVar = NULL, identiske = FALSE)

Arguments

data

Input data set of class data.frame.

xVar

Name of the x variable to be compared.

yVar

Name of the y variable to be compared.

strataVar

Name of stratification variable. Optional.

identiske

When TRUE, only units with value on both x and y are used in the calculations. Default FALSE.

Value

Output of AggrSml2NumVar is a data set of class data.frame. The variables in the data frame are:

strata

The stratum (if strataVar is given, "1" otherwise)

Antx

The number of units with x not missing used in the aggregation

Anty

The number of units with y not missing used in the aggregation

Sumx

The total of x in the stratum

Sumy

The total of y in the stratum

SumxProsAvTotx

The stratum total for x in percent of the population total for x: (Sumx / Totx) * 100

SumyProsAvToty

The stratum total for y in percent of the population total for y: (Sumy / Toty) * 100

Diff

The difference between the stratum totales of x and y: Sumy - Sumx

AbsDiff

The absolute difference: |Diff|

DiffProsAvSumx

The difference in percent of the stratum total for x: (Diff / Sumx) * 100

AbsDiffProsAvSumx

The absolute value of DiffProsAvSumx: |DiffProsAvSumx|

DiffProsAvTotx

The difference in percent of the population total for x: (Diff / Totx) * 100

AbsDiffProsAvTotx

The absolute value of DiffProsAvTotx: |DiffProsAvTotx|

Author(s)

Anna Mevik

Examples

testdata <- KostraData("testdata")

# lager en grupperingsvariabel
testdata$gr <- c(rep(3, 30), rep(5, 40), rep(1, 61), rep(2, 91), rep(3, 68), rep(4, 61),
                 rep(5, 45), rep(4, 20))

AggrSml2NumVar(data = testdata, xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
               strataVar = "gr", identiske = FALSE)


statisticsnorway/Kostra documentation built on Sept. 25, 2024, 10:37 a.m.