As_svy_mean: As_svy_mean: Calculating the Weighted Mean or Median of any...

View source: R/As_svy_mean.R

As_svy_meanR Documentation

As_svy_mean: Calculating the Weighted Mean or Median of any Combination of the Factors for the Global Physical Activity Questionnaire (GPAQ)

Description

Prepare the output for the weighted measures explained in the GPAQ Analysis Guide at the population level

Usage

As_svy_mean(
  Outcome,
  Group = NULL,
  Data,
  id,
  weights,
  strata,
  CLN,
  Median = FALSE
)

Arguments

Outcome

the outcome of interest. for example: "meet" which reports percentage of respondents who do not meet WHO recommendations on physical activity for health.

Group

the group of interest. The default is NULL for when only the outcome variable is in our interest. Group can be any combination of categorical variables. Examples for group can be: ~age4y, ~age4y+sex, ~age4y+UrbanRural+sex, etc.

Data

the output object of gpaq function.

id

an argument in the "svydesign" function.

weights

an argument in the "svydesign" function.

starta

an argument in the "svydesign" function.

CLN

depends on the analysis. There are five CLN variables in the output of the gpaq function. see details.

Median

a logical argument. The default is FALSE when we are interested in the weighted average (and 95 percent confidence interval) value and TRUE for weighted median (and 25 percentile-75 percentile) values.

Details

"cln_composition" is for the analysis of the outcome variables "percentwork" "percenttrans" "percentrec".
"cln_meet" is for the analysis of the outcome variable "meet".
"cln_activity" is for the analysis of the outcome variable "work" "trans" "rec".
"cln_vigorous" is for the analysis of the outcome variable "vig".
"cln_specific" is for the the analysis of the outcome variable "pworkday" "ptravelday" "precday".

Value

Output is a matrix with number of rows equal to the combination number of categories for Group arguments and three columns. The first column indicate the group of interest, the second group is the average or median of the outcome and the third column is the 95 percent confidence interval for the average or 25 percentile and 75 percentile for the median.

Examples

Examples for Mean
   As_svy_mean(~meet,~age4y,Data=Data,id=psu, weights=wstep1,strata =stratum,CLN="cln_meet")
   As_svy_mean(~meet,~age4y+sex,Data=Data,id=psu, weights=wstep1,strata =stratum,CLN="cln_meet")
   As_svy_mean(~meet,~age4y+ur+sex,Data=Data,id=psu,weights=wstep1,strata =stratum,CLN="cln_meet")

   As_svy_mean(~meet,Data=Data,id=psu,weights=wstep1,strata =stratum,CLN="cln_meet")

Examples for Median
   As_svy_mean(~ptotalday,~age4y,Data=Data,id=psu, weights=wstep1,strata =stratum,CLN="cln_Ptotal",Median=TRUE)
   As_svy_mean(~ptotalday,~age4y+sex,Data=Data,id=psu, weights=wstep1,strata =stratum,CLN="cln_Ptotal",Median=TRUE)
   As_svy_mean(~ptotalday,~age4y+ur+sex,Data=Data,id=psu, weights=wstep1,strata =stratum,CLN="cln_Ptotal",Median=TRUE)

   As_svy_mean(~ptotalday,Data=Data,id=psu,weights=wstep1,strata =stratum,CLN="cln_Ptotal",Median=TRUE)


mhajihos/GPAQ documentation built on Nov. 21, 2023, 6:52 p.m.