Closed leungi closed 5 years ago
Just to clarify:
Thanks for prompt reply @config-i1.
My apologies for Q2; my mistake on the indexing 😅
To Q1, just upgraded to 0.5.0
, but same issue.
Reproducible example provided below.
library(greybox)
#> Warning: package 'greybox' was built under R version 3.5.3
#> Package "greybox", v0.5.0 loaded.
url <-'https://raw.githubusercontent.com/leungi/datasets/master/greybox_debug_data.csv'
data <- readr::read_csv(url)
#> Warning: Missing column names filled in: 'X1' [1]
#> Parsed with column specification:
#> cols(
#> .default = col_double()
#> )
#> See spec(...) for full column specifications.
# drop first index column
data <- data[ ,-1]
# check for NA
sum(is.na(data))
#> [1] 0
GreyboxModel <- function(data, model) {
switch(model,
stepwise = stepwise(data),
lmCombine = lmCombine(data, bruteForce = FALSE),
lmDynamic = lmDynamic(data, bruteForce = FALSE),
lmCombineBF = lmCombine(data, bruteForce = TRUE),
lmDynamicBF = lmDynamic(data, bruteForce = TRUE))
}
# OK
GreyboxModel(data, 'stepwise')
#> Call:
#> alm(formula = y ~ x2 + x6 + x3 + x8 + x22 + x5 + x15 + x26 +
#> x12 + x14 + x21 + x20 + x9 + x19 + x4 + x13 + x11, data = data,
#> distribution = "dnorm")
#>
#> Coefficients:
#> (Intercept) x2 x6 x3 x8
#> 2.582548e-01 9.186865e-03 -4.949338e-04 -2.322507e-03 1.800258e-04
#> x22 x5 x15 x26 x12
#> -5.668228e-04 7.809159e-03 3.078416e-03 2.716742e-03 8.008150e-04
#> x14 x21 x20 x9 x19
#> 3.360904e-04 5.892103e-06 3.963442e-05 2.614113e-03 2.833173e-04
#> x4 x13 x11
#> -3.453556e-03 -4.095078e-03 4.601871e-03
# OK
GreyboxModel(data, 'lmDynamic')
#> Call:
#> lmDynamic(data = data, bruteForce = FALSE, formula = y ~ .)
#>
#> Coefficients:
#> (Intercept) x1 x2 x3 x4
#> 2.275600e-01 1.437598e-10 9.056750e-03 -2.242035e-03 -3.163102e-03
#> x5 x6 x7 x8 x9
#> 7.583379e-03 -4.518065e-04 1.844128e-07 1.955973e-04 2.565518e-03
#> x10 x11 x12 x13 x14
#> 9.390505e-10 4.292303e-03 1.049070e-03 -3.451540e-03 3.436896e-04
#> x15 x16 x17 x18 x19
#> 3.153094e-03 -1.651838e-09 4.594412e-05 4.423451e-08 2.403370e-04
#> x20 x21 x22 x23 x24
#> 4.107177e-05 -8.106787e-06 -4.584408e-04 -5.177786e-08 2.545252e-10
#> x25 x26
#> 1.061938e-10 1.910200e-03
# OK
GreyboxModel(data[1:1000,], 'lmCombine')
#> Call:
#> lmCombine(data = data, bruteForce = FALSE, formula = y ~ .)
#>
#> Coefficients:
#> (Intercept) x2 x11 x6 x8
#> 0.4141842032 0.0103885068 0.0031874725 -0.0004520585 0.0002475515
#> x9 x5 x15 x13 x19
#> 0.0025322978 0.0074380731 0.0031228157 -0.0033085031 0.0002062875
# error
GreyboxModel(data, 'lmCombine')
#> Error in logLik(ourModel): object 'ourModel' not found
# error
GreyboxModel(data[1:1300,], 'lmCombine')
#> Error in logLik(ourModel): object 'ourModel' not found
sessionInfo()
#> R version 3.5.1 (2018-07-02)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17134)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_United States.1252
#> [2] LC_CTYPE=English_United States.1252
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United States.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] greybox_0.5.0
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.1 urca_1.3-0 nloptr_1.2.1
#> [4] compiler_3.5.1 pillar_1.3.1 plyr_1.8.4
#> [7] highr_0.8 xts_0.11-2 tseries_0.10-45
#> [10] tools_3.5.1 digest_0.6.18 nlme_3.1-137
#> [13] evaluate_0.13 tibble_2.1.1 gtable_0.3.0
#> [16] lattice_0.20-38 pkgconfig_2.0.2 rlang_0.3.4
#> [19] curl_3.3 yaml_2.2.0 parallel_3.5.1
#> [22] xfun_0.5.2 stringr_1.4.0 dplyr_0.8.0.1
#> [25] knitr_1.22 hms_0.4.2 uroot_2.0-9
#> [28] lmtest_0.9-36 grid_3.5.1 nnet_7.3-12
#> [31] forecast_8.4 tidyselect_0.2.5 glue_1.3.1
#> [34] R6_2.4.0 lamW_1.3.0 rmarkdown_1.12
#> [37] readr_1.3.1 TTR_0.23-4 ggplot2_3.1.0
#> [40] purrr_0.3.2 magrittr_1.5 scales_1.0.0
#> [43] htmltools_0.3.6 quantmod_0.4-13 assertthat_0.2.1
#> [46] timeDate_3043.102 colorspace_1.4-1 numDeriv_2016.8-1
#> [49] fracdiff_1.4-2 quadprog_1.5-5 stringi_1.4.3
#> [52] RcppParallel_4.4.2 lazyeval_0.2.2 munsell_0.5.0
#> [55] crayon_1.3.4 zoo_1.8-4
Created on 2019-04-23 by the reprex package (v0.2.1)
Thanks for the detailed explanation! This is now fixed in v0.5.041002 on github: 78bfb9e24a987b9841bad37d3edb091fde4ac963
Awesome; thanks for the quick fix! 👍
As per subject; example shown below.
Using
greybox_0.4.1
.