R/get_goldDatasetStd.R

Defines functions get_goldDatasetStd

Documented in get_goldDatasetStd

#' @title get_goldDatasetStd
#' @description Esta es una funcion que construye el goldDataSet de estudiantes
#' @details Esta funcion es parte del paquete PFS-kit
#' La funcion recibe dos dataframes con las respuestas de los cuestionarios cognitivo
#' y contextual del examen PISA for Schools y calcula los parametros contextuales y
#' valores plausibles y los pesos para las replicas por alumno.
#' @examples
#' Q_context<-read_csv("data/input_pfs_context_mex_2018.csv")
#' Q_cognitive<-read_csv("data/input_pfs_cognitive_mex_2018.csv")
#' goldData<-get_goldDatasetStd(Q_context,Q_cognitive)
#' @export
get_goldDatasetStd<-function(
  Q_context,
  Q_cognitive
){
  indicescontext<-apply_model(Q_context)
  HISEI<-get_HISEI()
  PARED<-get_PARED(Q_context)
  HOMEPOS<-get_HOMEPOS(Q_context)
  AGE<-get_AGE(Q_context)
  ESCS<-get_ESCS(Q_context)
  PV<-get_PV(Q_cognitive,Q_context)
  RDP<-get_readerpf(Q_context)
  goldDataset1<-indicescontext%>%
    inner_join(HISEI%>%select(stidstd,HISEI,BFMJ1,BMMJ1),by="stidstd")%>%
    inner_join(PARED%>%select(stidstd,MISCED,FISCED,HISCED,PARED),by="stidstd")%>%
    inner_join(HOMEPOS,by="stidstd")%>%
    inner_join(AGE%>%select(stidstd,AGE),by="stidstd")%>%
    inner_join(ESCS%>%select(stidstd,ESCS),by="stidstd")%>%
    inner_join(PV,by="stidstd")%>%
    inner_join(RDP,by="stidstd")
  indnames<-intersect(colnames(goldDataset1%>%select(-stidstd)),
                      colnames(Q_context))
  goldDataset2<-Q_context%>%select(-indnames)
  goldDataset3<-inner_join(goldDataset2,goldDataset1,by="stidstd")
  print("--------")
  LEV<-estimate_levels(goldDataset3)
  print("--------1")
  goldDataset<-inner_join(goldDataset3,LEV)
  print("--------2")
  return(goldDataset)
}
knotion/PFSkit documentation built on Feb. 12, 2020, 12:16 p.m.