The response for family[1] is not of type 'numeric|list|matrix'; don't know what to do.> str(data) 'data.frame': 19348 obs. of 24 variables: $ race : Factor w/ 2 levels "0","1": 2 2 1 2 2 2 1 2 1 2 ... $ gender : Factor w/ 2 levels "0","1": 1 2 1 1 1 2 1 1 2 1 ... $ ga : int 37 37 38 38 40 37 34 36 36 36 ...
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
b0 -3.6931 18.4548 -39.9177 -3.7010 32.5429 -3.7111 0
bw -0.0965 0.0880 -0.2708 -0.0960 0.0749 -0.0950 0
ga -0.2031 0.0812 -0.3610 -0.2037 -0.0423 -0.2047 0
gender0 -1.8084 18.3103 -37.7563 -1.8101 34.1160 -1.8118 0
gender1 -1.8113 18.3103 -37.7592 -1.8130 34.1131 -1.8146 0
nicu1 0.2780 0.5175 -0.8355 0.3141 1.1975 0.3902 0
sti1 0.1152 0.1598 -0.2036 0.1169 0.4244 0.1203 0
parity 0.1663 0.0641 0.0375 0.1673 0.2894 0.1693 0
race1 0.9413 0.2340 0.4978 0.9355 1.4182 0.9236 0nicu0 -1.4892 18.2637 -37.3471 -1.4898 34.3387 -1.4892 0 nicu1 -1.1172 18.2644 -36.9763 -1.1177 34.7120 -1.1172 0It is also doing this now - it does not seem to be fully completing some of the models. This dataset has around 19,000 points and I'm predicting the model onto 4000 points in a grid:
It's now doing this unpredictably with other binary variables. I'm now getting this without having changed the model at all other than trying it without the "gender variable"
nicu0 -1.4892 18.2637 -37.3471 -1.4898 34.3387 -1.4892 0 nicu1 -1.1172 18.2644 -36.9763 -1.1177 34.7120 -1.1172 0
As you can see from my earlier post this large SE for nicu was not the case when the model had dropped one of the levels.
b0 -3.6553 18.2851 -39.5554 -3.6558 32.2145 -3.6552 0 bw -0.0967 0.0870 -0.2690 -0.0962 0.0727 -0.0952 0 ga -0.2030 0.0810 -0.3604 -0.2036 -0.0427 -0.2046 0 nicu0 -1.9052 18.2684 -37.7722 -1.9058 33.9318 -1.9052 0 nicu1 -1.7444 18.2707 -37.6161 -1.7449 34.0972 -1.7444 0 sti1 0.1151 0.1598 -0.2037 0.1168 0.4243 0.1202 0 parity 0.1661 0.0641 0.0374 0.1671 0.2892 0.1691 0 race1 0.9402 0.2343 0.4958 0.9344 1.4175 0.9227 0
This model is EXACTLY the same as the last one, but it's reporting bw, a continuous numeric variable, out like this.
Any idea what's happening here?
Fixed effects: mean sd 0.025quant 0.5quant 0.975quant mode kld b0 -50.9563 1.8694 -54.6782 -50.9388 -47.3338 -50.9036 0 bw-0.009863134 46.4362 1.9305 42.6835 46.4231 50.2591 46.3968 0 bw-0.030264237 46.7306 1.9178 43.0068 46.7161 50.5330 46.6871 0 bw-0.050665339 44.5188 2.1140 40.2870 44.5466 48.5945 44.6026 0 bw-0.071066442 46.4187 1.9305 42.6659 46.4056 50.2416 46.3793 0 bw-0.091467545 46.1417 1.9520 42.3390 46.1313 49.9985 46.1105 0 bw-0.111868647 46.7916 1.9088 43.0878 46.7764 50.5790 46.7458 0 bw-0.13226975 47.8266 1.8857 44.1728 47.8098 51.5740 47.7760 0 bw-0.152670853 46.1585 1.9520 42.3559 46.1481 50.0153 46.1273 0 bw-0.173071955 45.7362 1.9941 41.8313 45.7327 49.6574 45.7257 0 bw-0.193473058 46.2262 1.9301 42.4742 46.2130 50.0483 46.1868 0 bw-0.213874161 46.8210 1.9181 43.0967 46.8066 50.6240 46.7776 0 bw-0.234275263 46.7750 1.9179 43.0509 46.7605 50.5777 46.7316 0 bw-0.254676366 46.4789 1.9173 42.7562 46.4644 50.2803 46.4354 0 bw-0.275077469 46.6101 1.9175 42.8869 46.5957 50.4120 46.5667 0
> str(data) 'data.frame': 19348 obs. of 24 variables: $ id : int 2248 13062 551 561 322 86 1164 12850 1549 1638 ... $ long : num 616695 616149 618039 619041 619044 ... $ lat : num 249922 249673 240838 242066 241644 ... $ race : Factor w/ 2 levels "0","1": 2 2 1 2 2 2 1 2 1 2 ... $ gender : Factor w/ 2 levels "0","1": 1 2 1 1 1 2 1 1 2 1 ... $ ga : int 37 37 38 38 40 37 34 36 36 36 ... $ bw : num 2.31 2.34 2.53 3.26 3.76 3.21 1.68 2.27 2.33 2.56 ... $ nicu : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ... $ bw : num -2.07 -2.009 -1.622 -0.132 0.888 ...
$ parity : num 0.347 1.079 -0.385 0.347 -0.385 ... $ ga : num -1.646 -1.646 -0.925 -0.925 0.517 ...
> str(data) 'data.frame': 19348 obs. of 24 variables: $ id : int 2248 13062 551 561 322 86 1164 12850 1549 1638 ... $ long : num 616695 616149 618039 619041 619044 ... $ lat : num 249922 249673 240838 242066 241644 ... $ binrace : Factor w/ 2 levels "0","1": 2 2 1 2 2 2 1 2 1 2 ... $ MF : Factor w/ 2 levels "Female","Male": 1 2 1 1 1 2 1 1 2 1 ... $ gender : Factor w/ 2 levels "0","1": 1 2 1 1 1 2 1 1 2 1 ... $ ga : int 37 37 38 38 40 37 34 36 36 36 ... $ bw : num 2.31 2.34 2.53 3.26 3.76 3.21 1.68 2.27 2.33 2.56 ... $ nicu : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ... $ parity : int 2 3 1 2 1 5 2 2 1 1 ... $ sti : Factor w/ 2 levels "0","1": 1 1 1 1 2 1 1 1 2 1 ... $ As_Fail : int 0 0 1 1 1 1 0 0 0 0 ... $ Random : int 0 0 1 1 1 1 0 0 0 0 ... $ As_Pass : int 0 0 0 0 0 1 0 0 0 0 ... $ PF_0 : int 0 0 2 2 2 1 0 0 0 0 ... $ CMV_TESTED: Factor w/ 2 levels "N","Y": 1 1 1 1 1 1 1 1 1 1 ... $ CMV_TEST_R: Factor w/ 3 levels "","Negative",..: 1 1 1 1 1 1 1 1 1 1 ... $ ADI : num 0.987 0.987 0.302 0.302 0.302 ... $ bw_std : num -2.07 -2.009 -1.622 -0.132 0.888 ... $ adi_std : num 1.729 1.729 -0.475 -0.475 -0.475 ... $ parity_std: num 0.347 1.079 -0.385 0.347 -0.385 ... $ ga_std : num -1.646 -1.646 -0.925 -0.925 0.517 ... $ bgfips : num 3.71e+11 3.71e+11 3.71e+11 3.71e+11 3.71e+11 ... $ popsqmi : int 3397 3397 2125 2125 2125 2125 2125 2125 2125 2125 ...
lm(formula = Result ~ nicu, data = data)
Residuals:
Min 1Q Median 3Q Max
-0.05792 -0.03457 -0.03457 -0.03457 0.96543
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.034575 0.001328 26.035 <2e-16 ***
nicu1 0.023340 0.011478 2.033 0.042 * --
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To post to this group, send email to r-inla-disc...@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
b0 -50.9563 1.8694 -54.6782 -50.9388 -47.3338 -50.9036 0
bw-0.009863134 46.4362 1.9305 42.6835 46.4231 50.2591 46.3968 0
bw-0.030264237 46.7306 1.9178 43.0068 46.7161 50.5330 46.6871 0
bw-0.050665339 44.5188 2.1140 40.2870 44.5466 48.5945 44.6026 0
bw-0.071066442 46.4187 1.9305 42.6659 46.4056 50.2416 46.3793 0
bw-0.091467545 46.1417 1.9520 42.3390 46.1313 49.9985 46.1105 0
bw-0.111868647 46.7916 1.9088 43.0878 46.7764 50.5790 46.7458 0
bw-0.13226975 47.8266 1.8857 44.1728 47.8098 51.5740 47.7760 0
[ reached getOption("max.print") -- omitted 200 rows ]
When running with inla.stack, you also use expand.factor.strategy="inla", right?Also see Elias post, which showed what happens when the intercept is a regular covariates (as it must be for inla.stack to operate properly).Håvard, I think we need an expand.factor.strategy="inla0", meaning "drop the first level of every factor" (I think the current "inla" strategy does something different to that, that only works sensibly when there is a single factor in the model...).Paul, you can have full control over the factor level handling if you convert the factors yourself into model matrices instead when supplying them to inla.stack. (Only works for factors not involved in an f() model)Something like..., effects=list(list(myfactor=model.matrix(~0+thefactor, data)[,-1], ...)), ..
Finn
The problem is that when I run the models in INLA it does not drop a level, so I get estimates for nicu0 and nicu1 -- something that does not happen for my other binary variables. It did drop the level in lm() and it has in the past when I've run the model in INLA (for instance just running an estimation model with no prediction stack).On Sat, Aug 5, 2017 at 10:26 PM, INLA help <he...@r-inla.org> wrote:On Sun, 2017-08-06 at 01:01 -0700, Paul Lantos wrote:
>
> Any idea what's happening here?
its interpreting the variable as a factor. if this is an error, can you
produce a simple reproducing example and we'll fix it.
H
--
Håvard Rue
he...@r-inla.org
--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.
To post to this group, send email to r-inla-discussion-group@googlegroups.com.
> form1 <- y ~ b0 + nicu> test <- inla(form1, + data=inla.stack.data(stk.est), + family="binomial", + control.predictor=list(A =inla.stack.A(stk.est), compute=TRUE), + control.compute = list(dic = TRUE))
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) -0.4491 0.0113 -0.4712 -0.4491 -0.4270 -0.4491 0
b0 0.2073 0.0196 0.1689 0.2073 0.2457 0.2073 0
nicu1 0.0149 0.0656 -0.1140 0.0150 0.1434 0.0151 0
The model has no random effects
The model has no hyperparametersTo unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsubscr...@googlegroups.com.
> dim(data) [1] 19348 24
> summary(data$nicu) 0 1 19089 259
> summary(data$bw_std) Min. 1st Qu. Median Mean 3rd Qu. Max. -4.57971 -0.64230 0.01054 0.00000 0.64297 4.07036
> str(inla.stack.data(stk.est)$bw) num [1:12737] NA NA NA NA NA NA NA NA NA NA ...
> str(inla.stack.data(stk.est)$nicu) Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ...
Fixed effects:
mean sd 0.025quant 0.5quant 0.975quant mode kld
b0 -2.9030 18.2577 -38.7492 -2.9035 32.9131 -2.9030 0
bw 0.0432 0.0510 -0.0575 0.0433 0.1428 0.0437 0
ga -0.2025 0.0489 -0.2980 -0.2026 -0.1061 -0.2029 0
gender0 -1.4738 18.2576 -37.3196 -1.4743 34.3422 -1.4738 0
gender1 -1.3875 18.2576 -37.2333 -1.3880 34.4284 -1.3875 0
nicu1 0.1614 0.3295 -0.5314 0.1775 0.7648 0.2108 0
sti1 0.2942 0.0932 0.1099 0.2946 0.4758 0.2955 0
parity 0.0256 0.0417 -0.0574 0.0259 0.1065 0.0266 0
race1 0.8381 0.1276 0.5921 0.8365 1.0931 0.8332 0
Model hyperparameters:
mean sd 0.025quant 0.5quant 0.975quant mode
Range for s 8352.813 1.193e+04 1106.9747 4.850e+03 3.707e+04 2.350e+03
Stdev for s 0.217 5.620e-02 0.1217 2.124e-01 3.409e-01 2.047e-01
Precision for nicu 18089.470 1.997e+04 1263.7991 1.207e+04 7.093e+04 3.448e+03
Precision for sti 37896.276 2.177e+04 9865.7847 3.341e+04 9.234e+04 2.427e+04
Precision for race 20398.145 2.017e+04 922.8571 1.420e+04 7.338e+04 2.122e+03
Precision for gender 15693.031 2.028e+04 953.2671 9.495e+03 6.806e+04 2.515e+03
--
You received this message because you are subscribed to a topic in the Google Groups "R-inla discussion group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/r-inla-discussion-group/iimQ1t1onE0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to r-inla-discussion-group+unsubscr...@googlegroups.com.
To post to this group, send an email to r-inla-discussion-group@googlegroups.com.
> str(stk.est$effects) List of 5 $ data :'data.frame': 12737 obs. of 9 variables: ..$ s : int [1:12737] 1 2 6 7 14 15 20 35 36 37 ... ..$ b0 : num [1:12737] NA NA NA NA NA NA NA NA NA NA ... ..$ ga : num [1:12737] NA NA NA NA NA NA NA NA NA NA ... ..$ bw : num [1:12737] NA NA NA NA NA NA NA NA NA NA ... ..$ parity: num [1:12737] NA NA NA NA NA NA NA NA NA NA ... ..$ race : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... ..$ gender: Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... ..$ nicu : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... ..$ sti : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... $ nrow : int 12737 $ ncol : Named int [1:9] 1 1 1 1 1 1 1 1 1 ..- attr(*, "names")= chr [1:9] "s" "b0" "ga" "race" ... $ names:List of 9 ..$ s : chr "s" ..$ b0 : chr "b0" ..$ ga : chr "ga" ..$ race : chr "race" ..$ gender: chr "gender" ..$ bw : chr "bw" ..$ nicu : chr "nicu" ..$ parity: chr "parity" ..$ sti : chr "sti" $ index:List of 1 ..$ estimation: int [1:19979] 1 2 NA NA NA 3 4 NA NA NA ... - attr(*, "class")= chr "inla.data.stack.info"
> str(inla.stack.data(stk.est)) List of 10 $ y : int [1:19348] 0 0 1 1 1 1 0 0 0 0 ... $ s : int [1:12737] 1 2 6 7 14 15 20 35 36 37 ... $ b0 : num [1:12737] NA NA NA NA NA NA NA NA NA NA ... $ ga : num [1:12737] NA NA NA NA NA NA NA NA NA NA ... $ race : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... $ gender: Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... $ bw : num [1:12737] NA NA NA NA NA NA NA NA NA NA ... $ nicu : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... $ parity: num [1:12737] NA NA NA NA NA NA NA NA NA NA ... $ sti : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ...
> str(inla.stack.data(stk.pred)) List of 10 $ y : logi [1:4100] NA NA NA NA NA NA ... $ s : int [1:447] 2 3 4 5 6 7 8 9 10 11 ... $ b0 : num [1:447] NA NA NA NA NA NA NA NA NA NA ... $ ga : num [1:447] NA NA NA NA NA NA NA NA NA NA ... $ race : Factor w/ 1 level "0": NA NA NA NA NA NA NA NA NA NA ... $ gender: Factor w/ 1 level "0": NA NA NA NA NA NA NA NA NA NA ... $ bw : num [1:447] NA NA NA NA NA NA NA NA NA NA ... $ nicu : Factor w/ 1 level "0": NA NA NA NA NA NA NA NA NA NA ... $ parity: num [1:447] NA NA NA NA NA NA NA NA NA NA ... $ sti : Factor w/ 1 level "0": NA NA NA NA NA NA NA NA NA NA ...
> str(inla.stack.data(stk.full)) List of 10 $ y : int [1:23448] 0 0 1 1 1 1 0 0 0 0 ... $ s : int [1:12846] 1 2 6 7 14 15 20 35 36 37 ... $ b0 : num [1:12846] NA NA NA NA NA NA NA NA NA NA ... $ ga : num [1:12846] NA NA NA NA NA NA NA NA NA NA ... $ race : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... $ gender: Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... $ bw : num [1:12846] NA NA NA NA NA NA NA NA NA NA ... $ nicu : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ... $ parity: num [1:12846] NA NA NA NA NA NA NA NA NA NA ... $ sti : Factor w/ 2 levels "0","1": NA NA NA NA NA NA NA NA NA NA ...
*** ERROR *** INLA.Data1: Binomial data[2] (nb,y) = (1,2) is void Error in inla.inlaprogram.has.crashed() : The inla-program exited with an error. Unless you interupted it yourself, please rerun with verbose=TRUE and check the output carefully. If this does not help, please contact the developers at <he...@r-inla.org>. In addition: Warning message: running command '"C:/Users/pl39/Documents/R/win-library/3.4/INLA/bin/windows/64bit/inla.exe" -b -s -v "C:/Users/pl39/AppData/Local/Temp/Rtmpkd59hS/file1cb06c3b3b56/Model.ini"' had status 1
When running with inla.stack, you also use expand.factor.strategy="inla", right?
Also see Elias post, which showed what happens when the intercept is a regular covariates (as it must be for inla.stack to operate properly).Håvard, I think we need an expand.factor.strategy="inla0", meaning "drop the first level of every factor" (I think the current "inla" strategy does something different to that, that only works sensibly when there is a single factor in the model...).Paul, you can have full control over the factor level handling if you convert the factors yourself into model matrices instead when supplying them to inla.stack. (Only works for factors not involved in an f() model)Something like..., effects=list(list(myfactor=model.matrix(~0+thefactor, data)[,-1], ...)), ..
Finn
The problem is that when I run the models in INLA it does not drop a level, so I get estimates for nicu0 and nicu1 -- something that does not happen for my other binary variables. It did drop the level in lm() and it has in the past when I've run the model in INLA (for instance just running an estimation model with no prediction stack).
On Sat, Aug 5, 2017 at 10:26 PM, INLA help <he...@r-inla.org> wrote:
On Sun, 2017-08-06 at 01:01 -0700, Paul Lantos wrote:
>
> Any idea what's happening here?
its interpreting the variable as a factor. if this is an error, can you
produce a simple reproducing example and we'll fix it.
H
--
Håvard Rue
he...@r-inla.org
--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.
To post to this group, send email to r-inla-disc...@googlegroups.com.
Paul,
It looks like a problem in the response, not in the covariates.
Elias
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.