rm(list = ls())

rm(list=lsf.str()) #remove functions only

library(pbapply, quietly = TRUE)

setwd("C:/Users/nathan.green/Documents/chlamydia/classifier")   #PHE homedrive
# setwd("E:/NGreen/Chlamydia/classifier")   #usb


## data preprocessing and cleaning functions
source("./R_code/Chlamydia_classifier/sim_logistic_regn/classifier_fns.R")

SETUP

Load-in functions, raw data and preprocess for analysis

# source("./data_config.R")
setwd("./R_code/Chlamydia_classifier/sim_logistic_regn/workspaces/config")
load(file = file.choose())
setwd("../../../../../")

SIMULATE

Simulate LA populations as weighted random samples for use in NATSAL classifier prediction

## slow!
# source("./locallevel_pop_sim.R")

## res[[...]]
# load(file=file.choose())
load("./data/output/LAsim/LAsim_submodel_1634_n10000.RData") #output
# load("./data/output/LAsim/LAsim_submodel_1624_n10000.RData")

MODEL FIT

STI risk factor regression/classifier of NATSAL data

# source("./model_fitting.R")   ## deprecated

# data.covshift <- pblapply(res, function(x) covariateShift(data[1:10000,], resla=x, riskfac))
# fit.model <- c(pblapply(data.covshift, function(x) fitModel(x, x, riskfac, depvar="cttestly")), res=list(res))

## slow!l
setwd("./data/output/fitmodel")
load(file = file.choose())
setwd("../../../")

PREDICT

Regression prediction using simulated LA populations takes the model fits from riskfactor_regn

# source("./classpredict.R")
# temp <- classPredict(fit.model, drink0=FALSE)

setwd("./data/output/predictions")
load(file = file.choose())
setwd("../../../")

COMPARE

Compare the estimated coverage from the classifiers against the observed coverages

# source("PLOTS_estimate_vs_data.R")
# source("MAPS_estimate_vs_data.R")


n8thangreen/STIecoPredict documentation built on June 7, 2020, 12:50 p.m.