Skip to content

Commit

Permalink
FIX some typos in ipf and methodology vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfgang Rannetbauer - QM committed Jul 29, 2020
1 parent 1d815d0 commit ff7f9ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions vignettes/ipf.Rmd
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(
)
```

This vignette explains the usage of the `ipf()` function, which has been used for calibrating the labour force survey of austria for several years.
This vignette explains the usage of the `ipf()` function, which has been used for calibrating the labour force survey of Austria for several years.
It is based on the Iterative Proportional Fitting algorithm and gives some flexibility about the details of the implementation. See [@mekogu2016] or `vignette("methodology")` for more details.

## Setup
Expand Down Expand Up @@ -45,7 +45,7 @@ We can see that this is currently not the case.
xtabs(pWeight ~ gender, pop_sample)
```

Due to random sampling (rather than stratified sampling), there are differences betweeen the gender distributions.
Due to random sampling (rather than stratified sampling), there are differences between the gender distributions.
We can pass `gender_distribution` as a parameter to `ipf()` to obtain modified weights.

```{r}
Expand Down Expand Up @@ -92,7 +92,7 @@ xtabs(pWeight ~ gender + age, pop_sample)
```

Again, we can see that those constraints are not met.
Suppliying the contingency table `con_ga` to `ipf()` will again resolve this.
Supplying the contingency table `con_ga` to `ipf()` will again resolve this.

```{r}
pop_sample_c2 <- ipf(pop_sample, conP = list(con_ga), w = "pWeight")
Expand Down
6 changes: 3 additions & 3 deletions vignettes/methodology.Rmd
Expand Up @@ -114,7 +114,7 @@ For ease of readability we will drop the subindices regarding strata $h$ and clu

The uncalibrated bootstrap weights $\tilde{b}_j^{i}$ computed through the rescaled bootstrap procedure yields population statistics that differ from the known population margins of specified sociodemographic variables for which the base weights $w_j$ have been calibrated. To adjust for this the bootstrap weights $\tilde{b}_{j}^{i}$ can be recalibrated using iterative proportional fitting as described in [@mekogu2016].

Let the original weight $w_{j}$ be calibrated for $n=n_P+n_H$ sociodemographic variables which are divided into the sets $\mathcal{P}:=\{p_{c}, c=1 \ldots,n_P\}$ and $\mathcal{H}:=\{h_{c}, c=1 \ldots,n_H\}$. $\mathcal{P}$ and $\mathcal{H}$ correspond to personal, for example gender or age, or household variables, like region or households size, respectively. Each variable in either $\mathcal{P}$ or $\mathcal{H}$ can take on $P_{c}$ or $H_{c}$ values with and $N^{p_c}_v$, $v=1,\ldots,P_c$, or $N^{h_c}_v$, $v=1,\ldots,H_c$, as the corresponding population margins. Starting with $k=0$ the iterative proportional fitting procedure is applied on each $\tilde{b}_j^{i}$, $i=1,\ldots, B$ seperately. The weights are first updated for personal and afterwards updated for household variables. If constraints regarding the populations margins are not met $k$ is raised by 1 and the procedure starts from the beginning. For the following denote as starting weight $\tilde{b}_j^{[0]}:=\tilde{b}_j^{i}$ for fixed $i$.
Let the original weight $w_{j}$ be calibrated for $n=n_P+n_H$ sociodemographic variables which are divided into the sets $\mathcal{P}:=\{p_{c}, c=1 \ldots,n_P\}$ and $\mathcal{H}:=\{h_{c}, c=1 \ldots,n_H\}$. $\mathcal{P}$ and $\mathcal{H}$ correspond to personal, for example gender or age, or household variables, like region or households size, respectively. Each variable in either $\mathcal{P}$ or $\mathcal{H}$ can take on $P_{c}$ or $H_{c}$ values with and $N^{p_c}_v$, $v=1,\ldots,P_c$, or $N^{h_c}_v$, $v=1,\ldots,H_c$, as the corresponding population margins. Starting with $k=0$ the iterative proportional fitting procedure is applied on each $\tilde{b}_j^{i}$, $i=1,\ldots, B$ separately. The weights are first updated for personal and afterwards updated for household variables. If constraints regarding the populations margins are not met $k$ is raised by 1 and the procedure starts from the beginning. For the following denote as starting weight $\tilde{b}_j^{[0]}:=\tilde{b}_j^{i}$ for fixed $i$.

### Adjustment and trimming for $\mathcal{P}$

Expand All @@ -132,7 +132,7 @@ Since the sociodemographic variables $p_1,\ldots,p_{n_c}$ include person-specifi
$$
\tilde{b}_j^{[(n+1)k+n_p+1]} = \frac{{\sum\limits_{l\in a}} {\tilde{b}_l^{[(n+1)k+n_p]}}}{h_a}
$$
This can result in losing the population structure performed in the previouse subsection.
This can result in losing the population structure performed in the previous subsection.

### Adjustment and trimming for $\mathcal{H}$

Expand Down Expand Up @@ -160,7 +160,7 @@ $$
\frac{N^{h_c}_v}{{\sum\limits_l} {\tilde{b}}_l^{[(n+1)k+j]}} \in ((1-\epsilon_h)N^{h_c}_v,(1+\epsilon_h)N^{h_c}_v)
$$
are verified, where the sum in the denominator expands over all observations which have the same value for variables $h_c$ or $p_c$.
If these contraints hold true the algorithm reaches convergence, otherwise $k$ is raised by 1 and the procedure repeats itself.
If these constraints hold true the algorithm reaches convergence, otherwise $k$ is raised by 1 and the procedure repeats itself.

The above described calibration procedure is applied on each year $y_t$ of EU-SILC separately, $t=1,\ldots n_y$, thus resulting in so called calibrated bootstrap sample weights $b_{j}^{(i,{y_t})}$, $i=1,\ldots,B$ for each year $y$ and each household $j$.

Expand Down

1 comment on commit ff7f9ee

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/calc.stError.R:853:1: style: Lines should not be more than 80 characters.

var.est[, c("est", "ID") := tstrsplit(variable, "\\.(?=[^\\.]+$)", perl=TRUE)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/calc.stError.R:853:76: style: Put spaces around all infix operators.

var.est[, c("est", "ID") := tstrsplit(variable, "\\.(?=[^\\.]+$)", perl=TRUE)]
                                                                          ~^~

R/draw.bootstrap.R:395:1: style: Trailing whitespace is superfluous.

^~

R/draw.bootstrap.R:397:6: style: Place a space before left parenthesis, except in a function call.

for(i in seq_along(strata)){
     ^

R/draw.bootstrap.R:397:29: style: There should be a space between right parenthesis and an opening curly brace.

for(i in seq_along(strata)){
                            ^~

R/draw.bootstrap.R:398:7: style: Place a space before left parenthesis, except in a function call.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
      ^

R/draw.bootstrap.R:398:18: style: Put spaces around all infix operators.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                ~^~~~~

R/draw.bootstrap.R:398:28: style: Commas should always have a space after.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                           ^

R/draw.bootstrap.R:398:46: style: Put spaces around all infix operators.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                                            ~^~~~~

R/draw.bootstrap.R:398:56: style: Commas should always have a space after.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                                                       ^

R/draw.bootstrap.R:398:60: style: There should be a space between right parenthesis and an opening curly brace.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                                                           ^~

R/draw.bootstrap.R:399:1: style: Lines should not be more than 80 characters.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=c(cluster[i],period)][V1>1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/draw.bootstrap.R:399:48: style: Commas should always have a space after.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=c(cluster[i],period)][V1>1]")
                                               ^

R/draw.bootstrap.R:399:58: style: Commas should always have a space after.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=c(cluster[i],period)][V1>1]")
                                                         ^

R/draw.bootstrap.R:400:9: style: Place a space before left parenthesis, except in a function call.

if(nrow(countMultiple)>0){
        ^

R/draw.bootstrap.R:400:29: style: Put spaces around all infix operators.

if(nrow(countMultiple)>0){
                           ~^~

R/draw.bootstrap.R:400:31: style: There should be a space between right parenthesis and an opening curly brace.

if(nrow(countMultiple)>0){
                              ^~

R/draw.bootstrap.R:401:1: style: Lines should not be more than 80 characters.

​        stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/draw.bootstrap.R:401:40: style: Commas should always have a space after.

​        stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
                                       ^

R/draw.bootstrap.R:401:51: style: Commas should always have a space after.

​        stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
                                                  ^

R/draw.bootstrap.R:401:83: style: Commas should always have a space after.

​        stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
                                                                                  ^

R/draw.bootstrap.R:405:1: style: Trailing whitespace is superfluous.

^~

R/ipf.r:35:5: style: Place a space before left parenthesis, except in a function call.

if(!is.null(bound)){
    ^

R/ipf.r:35:21: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.null(bound)){
                    ^~

R/ipf.r:43:5: style: Place a space before left parenthesis, except in a function call.

if(!is.null(minMaxTrim)){
    ^

R/ipf.r:43:26: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.null(minMaxTrim)){
                         ^~

R/ipf.r:44:10: style: Put spaces around all infix operators.

g1[g1<minMaxTrim[1]] <- minMaxTrim[1]
        ~^~

R/ipf.r:45:10: style: Put spaces around all infix operators.

g1[g1>minMaxTrim[2]] <- minMaxTrim[2]
        ~^~

R/ipf.r:59:5: style: Place a space before left parenthesis, except in a function call.

if(!is.null(bound)){
    ^

R/ipf.r:59:21: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.null(bound)){
                    ^~

R/ipf.r:65:5: style: Place a space before left parenthesis, except in a function call.

if(!is.null(minMaxTrim)){
    ^

R/ipf.r:65:26: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.null(minMaxTrim)){
                         ^~

R/ipf.r:66:10: style: Put spaces around all infix operators.

g1[g1<minMaxTrim[1]] <- minMaxTrim[1]
        ~^~

R/ipf.r:67:10: style: Put spaces around all infix operators.

g1[g1>minMaxTrim[2]] <- minMaxTrim[2]
        ~^~

R/ipf.r:72:37: style: There should be a space between right parenthesis and an opening curly brace.

check_eps <- function(con, eps, type){
                                    ^~

R/ipf.r:74:5: style: Place a space before left parenthesis, except in a function call.

if(is.list(eps)){
    ^

R/ipf.r:74:18: style: There should be a space between right parenthesis and an opening curly brace.

if(is.list(eps)){
                 ^~

R/ipf.r:75:7: style: Place a space before left parenthesis, except in a function call.

if(length(eps)!=l){
      ^

R/ipf.r:75:19: style: Put spaces around all infix operators.

if(length(eps)!=l){
                 ~^~~

R/ipf.r:75:22: style: There should be a space between right parenthesis and an opening curly brace.

if(length(eps)!=l){
                     ^~

R/ipf.r:76:1: style: Lines should not be more than 80 characters.

​      stop(paste("Provided",type,"eps argument does not fit",type,"constraints."))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:76:29: style: Commas should always have a space after.

​      stop(paste("Provided",type,"eps argument does not fit",type,"constraints."))
                            ^

R/ipf.r:76:34: style: Commas should always have a space after.

​      stop(paste("Provided",type,"eps argument does not fit",type,"constraints."))
                                 ^

R/ipf.r:76:62: style: Commas should always have a space after.

​      stop(paste("Provided",type,"eps argument does not fit",type,"constraints."))
                                                             ^

R/ipf.r:76:67: style: Commas should always have a space after.

​      stop(paste("Provided",type,"eps argument does not fit",type,"constraints."))
                                                                  ^

R/ipf.r:78:8: style: Place a space before left parenthesis, except in a function call.

for(i in 1:length(eps)){
       ^

R/ipf.r:78:14: warning: Avoid 1:length(...) expressions, use seq_len.

for(i in 1:length(eps)){
             ^

R/ipf.r:78:27: style: There should be a space between right parenthesis and an opening curly brace.

for(i in 1:length(eps)){
                          ^~

R/ipf.r:79:9: style: Place a space before left parenthesis, except in a function call.

if(is.array(eps[[i]])){
        ^

R/ipf.r:79:28: style: There should be a space between right parenthesis and an opening curly brace.

if(is.array(eps[[i]])){
                           ^~

R/ipf.r:80:11: style: Place a space before left parenthesis, except in a function call.

if(!identical(dim(eps[[i]]),dim(con[[i]]))){
          ^

R/ipf.r:80:37: style: Commas should always have a space after.

if(!identical(dim(eps[[i]]),dim(con[[i]]))){
                                    ^

R/ipf.r:80:51: style: There should be a space between right parenthesis and an opening curly brace.

if(!identical(dim(eps[[i]]),dim(con[[i]]))){
                                                  ^~

R/ipf.r:81:1: style: Lines should not be more than 80 characters.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:81:33: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                ^

R/ipf.r:81:38: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                     ^

R/ipf.r:81:53: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                                    ^

R/ipf.r:81:55: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                                      ^

R/ipf.r:81:87: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                                                                      ^

R/ipf.r:81:92: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                                                                           ^

R/ipf.r:81:106: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                                                                                         ^

R/ipf.r:81:108: style: Commas should always have a space after.

​          stop(paste("Provided",type,"eps argument",i,"does not fit in dimension to ",type,"constraints",i,"."))
                                                                                                           ^

R/ipf.r:85:11: style: Place a space before left parenthesis, except in a function call.

​  }else if(length(eps)>1){
          ^

R/ipf.r:85:23: style: Put spaces around all infix operators.

​  }else if(length(eps)>1){
                     ~^~

R/ipf.r:85:25: style: There should be a space between right parenthesis and an opening curly brace.

​  }else if(length(eps)>1){
                        ^~

R/ipf.r:86:1: style: Lines should not be more than 80 characters.

​    stop("Individual eps arguments for each constraints must be defined as list.")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:137:1: style: Lines should not be more than 80 characters.

numericalWeighting, numericalWeightingVar, w, cw, minMaxTrim) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:138:1: style: Lines should not be more than 80 characters.

selectGroupNotConverged <- epsPcur <- maxFac <- OriginalSortingVariable <- V1 <-
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:182:1: style: Lines should not be more than 80 characters.

dat[, selectGroupNotConverged := any(!is.na(fVariableForCalibrationIPF) &
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:183:1: style: Lines should not be more than 80 characters.

​                                               (abs(1 / fVariableForCalibrationIPF - 1) > epsPcur)), by= c(pColNames[[i]])]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:183:104: style: Put spaces around all infix operators.

​                                               (abs(1 / fVariableForCalibrationIPF - 1) > epsPcur)), by= c(pColNames[[i]])]
                                                                                                      ~^

R/ipf.r:227:1: style: Lines should not be more than 80 characters.

looseH, numericalWeighting, numericalWeightingVar, w, cw, minMaxTrim) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:587:5: style: Place a space before left parenthesis, except in a function call.

if(!is.null(minMaxTrim)){
    ^

R/ipf.r:587:26: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.null(minMaxTrim)){
                         ^~

R/ipf.r:588:7: style: Place a space before left parenthesis, except in a function call.

if(length(minMaxTrim)!=2)
      ^

R/ipf.r:588:26: style: Put spaces around all infix operators.

if(length(minMaxTrim)!=2)
                        ~^~~

R/ipf.r:590:7: style: Place a space before left parenthesis, except in a function call.

if(!is.numeric(minMaxTrim)){
      ^

R/ipf.r:590:31: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.numeric(minMaxTrim)){
                              ^~

R/ipf.r:593:7: style: Place a space before left parenthesis, except in a function call.

if(minMaxTrim[2]<minMaxTrim[1]){
      ^

R/ipf.r:593:21: style: Put spaces around all infix operators.

if(minMaxTrim[2]<minMaxTrim[1]){
                   ~^~

R/ipf.r:593:35: style: There should be a space between right parenthesis and an opening curly brace.

if(minMaxTrim[2]<minMaxTrim[1]){
                                  ^~

R/ipf.r:594:1: style: Lines should not be more than 80 characters.

​      stop("minMaxTrim must have a minimum as a first element and a maximum as a second element.
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/ipf.r:628:1: style: Trailing whitespace is superfluous.

^~~~

R/ipf.r:629:7: style: Place a space before left parenthesis, except in a function call.

if(!hid%in%colnames(dat)){
      ^

R/ipf.r:629:12: style: Put spaces around all infix operators.

if(!hid%in%colnames(dat)){
          ~^~~~~

R/ipf.r:629:29: style: There should be a space between right parenthesis and an opening curly brace.

if(!hid%in%colnames(dat)){
                            ^~

R/ipf.r:630:43: style: Commas should always have a space after.

​      stop("dat does not contain column ",hid)
                                          ^

R/ipf.r:632:1: style: Trailing whitespace is superfluous.

^~~~

R/ipf.r:633:7: style: Place a space before left parenthesis, except in a function call.

if(any(is.na(dat[[hid]]))){
      ^

R/ipf.r:633:30: style: There should be a space between right parenthesis and an opening curly brace.

if(any(is.na(dat[[hid]]))){
                             ^~

R/ipf.r:636:1: style: Trailing whitespace is superfluous.

^~~~

R/kishFactor.R:11:1: style: Lines should not be more than 80 characters.

#' @details The factor is computed acording to 'Weighting for Unequal P_i', Leslie Kish, Journal of Official Statistics, Vol. 8. No. 2, 1992
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/recalib.R:214:5: style: Place a space before left parenthesis, except in a function call.

if(!is.null(names(conP))){
    ^

R/recalib.R:214:27: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.null(names(conP))){
                          ^~

R/recalib.R:216:58: style: Put spaces around all infix operators.

conPnamesNumeric <- conPnamesNumeric[conPnamesNumeric!=""]
                                                        ~^~~

R/recalib.R:222:7: style: Place a space before left parenthesis, except in a function call.

if(!is.null(names(conH))){
      ^

R/recalib.R:222:29: style: There should be a space between right parenthesis and an opening curly brace.

if(!is.null(names(conH))){
                            ^~

R/recalib.R:224:60: style: Put spaces around all infix operators.

conHnamesNumeric <- conHnamesNumeric[conHnamesNumeric!=""]
                                                          ~^~~

R/rescaled.bootstrap.R:172:1: style: Trailing whitespace is superfluous.

^~~~

R/rescaled.bootstrap.R:174:8: style: Place a space before left parenthesis, except in a function call.

for(i in seq_along(strata)){
       ^

R/rescaled.bootstrap.R:174:31: style: There should be a space between right parenthesis and an opening curly brace.

for(i in seq_along(strata)){
                              ^~

R/rescaled.bootstrap.R:175:9: style: Place a space before left parenthesis, except in a function call.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
        ^

R/rescaled.bootstrap.R:175:20: style: Put spaces around all infix operators.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                  ~^~~~~

R/rescaled.bootstrap.R:175:30: style: Commas should always have a space after.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                             ^

R/rescaled.bootstrap.R:175:48: style: Put spaces around all infix operators.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                                              ~^~~~~

R/rescaled.bootstrap.R:175:58: style: Commas should always have a space after.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                                                         ^

R/rescaled.bootstrap.R:175:62: style: There should be a space between right parenthesis and an opening curly brace.

if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
                                                             ^~

R/rescaled.bootstrap.R:176:1: style: Lines should not be more than 80 characters.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=.(",cluster[i],")][V1>1]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/rescaled.bootstrap.R:176:50: style: Commas should always have a space after.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=.(",cluster[i],")][V1>1]")
                                                 ^

R/rescaled.bootstrap.R:176:60: style: Commas should always have a space after.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=.(",cluster[i],")][V1>1]")
                                                           ^

R/rescaled.bootstrap.R:176:70: style: Commas should always have a space after.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=.(",cluster[i],")][V1>1]")
                                                                     ^

R/rescaled.bootstrap.R:176:81: style: Commas should always have a space after.

countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=.(",cluster[i],")][V1>1]")
                                                                                ^

R/rescaled.bootstrap.R:177:11: style: Place a space before left parenthesis, except in a function call.

if(nrow(countMultiple)>0){
          ^

R/rescaled.bootstrap.R:177:31: style: Put spaces around all infix operators.

if(nrow(countMultiple)>0){
                             ~^~

R/rescaled.bootstrap.R:177:33: style: There should be a space between right parenthesis and an opening curly brace.

if(nrow(countMultiple)>0){
                                ^~

R/rescaled.bootstrap.R:178:1: style: Lines should not be more than 80 characters.

​          stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/rescaled.bootstrap.R:178:42: style: Commas should always have a space after.

​          stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
                                         ^

R/rescaled.bootstrap.R:178:53: style: Commas should always have a space after.

​          stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
                                                    ^

R/rescaled.bootstrap.R:178:85: style: Commas should always have a space after.

​          stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
                                                                                    ^

R/rescaled.bootstrap.R:182:1: style: Trailing whitespace is superfluous.

^~~~

R/rescaled.bootstrap.R:247:34: style: Commas should always have a space after.

by.val.tail <- tail(by.val,1)
                                 ^

R/rescaled.bootstrap.R:264:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/rescaled.bootstrap.R:269:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/rescaled.bootstrap.R:272:11: style: Place a space before left parenthesis, except in a function call.

if(any(is.na(next.PSU[[new.var]]))){
          ^

R/rescaled.bootstrap.R:272:43: style: There should be a space between right parenthesis and an opening curly brace.

if(any(is.na(next.PSU[[new.var]]))){
                                          ^~

R/rescaled.bootstrap.R:273:13: style: Place a space before left parenthesis, except in a function call.

if(firstStage){
            ^

R/rescaled.bootstrap.R:273:24: style: There should be a space between right parenthesis and an opening curly brace.

if(firstStage){
                       ^~

R/rescaled.bootstrap.R:274:1: style: Lines should not be more than 80 characters.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",higher.stages,",1)]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/rescaled.bootstrap.R:274:39: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",higher.stages,",1)]")
                                      ^

R/rescaled.bootstrap.R:274:47: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",higher.stages,",1)]")
                                              ^

R/rescaled.bootstrap.R:274:69: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",higher.stages,",1)]")
                                                                    ^

R/rescaled.bootstrap.R:274:83: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",higher.stages,",1)]")
                                                                                  ^

R/rescaled.bootstrap.R:276:1: style: Lines should not be more than 80 characters.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",by.val.tail,",1),by=c(higher.stages)]")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/rescaled.bootstrap.R:276:39: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",by.val.tail,",1),by=c(higher.stages)]")
                                      ^

R/rescaled.bootstrap.R:276:47: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",by.val.tail,",1),by=c(higher.stages)]")
                                              ^

R/rescaled.bootstrap.R:276:69: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",by.val.tail,",1),by=c(higher.stages)]")
                                                                    ^

R/rescaled.bootstrap.R:276:81: style: Commas should always have a space after.

​            dt.eval("next.PSU[is.na(",new.var,"),c(new.var):=head(",by.val.tail,",1),by=c(higher.stages)]")
                                                                                ^

R/rescaled.bootstrap.R:279:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/rescaled.bootstrap.R:281:50: style: Commas should always have a space after.

next.PSU <- dt.eval("next.PSU[N == 1 | ",new.var," == ",by.val.tail,"]")
                                                 ^

R/rescaled.bootstrap.R:281:58: style: Commas should always have a space after.

next.PSU <- dt.eval("next.PSU[N == 1 | ",new.var," == ",by.val.tail,"]")
                                                         ^

R/rescaled.bootstrap.R:281:65: style: Commas should always have a space after.

next.PSU <- dt.eval("next.PSU[N == 1 | ",new.var," == ",by.val.tail,"]")
                                                                ^

R/rescaled.bootstrap.R:281:77: style: Commas should always have a space after.

next.PSU <- dt.eval("next.PSU[N == 1 | ",new.var," == ",by.val.tail,"]")
                                                                            ^

R/rescaled.bootstrap.R:284:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/rescaled.bootstrap.R:288:31: style: Commas should always have a space after.

​        dt.eval("dat[!is.na(",new.var,"),c(fpc.i_ADD) := 
                              ^

R/rescaled.bootstrap.R:288:39: style: Commas should always have a space after.

​        dt.eval("dat[!is.na(",new.var,"),c(fpc.i_ADD) := 
                                      ^

R/rescaled.bootstrap.R:288:57: style: Trailing whitespace is superfluous.

​        dt.eval("dat[!is.na(",new.var,"),c(fpc.i_ADD) := 
                                                        ^

R/rescaled.bootstrap.R:289:23: style: Commas should always have a space after.

​                sum(",fpc.i_ADD,"[!duplicated(",by.val.tail,")]),
                      ^

R/rescaled.bootstrap.R:289:33: style: Commas should always have a space after.

​                sum(",fpc.i_ADD,"[!duplicated(",by.val.tail,")]),
                                ^

R/rescaled.bootstrap.R:289:49: style: Commas should always have a space after.

​                sum(",fpc.i_ADD,"[!duplicated(",by.val.tail,")]),
                                                ^

R/rescaled.bootstrap.R:289:61: style: Commas should always have a space after.

​                sum(",fpc.i_ADD,"[!duplicated(",by.val.tail,")]),
                                                            ^

R/rescaled.bootstrap.R:293:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/rescaled.bootstrap.R:296:71: style: Commas should always have a space after.

​        dt.eval("dat[!is.na(", new.var, "),", fpc[i], ":=", fpc.i_ADD,"]")
                                                                      ^

R/rescaled.bootstrap.R:297:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/rescaled.bootstrap.R:317:1: style: Lines should not be more than 80 characters.

")),by=c(by.val)][V1==1,.(",paste(by.val,collapse=","),")]"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/rescaled.bootstrap.R:317:51: style: Commas should always have a space after.

")),by=c(by.val)][V1==1,.(",paste(by.val,collapse=","),")]"))
                                                  ^

R/rescaled.bootstrap.R:317:64: style: Commas should always have a space after.

")),by=c(by.val)][V1==1,.(",paste(by.val,collapse=","),")]"))
                                                               ^

R/rescaled.bootstrap.R:317:72: style: Put spaces around all infix operators.

")),by=c(by.val)][V1==1,.(",paste(by.val,collapse=","),")]"))
                                                                      ~^~

R/rescaled.bootstrap.R:317:78: style: Commas should always have a space after.

")),by=c(by.val)][V1==1,.(",paste(by.val,collapse=","),")]"))
                                                                             ^

tests/testthat/test_ipf.R:145:1: style: Lines should not be more than 80 characters.

eusilc, hid = "hid", conP = list(conP1, conP2), conH = list(conH1,conH1,conH1),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:145:71: style: Commas should always have a space after.

eusilc, hid = "hid", conP = list(conP1, conP2), conH = list(conH1,conH1,conH1),
                                                                      ^

tests/testthat/test_ipf.R:145:77: style: Commas should always have a space after.

eusilc, hid = "hid", conP = list(conP1, conP2), conH = list(conH1,conH1,conH1),
                                                                            ^

tests/testthat/test_ipf.R:146:40: style: Commas should always have a space after.

epsP = c(1e-06), epsH = list(epsH1,1e-06), w = "baseWeight", bound = 4,
                                       ^

tests/testthat/test_ipf.R:148:1: style: Lines should not be more than 80 characters.

regexp = "Provided household eps argument does not fit household constraints.")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:152:41: style: Commas should always have a space after.

epsP = c(1e-06), epsH = list(epsH1[,1:8]), w = "baseWeight", bound = 4,
                                        ^

tests/testthat/test_ipf.R:154:1: style: Lines should not be more than 80 characters.

regexp = "Provided household eps argument 1 does not fit in dimension to  household constraints 1 .")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:157:1: style: Lines should not be more than 80 characters.

eusilc, hid = "hid", conP = list(conP1, conP2), conH = list(conH1,conH1,conH1),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:157:71: style: Commas should always have a space after.

eusilc, hid = "hid", conP = list(conP1, conP2), conH = list(conH1,conH1,conH1),
                                                                      ^

tests/testthat/test_ipf.R:157:77: style: Commas should always have a space after.

eusilc, hid = "hid", conP = list(conP1, conP2), conH = list(conH1,conH1,conH1),
                                                                            ^

tests/testthat/test_ipf.R:158:1: style: Lines should not be more than 80 characters.

epsP = c(1e-06,22), epsH = list(epsH1,1e-06,1e-6), w = "baseWeight", bound = 4,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:158:20: style: Commas should always have a space after.

epsP = c(1e-06,22), epsH = list(epsH1,1e-06,1e-6), w = "baseWeight", bound = 4,
                   ^

tests/testthat/test_ipf.R:158:43: style: Commas should always have a space after.

epsP = c(1e-06,22), epsH = list(epsH1,1e-06,1e-6), w = "baseWeight", bound = 4,
                                          ^

tests/testthat/test_ipf.R:158:49: style: Commas should always have a space after.

epsP = c(1e-06,22), epsH = list(epsH1,1e-06,1e-6), w = "baseWeight", bound = 4,
                                                ^

tests/testthat/test_ipf.R:160:1: style: Lines should not be more than 80 characters.

regexp = "Individual eps arguments for each constraints must be defined as list.")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:170:56: style: Commas should always have a space after.

verbose = FALSE, maxIter = 200, minMaxTrim = c(450,700))
                                                       ^

tests/testthat/test_ipf.R:178:1: style: Lines should not be more than 80 characters.

​  expect_true(all(calibweights2$calibWeight<=700)&&all(calibweights2$calibWeight>=450))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:178:44: style: Put spaces around all infix operators.

​  expect_true(all(calibweights2$calibWeight<=700)&&all(calibweights2$calibWeight>=450))
                                          ~^~~

tests/testthat/test_ipf.R:178:50: style: Put spaces around all infix operators.

​  expect_true(all(calibweights2$calibWeight<=700)&&all(calibweights2$calibWeight>=450))
                                                ~^~~

tests/testthat/test_ipf.R:178:81: style: Put spaces around all infix operators.

​  expect_true(all(calibweights2$calibWeight<=700)&&all(calibweights2$calibWeight>=450))
                                                                               ~^~~

tests/testthat/test_ipf.R:186:56: style: Commas should always have a space after.

verbose = FALSE, maxIter = 200, minMaxTrim = c(340,870))
                                                       ^

tests/testthat/test_ipf.R:196:1: style: Lines should not be more than 80 characters.

​  expect_true(all(calibweights2$calibWeight<=870)&&all(calibweights2$calibWeight>=340))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test_ipf.R:196:44: style: Put spaces around all infix operators.

​  expect_true(all(calibweights2$calibWeight<=870)&&all(calibweights2$calibWeight>=340))
                                          ~^~~

tests/testthat/test_ipf.R:196:50: style: Put spaces around all infix operators.

​  expect_true(all(calibweights2$calibWeight<=870)&&all(calibweights2$calibWeight>=340))
                                                ~^~~

tests/testthat/test_ipf.R:196:81: style: Put spaces around all infix operators.

​  expect_true(all(calibweights2$calibWeight<=870)&&all(calibweights2$calibWeight>=340))
                                                                               ~^~~

vignettes/error_estimation.Rmd:42:1: style: Lines should not be more than 80 characters.

dat_boot_calib[1:5, .(year, povertyRisk, eqIncome, onePerson, pWeight, w1, w2, w3, w4, w5)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/error_estimation.Rmd:54:1: style: Lines should not be more than 80 characters.

povertyRate <- calc.stError(dat_boot_calib, var = "povertyRisk", fun = weightedRatio)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/error_estimation.Rmd:83:8: style: Put spaces around all infix operators.

​  sum(x*w)
      ~^~

vignettes/error_estimation.Rmd:87:1: style: Lines should not be more than 80 characters.

totalIncome2 <- calc.stError(dat_boot_calib, var = "eqIncome", fun = myWeightedSum)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/error_estimation.Rmd:101:1: style: Lines should not be more than 80 characters.

multipleRates <- calc.stError(dat_boot_calib, var = c("povertyRisk", "onePerson"), fun = weightedRatio)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/error_estimation.Rmd:124:1: style: Lines should not be more than 80 characters.

povertyRates <- calc.stError(dat2, var = "povertyRisk", fun = weightedRatio, group = "region")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/error_estimation.Rmd:148:77: style: Trailing whitespace is superfluous.

povertyRates <- calc.stError(dat2, var = "povertyRisk", fun = weightedRatio, 
                                                                            ^

vignettes/error_estimation.Rmd:162:77: style: Trailing whitespace is superfluous.

povertyRates <- calc.stError(dat2, var = "povertyRisk", fun = weightedRatio, 
                                                                            ^

vignettes/error_estimation.Rmd:180:77: style: Trailing whitespace is superfluous.

povertyRates <- calc.stError(dat2, var = "povertyRisk", fun = weightedRatio, 
                                                                            ^

vignettes/error_estimation.Rmd:181:1: style: Lines should not be more than 80 characters.

group = list("gender", "region", c("gender", "region")))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/ipf.Rmd:34:47: style: Put spaces around all infix operators.

pop_sample <- population[sample(1:.N, floor(.N*0.10)), ]
                                             ~^~

vignettes/ipf.Rmd:116:1: style: Lines should not be more than 80 characters.

pop_sample_c2 <- ipf(pop_sample, conP = list(con_ga, registry_table), w = "pWeight")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/runtimeTests.R:8:1: style: Lines should not be more than 80 characters.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vignettes/runtimeTests.R:8:36: style: Commas should always have a space after.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
                                   ^

vignettes/runtimeTests.R:8:39: style: Put spaces around all infix operators.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
                                     ~^~

vignettes/runtimeTests.R:8:45: style: Commas should always have a space after.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
                                            ^

vignettes/runtimeTests.R:8:48: style: Put spaces around all infix operators.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
                                              ~^~

vignettes/runtimeTests.R:8:57: style: Commas should always have a space after.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
                                                        ^

vignettes/runtimeTests.R:8:64: style: Put spaces around all infix operators.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
                                                              ~^~

vignettes/runtimeTests.R:8:73: style: Commas should always have a space after.

dat_boot <- draw.bootstrap(eusilc,REP=1000,hid="db030",weights="rb050",strata=c("db040"),
                                                                        ^

Please sign in to comment.