computeProbs: Compute error probabilities according to the error model and...

Description Usage Arguments Value Examples

Description

Compute error probabilities according to the error model and units ordered by priority

Usage

1
2
3
4
computeProbs(object, na.as.category)

## S4 method for signature 'categObsPredModelParam,logical'
computeProbs(object, na.as.category = FALSE)

Arguments

object

Object of class categObsPredModelParam.

na.as.category

logical with default to FALSE to deal with NA values in the model. If TRUE the missing values are treated as a new category.

Value

A categObsPredModelParam with the new slot probs with the following columns:

  1. Identification variables for each unit in the input data set

  2. One per regressor

  3. Error probabilities

  4. The priority based on error probabilities for each of units

  5. Error moments

  6. The priority based on error moments for each of units

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
object <- readRDS("R:/USIE/Proyecto_DepSel_VarQual/categ_RF_simulacion/PC/RDS/ObsPredPar1.rds")
poolDD <- getDD(object@Data)
regressors <- getRegressors(object)  
targetVars <- getRegressands(object)
id.vars <- object@VarRoles$Units  
vars <- c(id.vars,targetVars,regressors)
data.dt <- object@Test$data
data.dt[c(1:3,10:16), NivelEstudios_35._2.1.4.:= NA ] 
data.dt[c(4:7,17:22), Edad_05._2.1.5.1.:= NA]        
# Provocamos un nivel distinto en "SitEmpleo_35._2.1.5.1._"  
data.dt[c(30:49), SitEmpleo_35._2.1.5.1._ := rep(c('8', '9'), 10)] 
data.dt[c(23:35), Sexo_04._2.1.5.1. := '4'] 
data.StQ <- melt_StQ(data.dt[,..vars], poolDD)
object@Data <- data.StQ
object2 <- computeProbs(object)
  
  # Dividimos el conjunto de datos en tres: 
  # (i) con missing en alguna variable numérica, 
  # (ii) con niveles nuevos en alguna variable categórica
  # (iii) el resto, donde se imputa NAs a valor *
  # (i) y (ii) se imputan probError a 1
  # (iii) se aplica el modelo ajustado y se computan probabilidades
  # Se vuelven a combinar los datsets y se computan momentos de error y prioridades

  # Provocamos missing en  "NivelEstudios_35._2.1.4." y "Edad_05._2.1.5.1."  
currentData.dt[c(1:3,10:16), NivelEstudios_35._2.1.4.:=NA] 
currentData.dt[c(4:7,17:22), Edad_05._2.1.5.1.:=NA]        
  # Provocamos un nivel distinto en "SitEmpleo_35._2.1.5.1._"  
currentData.dt[c(30:49), SitEmpleo_35._2.1.5.1._:='8'] 

## End(Not run)

david-salgado/categObsPredModelParam documentation built on Dec. 3, 2020, 1:42 p.m.