diff --git a/DESCRIPTION b/DESCRIPTION index 0b48ed1..ad90012 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: spatPomp Type: Package Title: Inference for Spatiotemporal Partially Observed Markov Processes -Version: 0.34.6 -Date: 2024-05-12 +Version: 0.34.7 +Date: 2024-05-13 Authors@R: c( person("Kidus", "Asfaw", email = "kidusasfaw1990@gmail.com", role = c("aut")), person("Edward", "Ionides", email = "ionides@umich.edu",role = c("cre","aut")), diff --git a/R/as_data_frame.R b/R/as_data_frame.R index b0aa632..423ccb5 100644 --- a/R/as_data_frame.R +++ b/R/as_data_frame.R @@ -58,10 +58,11 @@ setAs( # convert to long format with column for stateobscovars no_time_colnames <- colnames(dat)[-1] shared_covnames_ix <- which(no_time_colnames %in% from@shared_covarnames) - if(length(shared_covnames_ix) > 0) + if(length(shared_covnames_ix) > 0) { to_gather <- no_time_colnames[-shared_covnames_ix] - else - to_gather <- no_time_colnames + stop(paste('in', sQuote('as.data.frame'), + ": shared covariates are not yet fully implemented in spatPomp")) + } else to_gather <- no_time_colnames to_arrange <- rlang::syms(c(timename, unitname, "stateobscovars")) to_final_select <- c(timename, unitname, unit_stateobscovars) gathered <- dat %>% diff --git a/tests/bm.R b/tests/bm.R index 91a288d..0f4ebe2 100644 --- a/tests/bm.R +++ b/tests/bm.R @@ -717,7 +717,7 @@ try(spatPomp(data=b_data,times="time",units="unit",t0=0, b_shared_covar <- data.frame(time=0:2,Z=3:5) model_shared_covar <- spatPomp(data=b_data,times="time",units="unit", t0=0,covar=b_shared_covar, shared_covarnames="Z") -as.data.frame(b_shared_covar) +try(as.data.frame(model_shared_covar)) b_unit_covar <- data.frame(time=c(0:2,0:2),unit=rep(c("U1","U2"),each=3), Z=rep(3:5,times=2)) diff --git a/tests/bm.Rout.save b/tests/bm.Rout.save index 08da44e..f5a3d10 100644 --- a/tests/bm.Rout.save +++ b/tests/bm.Rout.save @@ -1,7 +1,7 @@ R version 4.4.0 (2024-04-24) -- "Puppy Cup" Copyright (C) 2024 The R Foundation for Statistical Computing -Platform: aarch64-apple-darwin20 +Platform: x86_64-apple-darwin20 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -1132,11 +1132,9 @@ Error : in ‘spatPomp’: for unit-specific covariates, there should be a colum > b_shared_covar <- data.frame(time=0:2,Z=3:5) > model_shared_covar <- spatPomp(data=b_data,times="time",units="unit", + t0=0,covar=b_shared_covar, shared_covarnames="Z") -> as.data.frame(b_shared_covar) - time Z -1 0 3 -2 1 4 -3 2 5 +> try(as.data.frame(model_shared_covar)) +Error in asMethod(object) : + in ‘as.data.frame’ : shared covariates are not yet fully implemented in spatPomp > > b_unit_covar <- data.frame(time=c(0:2,0:2),unit=rep(c("U1","U2"),each=3), + Z=rep(3:5,times=2)) diff --git a/tests/measles.R b/tests/measles.R index 0e96874..56e2116 100644 --- a/tests/measles.R +++ b/tests/measles.R @@ -40,7 +40,10 @@ logLik(m2_pf) ## i.e., cohort=0. ## -## A call to igirf using the moment-based guide function can test compiled code for eunit_measure, munit_measure, vunit_measure, dunit_measure, runit_measure, rprocess, skeleton, rinit and partrans. +## A call to igirf using the moment-based guide function can test +## compiled code for eunit_measure, munit_measure, vunit_measure, +## dunit_measure, runit_measure, rprocess, skeleton, rinit and partrans. +## It also tests igirf (method=moment) with covariates m3_params <- m_params m3_params["cohort"] <- 0 @@ -64,6 +67,10 @@ m3_igirf_out <- igirf(m_model, Ngirf = m3_igirf_ngirf, ) logLik(m3_igirf_out) +## another call to igirf tests igirf (method=bootstrap) with covariates +m3_igirf_bootstrap_out <- igirf(m3_igirf_out,kind='bootstrap') +logLik(m3_igirf_bootstrap_out) + ## test error message try(measles(U=1000)) diff --git a/tests/measles.Rout.save b/tests/measles.Rout.save index cf9aeb8..43476b3 100644 --- a/tests/measles.Rout.save +++ b/tests/measles.Rout.save @@ -1,7 +1,7 @@ R version 4.4.0 (2024-04-24) -- "Puppy Cup" Copyright (C) 2024 The R Foundation for Statistical Computing -Platform: aarch64-apple-darwin20 +Platform: x86_64-apple-darwin20 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -63,7 +63,10 @@ Loading required package: pomp > ## i.e., cohort=0. > ## > -> ## A call to igirf using the moment-based guide function can test compiled code for eunit_measure, munit_measure, vunit_measure, dunit_measure, runit_measure, rprocess, skeleton, rinit and partrans. +> ## A call to igirf using the moment-based guide function can test +> ## compiled code for eunit_measure, munit_measure, vunit_measure, +> ## dunit_measure, runit_measure, rprocess, skeleton, rinit and partrans. +> ## It also tests igirf (method=moment) with covariates > > m3_params <- m_params > m3_params["cohort"] <- 0 @@ -91,6 +94,16 @@ Warning messages: > logLik(m3_igirf_out) [1] -86380.55 > +> ## another call to igirf tests igirf (method=bootstrap) with covariates +> m3_igirf_bootstrap_out <- igirf(m3_igirf_out,kind='bootstrap') +Warning messages: +1: in 'table_lookup': extrapolating at 1.965003e+03. +2: in 'table_lookup': extrapolating at 1.965002e+03. +3: in 'table_lookup': extrapolating at 1.965002e+03. +4: in 'table_lookup': extrapolating at 1.965002e+03. +> logLik(m3_igirf_bootstrap_out) +[1] -86123.26 +> > ## test error message > try(measles(U=1000)) Error in measles(U = 1000) :