made modelServR compliant with Roxygen and R-package styling
- also changed age-distribution prior
This commit is contained in:
Родитель
ac56fce5b0
Коммит
d5883b56ca
|
@ -40,7 +40,7 @@ latentFieldModel <- function(db , shp, family = NULL, neighborGraph = NULL){
|
|||
hyper=list()
|
||||
hyper$global <- list(prec = list( prior = "pc.prec", param = 1/10, alpha = 0.01))
|
||||
hyper$local <- list(prec = list( prior = "pc.prec", param = 1/100, alpha = 0.01))
|
||||
hyper$age <- list(prec = list( prior = "pc.prec", param = 1/100, alpha = 0.01))
|
||||
hyper$age <- list(prec = list( prior = "pc.prec", param = 1, alpha = 0.01))
|
||||
hyper$time <- list(prec = list( prior = "pc.prec", param = 1/50, alpha = 0.01))
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ smoothModel <- function(db, shp, family = NULL, neighborGraph = NULL){
|
|||
hyper=list()
|
||||
hyper$global <- list(prec = list( prior = "pc.prec", param = 1/10, alpha = 0.01))
|
||||
hyper$local <- list(prec = list( prior = "pc.prec", param = 1/100, alpha = 0.01))
|
||||
hyper$age <- list(prec = list( prior = "pc.prec", param = 1/100, alpha = 0.01))
|
||||
hyper$age <- list(prec = list( prior = "pc.prec", param = 1, alpha = 0.01))
|
||||
|
||||
|
||||
# we smooth across factor levels with random effects replicates: http://www.r-inla.org/models/tools#TOC-Models-with-more-than-one-type-of-likelihood
|
||||
|
|
|
@ -57,9 +57,10 @@ for (SOURCE in names(geoLevels)){
|
|||
|
||||
saveModel(model)
|
||||
|
||||
dir.create('/home/rstudio/seattle_flu/plots/', showWarnings = FALSE)
|
||||
for(k in unique(model$modeledData[[FACTOR]])){
|
||||
tmp<-list(modeledData = model$modeledData[model$modeledData[[FACTOR]]==k,])
|
||||
fname <- paste('/home/rstudio/seattle_flu/data/plots/',paste(PATHOGEN,SOURCE,GEO,FACTOR,k,sep='-'),'.png',sep='')
|
||||
fname <- paste('/home/rstudio/seattle_flu/plots/',paste(PATHOGEN,SOURCE,GEO,FACTOR,k,sep='-'),'.png',sep='')
|
||||
png(filename = fname,width = 6, height = 5, units = "in", res = 300)
|
||||
print(ggplotSmoothMap(tmp,shp,title=k,shape_level = GEO))
|
||||
dev.off()
|
||||
|
@ -68,7 +69,6 @@ for (SOURCE in names(geoLevels)){
|
|||
}, error=function(e){cat("ERROR :",conditionMessage(e), "\n")}
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
plots
|
|
@ -11,10 +11,3 @@ License: What license it uses
|
|||
Encoding: UTF-8
|
||||
LazyData: true
|
||||
RoxygenNote: 6.1.1
|
||||
Suggest:
|
||||
testthat
|
||||
dbViewR
|
||||
Imports:
|
||||
digest,
|
||||
jsonlite,
|
||||
logging
|
|
@ -13,4 +13,5 @@ export(returnModel)
|
|||
export(saveModel)
|
||||
import(digest)
|
||||
import(jsonlite)
|
||||
import(logging)
|
||||
importFrom(jsonlite,toJSON)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
library(logging)
|
||||
basicConfig()
|
||||
|
||||
#' loadModelFileById function for getting modeled data
|
||||
#'
|
||||
#' This function will load a model from the model_store_dir by Id
|
||||
|
@ -39,29 +36,23 @@ loadModelFileById <- function (filename, model_store_dir = Sys.getenv('MODEL_STO
|
|||
#' @return model in requested format
|
||||
#'
|
||||
#' @import jsonlite
|
||||
#' @import logging
|
||||
#' @export
|
||||
#' @examples
|
||||
#'
|
||||
returnModel <- function(queryIn = jsonlite::toJSON(
|
||||
list(
|
||||
SELECT =list(COLUMN=c('sampling_location','residence_census_tract')),
|
||||
WHERE =list(COLUMN='sampling_location', IN = c('kiosk')),
|
||||
GROUP_BY =list(COLUMN=c('sampling_location','residence_census_tract')),
|
||||
SUMMARIZE=list(COLUMN='sampling_location', IN= c('kiosk'))
|
||||
SELECT =list(COLUMN=c('site_type','residence_census_tract')),
|
||||
WHERE =list(COLUMN='site_type', IN = c('kiosk')),
|
||||
GROUP_BY =list(COLUMN=c('site_type','residence_census_tract')),
|
||||
SUMMARIZE=list(COLUMN='site_type', IN= c('kiosk'))
|
||||
)),
|
||||
type = 'smooth',
|
||||
version = 'latest',
|
||||
cloudDir = Sys.getenv('MODEL_STORE', '/home/rstudio/seattle_flu/test_model_store')){
|
||||
|
||||
# https://www.dropbox.com/sh/5loj4x6j4tar17i/AABy5kP70IlYtSwrePg4m44Ca?dl=0
|
||||
|
||||
# need to solve paths problem for intalled packages!
|
||||
# ideally this would point to a web-based repository of models so that anyone can get to it.
|
||||
# THIS DOES NOT WORK because of authentication. Need to explore rdrop2 package!
|
||||
|
||||
# NEED TO Pull multiple formats of data once saving latent fields is implemented in incidenceMapR
|
||||
# ACTUALLY, current plan is to have csv obey format for each model type
|
||||
|
||||
basicConfig()
|
||||
|
||||
if(class(queryIn)== 'list'){
|
||||
queryList <- queryIn
|
||||
queryIn <- jsonlite::toJSON(queryIn)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
library(logging)
|
||||
basicConfig()
|
||||
setLevel("FINEST")
|
||||
|
||||
#' getHumanReadableModelIdFromModel: return human readable verion of model from query
|
||||
#'
|
||||
#' @param model INLA model object that will generatie id from
|
||||
|
@ -58,10 +54,15 @@ getModelQueryObjectFromModel<- function(model, model_type = 'inla', latent = FAL
|
|||
#'
|
||||
#' @param query query object container the observed and the model_type attributes
|
||||
#'
|
||||
#' @import logging
|
||||
#'
|
||||
#' @return An object containing the observed and the model_type fields
|
||||
#' @export
|
||||
#'
|
||||
getModelQueryObjectFromQuery <- function(query) {
|
||||
basicConfig()
|
||||
setLevel("FINEST")
|
||||
|
||||
logdebug("getModelQueryObjectFromQuery Src:", str(query))
|
||||
logdebug("$observed", attr(query, "observed"))
|
||||
result <- newEmptyObject()
|
||||
|
@ -86,11 +87,15 @@ getModelIdFromModel <- function(model) {
|
|||
#' @param query query object container the observed and the model_type attributes
|
||||
#'
|
||||
#' @import digest
|
||||
#' @import logging
|
||||
#' @importFrom jsonlite toJSON
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
getModelIdFromQuery <- function(query) {
|
||||
basicConfig()
|
||||
setLevel("FINEST")
|
||||
|
||||
#props <- getModelQueryObjectFromQuery(query)
|
||||
modelId <- as.character(jsonlite::toJSON(query, simplifyDataFrame=))
|
||||
logdebug("Model ID JSON:", jsonlite::toJSON(query, simplifyDataFrame=))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
% Please edit documentation in R/saveModel.R
|
||||
\name{getModelQueryObjectFromModel}
|
||||
\alias{getModelQueryObjectFromModel}
|
||||
\title{getModelQueryObjectFromModel: return query object from a model.
|
||||
\title{getModelQueryObjectFromModel: return query object from a model.
|
||||
This is the object we use to generate our unique ids.}
|
||||
\usage{
|
||||
getModelQueryObjectFromModel(model, model_type = "inla",
|
||||
|
@ -19,6 +19,6 @@ getModelQueryObjectFromModel(model, model_type = "inla",
|
|||
An object containing the observed and the model_type fields
|
||||
}
|
||||
\description{
|
||||
getModelQueryObjectFromModel: return query object from a model.
|
||||
getModelQueryObjectFromModel: return query object from a model.
|
||||
This is the object we use to generate our unique ids.
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ loadModelFileById(filename, model_store_dir = Sys.getenv("MODEL_STORE",
|
|||
"/home/rstudio/seattle_flu"), type = "csv")
|
||||
}
|
||||
\arguments{
|
||||
\item{filename}{= At moment we expect full filename in format ID.extension.
|
||||
\item{filename}{= At moment we expect full filename in format ID.extension.
|
||||
This is so in future we can more easily support different model save formats}
|
||||
|
||||
\item{model_store_dir}{= directory where models are stored}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
\title{returnModel function for getting modeled data}
|
||||
\usage{
|
||||
returnModel(queryIn = jsonlite::toJSON(list(SELECT = list(COLUMN =
|
||||
c("sampling_location", "GEOID")), WHERE = list(COLUMN =
|
||||
c("sampling_location", "residence_census_tract")), WHERE = list(COLUMN =
|
||||
"sampling_location", IN = c("kiosk")), GROUP_BY = list(COLUMN =
|
||||
c("sampling_location", "GEOID")), SUMMARIZE = list(COLUMN =
|
||||
"sampling_location", IN = c("kiosk")))), type = "smooth",
|
||||
c("sampling_location", "residence_census_tract")), SUMMARIZE =
|
||||
list(COLUMN = "sampling_location", IN = c("kiosk")))), type = "smooth",
|
||||
version = "latest", cloudDir = Sys.getenv("MODEL_STORE",
|
||||
"/home/rstudio/seattle_flu/test_model_store"))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче