Paquetes requeridos
library(future)
future::plan("multisession") # Windows
## Run chains in parallel
options(mc.cores = parallel::detectCores())
library(lavaan)
## This is lavaan 0.6-10
## lavaan is FREE software! Please report any bugs.
library(blavaan)
## Loading required package: Rcpp
## This is blavaan 0.4-1
## On multicore systems, we suggest use of future::plan("multicore") or
## future::plan("multisession") for faster post-MCMC computations.
library(semPlot)
## Found more than one class "family" in cache; using the first, from namespace 'MatrixModels'
## Also defined by 'lme4'
## Found more than one class "family" in cache; using the first, from namespace 'MatrixModels'
## Also defined by 'lme4'
## Found more than one class "family" in cache; using the first, from namespace 'MatrixModels'
## Also defined by 'lme4'
library(bayestestR)
## Warning: package 'bayestestR' was built under R version 4.1.3
library(sjPlot)
## Warning: package 'sjPlot' was built under R version 4.1.3
library(knitr)
#leer la base de datos
datos <- readRDS("data/datos.RDS")
#comparacion de modelos
set.seed(535535)
# TODO: Explorar agregar covarianza entre SNT & FNC
#MODELO DE REFERENCIA
model_bayesianoref <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
# Parametros modelo referencia
BURNIN1 = 3000
SAMPLE1 = 6500
# Parametros modelos variables moderadoras
BURNIN = 2500
SAMPLE = 6500
CHAINS = 30
# TODO: EM explorar inicializacion pars
fitref <- bsem(
model = model_bayesianoref,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
inits = "prior",
sample = SAMPLE1,
burnin = BURNIN1,
n.chains = CHAINS)
## Warning: There were 1 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 28 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.17, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fitref,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 3000 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -674.166 0.188
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.202 0.462
## F_c30 1.441 0.159 1.170 1.794 0.291 0.718
## sintomas =~
## S_br23 1.000 0.319 0.566
## S_c30 0.726 6.341 -23.587 3.517 0.232 0.604
## Rhat Prior
##
##
## 1.008 normal(0,15)
##
##
## 3.639 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -0.577 4.027 -2.437 14.832 -0.911 -0.911
## CV_Gral ~
## Salud (c) 0.752 0.088 0.585 0.907 0.752 0.834
## sintomas (e) -0.630 7.417 -15.885 14.866 -0.201 -0.104
## funcionldd (d) 0.254 4.448 -9.180 9.671 0.051 0.026
## Salud ~
## sintomas -5.890 8.437 -23.539 9.444 -1.879 -0.873
## funcionldd (b) -0.655 5.241 -11.969 8.634 -0.132 -0.061
## Rhat Prior
##
## 3.641 normal(0,10)
##
## 1.001 normal(0,10)
## 1.005 normal(0,10)
## 1.001 normal(0,10)
##
## 1.005 normal(-10,10)
## 1.022 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.342 0.072 2.201 2.483 2.342 5.352
## .F_c30 2.437 0.088 2.265 2.609 2.437 6.014
## .S_br23 1.765 0.063 1.641 1.889 1.765 3.130
## .S_c30 2.165 0.090 1.988 2.340 2.165 5.639
## .CV_Gral 0.837 0.394 0.145 1.582 0.837 0.431
## .Salud 4.335 0.206 3.933 4.739 4.335 2.013
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.001 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.151 0.029 0.102 0.216 0.151 0.787
## .F_c30 0.079 0.028 0.028 0.138 0.079 0.484
## .S_br23 0.216 0.053 0.148 0.368 0.216 0.680
## .S_c30 0.094 0.035 0.013 0.161 0.094 0.636
## .CV_Gral 0.436 0.104 0.194 0.633 0.436 0.116
## .Salud 1.539 0.327 0.926 2.214 1.539 0.332
## .funcionalidad 0.007 0.011 0.000 0.041 0.170 0.170
## sintomas 0.102 0.048 0.001 0.201 1.000 1.000
## Rhat Prior
## 1.003 gamma(1,.5)[sd]
## 1.010 gamma(1,.5)[sd]
## 1.394 gamma(1,.5)[sd]
## 1.011 gamma(1,.5)[sd]
## 1.005 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.039 gamma(1,.5)[sd]
## 1.208 gamma(1,.5)[sd]
blavFitIndices(fitref) # revisar
## Warning: blavaan WARNING: the chains may not have converged.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Posterior mean (EAP) of devm-based fit indices:
##
## BRMSEA BGammaHat adjBGammaHat BMc
## 0.151 0.955 0.760 0.931
blavInspect(fitref, 'rhat')
## funcionalidad=~F_c30 sintomas=~S_c30
## 1.007717 3.638913
## a c
## 3.641237 1.000944
## e d
## 1.004567 1.000595
## Salud~sintomas b
## 1.004947 1.022250
## F_br23~~F_br23 F_c30~~F_c30
## 1.003111 1.010191
## S_br23~~S_br23 S_c30~~S_c30
## 1.393566 1.011171
## CV_Gral~~CV_Gral Salud~~Salud
## 1.004546 1.000873
## funcionalidad~~funcionalidad sintomas~~sintomas
## 1.039210 1.208252
## F_br23~1 F_c30~1
## 1.000200 1.000195
## S_br23~1 S_c30~1
## 1.000140 1.000205
## CV_Gral~1 Salud~1
## 1.000941 1.000082
blavInspect(fitref, 'neff')
## funcionalidad=~F_c30 sintomas=~S_c30
## 2191.24187 16.26167
## a c
## 16.25992 29301.38078
## e d
## 21231.52889 40115.33390
## Salud~sintomas b
## 16405.54604 483.65249
## F_br23~~F_br23 F_c30~~F_c30
## 31133.33513 1221.92409
## S_br23~~S_br23 S_c30~~S_c30
## 30.93519 1277.36384
## CV_Gral~~CV_Gral Salud~~Salud
## 14772.48180 57444.65191
## funcionalidad~~funcionalidad sintomas~~sintomas
## 241.03262 48.29272
## F_br23~1 F_c30~1
## 88335.17567 78787.62712
## S_br23~1 S_c30~1
## 117010.01158 80005.24447
## CV_Gral~1 Salud~1
## 29344.01660 97131.91922
#grafico del sem Bayesiano
#version 1.0
semPaths(
fitref,
intercepts = FALSE,
residuals = TRUE,
edge.label.cex = 1.5,
intStyle = "multi",
optimizeLatRes = TRUE,
title.color = "black",
groups = "lat",
pastel = TRUE,
exoVar = FALSE,
sizeInt = 5,
edge.color = "black",
esize = 6,
label.prop = 2,
sizeLat = 6,
"std"
)
# trace plots
plot(fitref, par = 1:12, facet_args = list(ncol = 4))
plot(fitref, par = 13:22, facet_args = list(ncol = 4))
plot(fitref, par = 2:3, facet_args = list(ncol = 4))
# intervals plot
plot(fitref, par = 1:12, plot.type = "intervals")
# coord paralelas
plot(fitref, plot.type = "parcoord")
## SEM Bayesiano final utilizando variables moderadoras
# Modelo 1.0 interaccion Edad
model_bayesiano1.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad + Edad
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fitedad1.0 <- bsem(
model = model_bayesiano1.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 8 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Computing posterior predictives...
summary(fitedad1.0,standardized = TRUE)
## blavaan (0.4-1) results of 6500 samples after 2500 adapt/burnin iterations
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -526.666 0.036
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.538 0.811
## F_c30 1.436 0.156 1.169 1.782 0.772 0.939
## sintomas =~
## S_br23 1.000 0.331 0.588
## S_c30 2.353 0.502 1.664 3.542 0.778 0.930
## Rhat Prior
##
##
## 1.000 normal(0,15)
##
##
## 1.001 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -1.607 0.358 -2.444 -1.095 -0.989 -0.989
## CV_Gral ~
## Salud (c) 0.740 0.089 0.562 0.901 0.740 0.752
## sintomas (e) -1.415 7.248 -16.296 13.695 -0.468 -0.257
## funcionldd (d) -0.105 4.594 -9.603 9.502 -0.057 -0.031
## Edad -0.005 0.007 -0.018 0.008 -0.005 -0.033
## Salud ~
## sintomas -5.552 8.210 -22.796 9.353 -1.836 -0.991
## funcionldd (b) -0.865 5.241 -11.974 8.772 -0.465 -0.251
## Rhat Prior
##
## 1.001 normal(0,10)
##
## 1.000 normal(0,10)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
## 1.000 normal(-10,10)
## 1.000 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.342 0.072 2.200 2.484 2.342 3.534
## .F_c30 2.437 0.087 2.265 2.609 2.437 2.963
## .S_br23 1.765 0.063 1.642 1.889 1.765 3.140
## .S_c30 2.164 0.090 1.989 2.340 2.164 2.587
## .CV_Gral 1.155 0.581 0.048 2.317 1.155 0.633
## .Salud 4.336 0.206 3.932 4.738 4.336 2.339
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.150 0.029 0.102 0.215 0.150 0.342
## .F_c30 0.081 0.028 0.029 0.139 0.081 0.119
## .S_br23 0.207 0.036 0.147 0.288 0.207 0.654
## .S_c30 0.094 0.033 0.019 0.160 0.094 0.134
## .CV_Gral 0.432 0.110 0.159 0.635 0.432 0.130
## .Salud 1.537 0.327 0.917 2.215 1.537 0.447
## .funcionalidad 0.006 0.010 0.000 0.038 0.022 0.022
## sintomas 0.109 0.042 0.042 0.204 1.000 1.000
## Rhat Prior
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
blavFitIndices(fitedad1.0, baseline.model = fitref)
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: blavaan WARNING: the chains may not have converged.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Posterior mean (EAP) of devm-based fit indices:
##
## BRMSEA BGammaHat adjBGammaHat BMc BCFI BTLI
## 0.130 0.936 0.838 0.887 0.554 0.578
## BNFI
## -2.210
# TODO: generar los plots para cada modelo
#COMPARACION MODREF Vs MOD1.0
blavCompare(fitref, fitedad1.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 915.813
##
## WAIC difference & SE:
## -1.346 1.143
##
## LOO estimates:
## object1: 919.086
## object2: 916.239
##
## LOO difference & SE:
## -1.423 1.167
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -147.500
#Gana el mod ref 7.185
#confimacion COMPARACION MODREF Vs MOD1.0
blavCompare(fitedad1.0, fitref)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 915.813
## object2: 918.504
##
## WAIC difference & SE:
## -1.346 1.143
##
## LOO estimates:
## object1: 916.239
## object2: 919.086
##
## LOO difference & SE:
## -1.423 1.167
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 147.500
#Gana el mod ref -7.185
#Modelo 2.0 interaccion compañero permanente
model_bayesiano2.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad + Con_compañero_permanente
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit2.0 <- bsem(
model = model_bayesiano2.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 13 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.18, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit2.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -621.486 0.212
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.345 0.652
## F_c30 0.638 4.539 -16.756 1.781 0.220 0.616
## sintomas =~
## S_br23 1.000 0.324 0.575
## S_c30 1.549 4.569 -17.331 3.546 0.502 0.854
## Rhat Prior
##
##
## 3.176 normal(0,15)
##
##
## 3.585 normal(0,15)
## Warning in abbreviate(NAMES, minlength = (W - MAX.L), strict = TRUE):
## abreviatura utilizada con caracteres no ASCII
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -1.035 2.914 -2.419 10.910 -0.973 -0.973
## CV_Gral ~
## Salud (c) 0.752 0.085 0.585 0.908 0.752 0.797
## sintomas (e) -0.694 7.213 -15.712 14.388 -0.225 -0.119
## funcionldd (d) 0.285 4.696 -9.462 10.131 0.098 0.052
## Cn_cmpñr_p -0.000 0.162 -0.318 0.318 -0.000 -0.000
## Salud ~
## sintomas -5.748 8.210 -23.088 9.218 -1.862 -0.932
## funcionldd (b) -0.888 5.482 -12.563 8.961 -0.306 -0.153
## Rhat Prior
##
## 3.572 normal(0,10)
##
## 1.001 normal(0,10)
## 1.002 normal(0,10)
## 1.001 normal(0,10)
## 1.000 normal(0,10)
##
## 1.003 normal(-10,10)
## 1.014 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.342 0.072 2.200 2.484 2.342 4.434
## .F_c30 2.437 0.088 2.265 2.610 2.437 6.825
## .S_br23 1.765 0.063 1.642 1.888 1.765 3.135
## .S_c30 2.164 0.090 1.987 2.340 2.164 3.684
## .CV_Gral 0.837 0.437 0.016 1.700 0.837 0.444
## .Salud 4.336 0.206 3.932 4.739 4.336 2.169
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.160 0.063 0.102 0.402 0.160 0.575
## .F_c30 0.079 0.028 0.023 0.138 0.079 0.621
## .S_br23 0.212 0.045 0.148 0.328 0.212 0.669
## .S_c30 0.093 0.034 0.014 0.160 0.093 0.270
## .CV_Gral 0.442 0.106 0.197 0.644 0.442 0.124
## .Salud 1.543 0.322 0.939 2.216 1.543 0.386
## .funcionalidad 0.006 0.010 0.000 0.038 0.054 0.054
## sintomas 0.105 0.045 0.002 0.201 1.000 1.000
## Rhat Prior
## 2.018 gamma(1,.5)[sd]
## 1.013 gamma(1,.5)[sd]
## 1.228 gamma(1,.5)[sd]
## 1.017 gamma(1,.5)[sd]
## 1.005 gamma(1,.5)[sd]
## 1.003 gamma(1,.5)[sd]
## 1.029 gamma(1,.5)[sd]
## 1.111 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MOD2.0
blavCompare(fitref, fit2.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 17 (21.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 922.775
##
## WAIC difference & SE:
## -2.136 0.264
##
## LOO estimates:
## object1: 919.086
## object2: 923.893
##
## LOO difference & SE:
## -2.404 0.306
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -52.680
#Gana MODREF
#COMPARACION MOD1.0 Vs MOD2.0
blavCompare(fitedad1.0, fit2.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 17 (21.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 915.813
## object2: 922.775
##
## WAIC difference & SE:
## -3.481 1.221
##
## LOO estimates:
## object1: 916.239
## object2: 923.893
##
## LOO difference & SE:
## -3.827 1.279
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 94.820
#Gana MOD2.0 -2.782
#MODELO COMPUESTO 1.0 + 2.0 (Edad + compañero permanente)
model_bayesiano1.0_2.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad + Edad + Con_compañero_permanente
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit1.0_2.0 <- bsem(
model = model_bayesiano1.0_2.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 1 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 17 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.18, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit1.0_2.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -625.704 0.048
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.346 0.654
## F_c30 0.648 4.496 -16.559 1.781 0.224 0.623
## sintomas =~
## S_br23 1.000 0.324 0.576
## S_c30 1.557 4.558 -17.245 3.578 0.505 0.857
## Rhat Prior
##
##
## 3.130 normal(0,15)
##
##
## 3.541 normal(0,15)
## Warning in abbreviate(NAMES, minlength = (W - MAX.L), strict = TRUE):
## abreviatura utilizada con caracteres no ASCII
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -1.038 2.893 -2.428 10.848 -0.972 -0.972
## CV_Gral ~
## Salud (c) 0.742 0.089 0.566 0.903 0.742 0.763
## sintomas (e) -1.277 7.215 -16.199 13.896 -0.414 -0.215
## funcionldd (d) -0.017 4.710 -9.708 9.926 -0.006 -0.003
## Edad -0.005 0.007 -0.019 0.009 -0.005 -0.031
## Cn_cmpñr_p -0.016 0.164 -0.339 0.306 -0.016 -0.004
## Salud ~
## sintomas -5.569 8.148 -22.980 9.232 -1.806 -0.913
## funcionldd (b) -0.796 5.462 -12.572 8.924 -0.276 -0.139
## Rhat Prior
##
## 3.530 normal(0,10)
##
## 1.001 normal(0,10)
## 1.005 normal(0,10)
## 1.002 normal(0,10)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
## 1.004 normal(-10,10)
## 1.016 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.342 0.072 2.202 2.484 2.342 4.421
## .F_c30 2.437 0.087 2.266 2.609 2.437 6.764
## .S_br23 1.765 0.063 1.641 1.889 1.765 3.136
## .S_c30 2.164 0.090 1.988 2.341 2.164 3.673
## .CV_Gral 1.174 0.644 -0.065 2.457 1.174 0.610
## .Salud 4.336 0.205 3.932 4.739 4.336 2.192
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.161 0.063 0.103 0.401 0.161 0.572
## .F_c30 0.079 0.029 0.023 0.139 0.079 0.612
## .S_br23 0.212 0.045 0.148 0.329 0.212 0.668
## .S_c30 0.092 0.034 0.012 0.159 0.092 0.265
## .CV_Gral 0.441 0.110 0.175 0.648 0.441 0.119
## .Salud 1.543 0.327 0.935 2.218 1.543 0.394
## .funcionalidad 0.007 0.011 0.000 0.040 0.056 0.056
## sintomas 0.105 0.045 0.002 0.202 1.000 1.000
## Rhat Prior
## 2.009 gamma(1,.5)[sd]
## 1.012 gamma(1,.5)[sd]
## 1.231 gamma(1,.5)[sd]
## 1.018 gamma(1,.5)[sd]
## 1.005 gamma(1,.5)[sd]
## 1.003 gamma(1,.5)[sd]
## 1.029 gamma(1,.5)[sd]
## 1.110 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MODCOMPUESTO 1.0 + 2.0
blavCompare(fitref, fit1.0_2.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 18 (22.5%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 924.943
##
## WAIC difference & SE:
## -3.219 1.063
##
## LOO estimates:
## object1: 919.086
## object2: 926.363
##
## LOO difference & SE:
## -3.639 1.061
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -48.462
#Gana MODREF 11.216
#COMPATACION MODCOMPUESTO VS MOD1.0
blavCompare(fit1.0_2.0, fitedad1.0)
## Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 18 (22.5%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 924.943
## object2: 915.813
##
## WAIC difference & SE:
## -4.565 0.522
##
## LOO estimates:
## object1: 926.363
## object2: 916.239
##
## LOO difference & SE:
## -5.062 0.605
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -99.038
#Gana MOD1.0 -4.378
#COMPATACION MODCOMPUESTO VS MOD2.0
blavCompare(fit1.0_2.0, fit2.0)
## Warning: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 18 (22.5%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 17 (21.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 924.943
## object2: 922.775
##
## WAIC difference & SE:
## -1.084 1.084
##
## LOO estimates:
## object1: 926.363
## object2: 923.893
##
## LOO difference & SE:
## -1.235 1.086
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -4.218
#Gana MOD2.0 -7.160
#Modelo 3.0 interaccion + estrato
model_bayesiano3.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas + Estrato
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit3.0 <- bsem(
model = model_bayesiano3.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: The largest R-hat is 1.1, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit3.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -533.001 0.296
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.374 0.695
## F_c30 1.434 0.154 1.170 1.774 0.536 0.890
## sintomas =~
## S_br23 1.000 0.318 0.569
## S_c30 1.613 4.635 -17.661 3.746 0.513 0.871
## Rhat Prior
##
##
## 1.003 normal(0,15)
##
##
## 3.596 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -1.121 2.954 -2.565 11.201 -0.954 -0.954
## Estrato 0.085 0.060 -0.018 0.213 0.228 0.113
## CV_Gral ~
## Salud (c) 0.755 0.072 0.615 0.892 0.755 0.765
## sintomas (e) -1.455 4.083 -10.321 7.745 -0.463 -0.254
## funcionldd (d) -0.231 2.265 -5.358 4.418 -0.086 -0.047
## Salud ~
## sintomas -3.431 5.714 -17.337 6.118 -1.092 -0.593
## funcionldd (b) 0.694 3.325 -7.392 6.284 0.259 0.141
## Rhat Prior
##
## 3.551 normal(0,10)
## 1.001 normal(0,10)
##
## 1.000 normal(0,10)
## 1.023 normal(0,10)
## 1.002 normal(0,10)
##
## 1.009 normal(-10,10)
## 1.010 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.219 0.113 1.988 2.430 2.219 4.126
## .F_c30 2.262 0.151 1.957 2.542 2.262 3.755
## .S_br23 1.765 0.062 1.643 1.888 1.765 3.154
## .S_c30 2.165 0.090 1.989 2.341 2.165 3.675
## .CV_Gral 0.847 0.359 0.181 1.575 0.847 0.465
## .Salud 4.193 0.393 3.374 4.942 4.193 2.276
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.001 normal(0,32)
## 1.001 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.002 normal(0,10)
## 1.010 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.150 0.029 0.102 0.214 0.150 0.517
## .F_c30 0.076 0.027 0.024 0.133 0.076 0.209
## .S_br23 0.212 0.045 0.148 0.328 0.212 0.677
## .S_c30 0.084 0.036 0.005 0.152 0.084 0.241
## .CV_Gral 0.460 0.087 0.310 0.646 0.460 0.139
## .Salud 1.595 0.301 1.081 2.254 1.595 0.470
## .funcionalidad 0.011 0.013 0.000 0.048 0.077 0.077
## sintomas 0.101 0.045 0.002 0.197 1.000 1.000
## Rhat Prior
## 1.001 gamma(1,.5)[sd]
## 1.003 gamma(1,.5)[sd]
## 1.229 gamma(1,.5)[sd]
## 1.003 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.006 gamma(1,.5)[sd]
## 1.102 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MOD3.0
blavCompare(fitref, fit3.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 915.767
##
## WAIC difference & SE:
## -1.368 1.455
##
## LOO estimates:
## object1: 919.086
## object2: 916.243
##
## LOO difference & SE:
## -1.422 1.464
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -141.165
#Gana MODREF 4.229
#Modelo 4.0 interaccion nivel educativo
model_bayesiano4.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad + Nivel_educativo
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit4.0 <- bsem(
model = model_bayesiano4.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 5 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 17 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.3, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit4.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -979.324 0.075
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.164 0.388
## F_c30 1.447 0.161 1.174 1.805 0.237 0.646
## sintomas =~
## S_br23 1.000 0.308 0.543
## S_c30 -0.896 8.637 -27.638 3.498 -0.276 -0.673
## Rhat Prior
##
##
## 1.015 normal(0,15)
##
##
## 3.611 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) 0.447 5.461 -2.416 17.341 0.840 0.840
## CV_Gral ~
## Salud (c) 0.752 0.085 0.586 0.905 0.752 0.877
## sintomas (e) -0.581 7.541 -15.973 15.116 -0.179 -0.091
## funcionldd (d) 0.223 4.286 -9.004 9.388 0.036 0.019
## Nivel_dctv 0.115 0.173 -0.223 0.455 0.115 0.028
## Salud ~
## sintomas -6.088 8.527 -23.902 9.447 -1.873 -0.818
## funcionldd (b) -0.376 5.127 -11.668 8.409 -0.061 -0.027
## Rhat Prior
##
## 3.632 normal(0,10)
##
## 1.001 normal(0,10)
## 1.010 normal(0,10)
## 1.001 normal(0,10)
## 1.000 normal(0,10)
##
## 1.008 normal(-10,10)
## 1.044 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.342 0.072 2.200 2.483 2.342 5.550
## .F_c30 2.437 0.088 2.265 2.609 2.437 6.652
## .S_br23 1.765 0.063 1.641 1.889 1.765 3.116
## .S_c30 2.164 0.090 1.988 2.341 2.164 5.283
## .CV_Gral 0.684 0.447 -0.158 1.559 0.684 0.348
## .Salud 4.335 0.206 3.931 4.739 4.335 1.893
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.001 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.151 0.029 0.103 0.217 0.151 0.850
## .F_c30 0.078 0.028 0.025 0.136 0.078 0.583
## .S_br23 0.226 0.064 0.149 0.402 0.226 0.705
## .S_c30 0.092 0.036 0.007 0.161 0.092 0.548
## .CV_Gral 0.441 0.106 0.198 0.642 0.441 0.114
## .Salud 1.543 0.324 0.941 2.214 1.543 0.294
## .funcionalidad 0.008 0.012 0.000 0.044 0.295 0.295
## sintomas 0.095 0.053 0.001 0.199 1.000 1.000
## Rhat Prior
## 1.006 gamma(1,.5)[sd]
## 1.018 gamma(1,.5)[sd]
## 1.610 gamma(1,.5)[sd]
## 1.021 gamma(1,.5)[sd]
## 1.009 gamma(1,.5)[sd]
## 1.002 gamma(1,.5)[sd]
## 1.066 gamma(1,.5)[sd]
## 1.383 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MOD3.0
blavCompare(fitref, fit4.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 17 (21.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 924.769
##
## WAIC difference & SE:
## -3.133 0.875
##
## LOO estimates:
## object1: 919.086
## object2: 925.268
##
## LOO difference & SE:
## -3.091 0.889
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 305.158
#Gana MODREF 4.092
#COMPARACION MOD3.0 Vs MOD4.0
blavCompare(fit3.0, fit4.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 17 (21.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 915.767
## object2: 924.769
##
## WAIC difference & SE:
## -4.501 1.799
##
## LOO estimates:
## object1: 916.243
## object2: 925.268
##
## LOO difference & SE:
## -4.513 1.812
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 446.323
#Gana MOD4.0 -0.137 #GANADOR A MOD REF
#MODELO COMPUESTO 3.0 + 4.0 (Estrato + nivel educativo)
model_bayesiano3.0_4.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas + Estrato
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad + Nivel_educativo
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit3.0_4.0 <- bsem(
model = model_bayesiano3.0_4.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 1 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.32, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit3.0_4.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -1000.835 0.108
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.109 0.264
## F_c30 0.716 4.112 -14.964 1.777 0.078 0.277
## sintomas =~
## S_br23 1.000 0.307 0.546
## S_c30 -0.019 7.673 -26.195 3.716 -0.006 -0.020
## Rhat Prior
##
##
## 3.132 normal(0,15)
##
##
## 3.632 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -0.022 4.877 -2.522 16.536 -0.062 -0.062
## Estrato 0.085 0.061 -0.018 0.213 0.780 0.387
## CV_Gral ~
## Salud (c) 0.757 0.071 0.617 0.892 0.757 0.717
## sintomas (e) -1.644 4.939 -11.445 10.893 -0.505 -0.279
## funcionldd (d) -0.443 2.726 -6.258 5.200 -0.049 -0.027
## Nivel_dctv 0.146 0.181 -0.210 0.505 0.146 0.039
## Salud ~
## sintomas -3.742 5.964 -18.391 6.346 -1.149 -0.670
## funcionldd (b) 0.672 3.742 -8.516 6.342 0.074 0.043
## Rhat Prior
##
## 3.654 normal(0,10)
## 1.046 normal(0,10)
##
## 1.001 normal(0,10)
## 1.085 normal(0,10)
## 1.020 normal(0,10)
## 1.002 normal(0,10)
##
## 1.021 normal(-10,10)
## 1.060 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.219 0.114 1.988 2.434 2.219 5.345
## .F_c30 2.254 0.150 1.951 2.535 2.254 7.962
## .S_br23 1.765 0.063 1.643 1.889 1.765 3.139
## .S_c30 2.164 0.090 1.988 2.340 2.164 7.467
## .CV_Gral 0.680 0.410 -0.104 1.497 0.680 0.376
## .Salud 4.179 0.397 3.358 4.941 4.179 2.438
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.027 normal(0,32)
## 1.004 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.004 normal(0,10)
## 1.031 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.160 0.064 0.102 0.405 0.160 0.931
## .F_c30 0.074 0.028 0.018 0.132 0.074 0.923
## .S_br23 0.222 0.059 0.149 0.389 0.222 0.702
## .S_c30 0.084 0.036 0.005 0.153 0.084 1.000
## .CV_Gral 0.460 0.090 0.302 0.650 0.460 0.141
## .Salud 1.601 0.300 1.093 2.263 1.601 0.545
## .funcionalidad 0.010 0.013 0.000 0.048 0.846 0.846
## sintomas 0.094 0.050 0.001 0.195 1.000 1.000
## Rhat Prior
## 2.044 gamma(1,.5)[sd]
## 1.015 gamma(1,.5)[sd]
## 1.512 gamma(1,.5)[sd]
## 1.013 gamma(1,.5)[sd]
## 1.003 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.030 gamma(1,.5)[sd]
## 1.281 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MODCOMPUESTO 3.0 + 4.0
blavCompare(fitref, fit3.0_4.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 19 (23.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 926.245
##
## WAIC difference & SE:
## -3.871 1.742
##
## LOO estimates:
## object1: 919.086
## object2: 927.068
##
## LOO difference & SE:
## -3.991 1.751
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 326.669
#Gana MODREF
#MODELO 5.0 Situracion laboral
model_bayesiano5.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas + Situacion_laboral
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit5.0 <- bsem(
model = model_bayesiano5.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 6 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Computing posterior predictives...
summary(fit5.0,standardized = TRUE)
## blavaan (0.4-1) results of 6500 samples after 2500 adapt/burnin iterations
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -524.839 0.190
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.542 0.815
## F_c30 1.421 0.153 1.158 1.757 0.770 0.938
## sintomas =~
## S_br23 1.000 0.327 0.584
## S_c30 2.382 0.530 1.674 3.627 0.780 0.931
## Rhat Prior
##
##
## 1.000 normal(0,15)
##
##
## 1.001 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -1.634 0.377 -2.509 -1.105 -0.987 -0.987
## Sitcn_lbrl -0.019 0.051 -0.124 0.083 -0.035 -0.017
## CV_Gral ~
## Salud (c) 0.759 0.081 0.605 0.911 0.759 0.769
## sintomas (e) 0.318 6.048 -12.640 12.787 0.104 0.057
## funcionldd (d) 0.906 3.725 -7.081 8.618 0.491 0.267
## Salud ~
## sintomas -5.261 7.311 -20.918 7.909 -1.723 -0.925
## funcionldd (b) -0.631 4.542 -10.396 7.664 -0.342 -0.183
## Rhat Prior
##
## 1.001 normal(0,10)
## 1.001 normal(0,10)
##
## 1.000 normal(0,10)
## 1.001 normal(0,10)
## 1.001 normal(0,10)
##
## 1.001 normal(-10,10)
## 1.000 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.373 0.109 2.157 2.589 2.373 3.566
## .F_c30 2.479 0.145 2.191 2.765 2.479 3.018
## .S_br23 1.765 0.063 1.643 1.888 1.765 3.151
## .S_c30 2.164 0.090 1.988 2.340 2.164 2.582
## .CV_Gral 0.930 0.387 0.217 1.706 0.930 0.506
## .Salud 4.253 0.354 3.489 4.922 4.253 2.282
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.001 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.149 0.029 0.101 0.214 0.149 0.336
## .F_c30 0.082 0.028 0.030 0.140 0.082 0.121
## .S_br23 0.207 0.036 0.147 0.288 0.207 0.658
## .S_c30 0.094 0.034 0.016 0.161 0.094 0.134
## .CV_Gral 0.441 0.097 0.241 0.633 0.441 0.130
## .Salud 1.550 0.316 0.979 2.217 1.550 0.446
## .funcionalidad 0.007 0.011 0.000 0.042 0.025 0.025
## sintomas 0.107 0.041 0.040 0.201 1.000 1.000
## Rhat Prior
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MOD5.0
blavCompare(fitref, fit5.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 915.747
##
## WAIC difference & SE:
## -1.378 0.747
##
## LOO estimates:
## object1: 919.086
## object2: 916.156
##
## LOO difference & SE:
## -1.465 0.772
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -149.327
#Gana MOD5.0 5.366 #### GANADOR A MOD REF
#MODELO 6.0 Regimen de salud
model_bayesiano6.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad +Regimen_salud
# residual correlations
'
fit6.0 <- bsem(
model = model_bayesiano6.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 1 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 15 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.3, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit6.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -976.604 0.110
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.161 0.381
## F_c30 1.450 0.161 1.178 1.811 0.233 0.643
## sintomas =~
## S_br23 1.000 0.307 0.542
## S_c30 -0.874 8.597 -27.496 3.507 -0.269 -0.662
## Rhat Prior
##
##
## 1.016 normal(0,15)
##
##
## 3.570 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) 0.435 5.436 -2.418 17.228 0.832 0.832
## CV_Gral ~
## Salud (c) 0.762 0.088 0.604 0.930 0.762 0.939
## sintomas (e) -0.144 7.604 -15.622 15.750 -0.044 -0.024
## funcionldd (d) 0.412 4.327 -8.870 9.755 0.066 0.036
## Salud ~
## sintomas -6.089 8.644 -24.063 9.676 -1.871 -0.819
## funcionldd (b) -0.322 5.219 -11.838 8.663 -0.052 -0.023
## Regimn_sld 0.286 0.314 -0.332 0.902 0.286 0.060
## Rhat Prior
##
## 3.600 normal(0,10)
##
## 1.000 normal(0,10)
## 1.008 normal(0,10)
## 1.001 normal(0,10)
##
## 1.007 normal(-10,10)
## 1.043 normal(0,10)
## 1.000 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.342 0.072 2.201 2.483 2.342 5.555
## .F_c30 2.437 0.087 2.264 2.608 2.437 6.730
## .S_br23 1.765 0.063 1.641 1.889 1.765 3.115
## .S_c30 2.164 0.089 1.989 2.341 2.164 5.338
## .CV_Gral 0.796 0.390 0.049 1.505 0.796 0.429
## .Salud 3.867 0.554 2.779 4.951 3.867 1.692
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.152 0.029 0.103 0.217 0.152 0.855
## .F_c30 0.077 0.028 0.024 0.135 0.077 0.586
## .S_br23 0.227 0.064 0.149 0.403 0.227 0.706
## .S_c30 0.092 0.036 0.008 0.161 0.092 0.561
## .CV_Gral 0.438 0.105 0.189 0.636 0.438 0.128
## .Salud 1.539 0.331 0.910 2.221 1.539 0.295
## .funcionalidad 0.008 0.012 0.000 0.044 0.308 0.308
## sintomas 0.094 0.053 0.001 0.199 1.000 1.000
## Rhat Prior
## 1.006 gamma(1,.5)[sd]
## 1.021 gamma(1,.5)[sd]
## 1.602 gamma(1,.5)[sd]
## 1.018 gamma(1,.5)[sd]
## 1.008 gamma(1,.5)[sd]
## 1.002 gamma(1,.5)[sd]
## 1.060 gamma(1,.5)[sd]
## 1.380 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MOD6.0
blavCompare(fitref, fit6.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 17 (21.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 924.393
##
## WAIC difference & SE:
## -2.944 1.004
##
## LOO estimates:
## object1: 919.086
## object2: 924.845
##
## LOO difference & SE:
## -2.879 1.008
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 302.438
#Gana MODREF 3.451 ####
#COMPARACION MOD5.0 VS MOD6.0
blavCompare(fit5.0, fit6.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 17 (21.2%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 915.747
## object2: 924.393
##
## WAIC difference & SE:
## -4.323 1.361
##
## LOO estimates:
## object1: 916.156
## object2: 924.845
##
## LOO difference & SE:
## -4.345 1.373
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 451.765
#Gana MOD6.0 -1.916 ####
#MODELO COMPUESTO 5.0 + 6.0 (Situracion laboral + Regimen de salud)
model_bayesiano5.0_6.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas + Situacion_laboral
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad + Regimen_salud
# residual correlations
'
fit5.0_6.0 <- bsem(
model = model_bayesiano5.0_6.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 2 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 8 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Computing posterior predictives...
summary(fit5.0_6.0,standardized = TRUE)
## blavaan (0.4-1) results of 6500 samples after 2500 adapt/burnin iterations
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -527.847 0.126
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.541 0.813
## F_c30 1.425 0.153 1.162 1.763 0.770 0.939
## sintomas =~
## S_br23 1.000 0.328 0.585
## S_c30 2.378 0.513 1.676 3.619 0.779 0.930
## Rhat Prior
##
##
## 1.000 normal(0,15)
##
##
## 1.000 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -1.629 0.367 -2.505 -1.101 -0.987 -0.987
## Sitcn_lbrl -0.019 0.051 -0.123 0.082 -0.035 -0.017
## CV_Gral ~
## Salud (c) 0.768 0.086 0.617 0.935 0.768 0.777
## sintomas (e) 0.562 6.148 -12.495 13.456 0.184 0.099
## funcionldd (d) 1.035 3.806 -7.038 8.985 0.560 0.300
## Salud ~
## sintomas -5.373 7.473 -21.338 8.243 -1.761 -0.933
## funcionldd (b) -0.654 4.668 -10.666 7.947 -0.354 -0.187
## Regimn_sld 0.288 0.314 -0.331 0.905 0.288 0.073
## Rhat Prior
##
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
## 1.000 normal(0,10)
## 1.001 normal(0,10)
## 1.001 normal(0,10)
##
## 1.001 normal(-10,10)
## 1.001 normal(0,10)
## 1.000 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.372 0.108 2.158 2.587 2.372 3.568
## .F_c30 2.478 0.144 2.193 2.762 2.478 3.019
## .S_br23 1.766 0.062 1.644 1.888 1.766 3.150
## .S_c30 2.165 0.090 1.988 2.341 2.165 2.585
## .CV_Gral 0.896 0.402 0.143 1.668 0.896 0.481
## .Salud 3.770 0.635 2.497 5.002 3.770 1.998
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.150 0.029 0.102 0.214 0.150 0.339
## .F_c30 0.080 0.028 0.029 0.139 0.080 0.119
## .S_br23 0.207 0.036 0.147 0.288 0.207 0.658
## .S_c30 0.094 0.034 0.016 0.162 0.094 0.135
## .CV_Gral 0.439 0.101 0.221 0.635 0.439 0.126
## .Salud 1.543 0.330 0.926 2.222 1.543 0.433
## .funcionalidad 0.007 0.011 0.000 0.042 0.025 0.025
## sintomas 0.107 0.041 0.040 0.201 1.000 1.000
## Rhat Prior
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MODCOMPUESTO 5.0 + 6.0
blavCompare(fitref, fit5.0_6.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 917.038
##
## WAIC difference & SE:
## -0.733 1.234
##
## LOO estimates:
## object1: 919.086
## object2: 917.534
##
## LOO difference & SE:
## -0.776 1.260
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -146.319
#Gana
#MODELO 7.0 Comorbilidad
model_bayesiano7.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas + Comorbilidad
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit7.0 <- bsem(
model = model_bayesiano7.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 6 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 22 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.35, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit7.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -858.234 0.132
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.302 0.614
## F_c30 1.421 0.157 1.152 1.768 0.429 0.824
## sintomas =~
## S_br23 1.000 0.311 0.546
## S_c30 -1.628 9.112 -27.859 3.234 -0.507 -0.858
## Rhat Prior
##
##
## 1.023 normal(0,15)
##
##
## 3.438 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) 0.936 5.872 -2.276 17.766 0.964 0.964
## Comorbildd 0.035 0.091 -0.122 0.187 0.114 0.054
## CV_Gral ~
## Salud (c) 0.686 0.116 0.409 0.860 0.686 0.776
## sintomas (e) -1.201 7.468 -16.498 12.069 -0.374 -0.254
## funcionldd (d) 0.472 4.198 -8.406 8.282 0.143 0.097
## Salud ~
## sintomas -4.835 11.843 -26.619 13.716 -1.505 -0.901
## funcionldd (b) 1.088 6.954 -12.902 11.742 0.329 0.197
## Rhat Prior
##
## 3.486 normal(0,10)
## 1.049 normal(0,10)
##
## 1.025 normal(0,10)
## 1.008 normal(0,10)
## 1.008 normal(0,10)
##
## 1.052 normal(-10,10)
## 1.023 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.285 0.168 1.987 2.595 2.285 4.640
## .F_c30 2.353 0.230 1.948 2.771 2.353 4.518
## .S_br23 1.765 0.064 1.640 1.891 1.765 3.093
## .S_c30 2.164 0.090 1.989 2.340 2.164 3.665
## .CV_Gral 0.710 0.418 -0.034 1.593 0.710 0.481
## .Salud 3.488 0.586 2.260 4.512 3.488 2.088
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.039 normal(0,32)
## 1.046 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.001 normal(0,10)
## 1.023 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.151 0.030 0.101 0.217 0.151 0.623
## .F_c30 0.087 0.028 0.035 0.147 0.087 0.321
## .S_br23 0.229 0.069 0.147 0.414 0.229 0.702
## .S_c30 0.092 0.036 0.010 0.162 0.092 0.263
## .CV_Gral 0.418 0.105 0.175 0.616 0.418 0.192
## .Salud 1.370 0.347 0.642 2.057 1.370 0.491
## .funcionalidad 0.006 0.009 0.000 0.035 0.068 0.068
## sintomas 0.097 0.057 0.001 0.206 1.000 1.000
## Rhat Prior
## 1.012 gamma(1,.5)[sd]
## 1.027 gamma(1,.5)[sd]
## 1.722 gamma(1,.5)[sd]
## 1.024 gamma(1,.5)[sd]
## 1.019 gamma(1,.5)[sd]
## 1.018 gamma(1,.5)[sd]
## 1.097 gamma(1,.5)[sd]
## 1.502 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MOD7.0
blavCompare(fitref, fit7.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 23 (28.7%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 924.196
##
## WAIC difference & SE:
## -2.846 2.102
##
## LOO estimates:
## object1: 919.086
## object2: 924.555
##
## LOO difference & SE:
## -2.735 2.099
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 184.069
#Gana
#MODELO 8.0 Estado_del_tumor
model_bayesiano8.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad + Estado_del_tumor
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit8.0 <- bsem(
model = model_bayesiano8.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 1 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 19 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Computing posterior predictives...
summary(fit8.0,standardized = TRUE)
## blavaan (0.4-1) results of 6500 samples after 2500 adapt/burnin iterations
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -523.168 0.137
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.538 0.811
## F_c30 1.437 0.156 1.170 1.781 0.773 0.939
## sintomas =~
## S_br23 1.000 0.330 0.587
## S_c30 2.366 0.527 1.669 3.586 0.780 0.931
## Rhat Prior
##
##
## 1.000 normal(0,15)
##
##
## 1.001 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -1.615 0.373 -2.463 -1.094 -0.989 -0.989
## CV_Gral ~
## Salud (c) 0.752 0.090 0.582 0.910 0.752 0.757
## sintomas (e) -1.012 7.223 -15.980 14.077 -0.334 -0.181
## funcionldd (d) 0.138 4.571 -9.386 9.752 0.074 0.040
## Estd_dl_tm -0.159 0.169 -0.492 0.173 -0.159 -0.041
## Salud ~
## sintomas -5.639 8.279 -23.025 9.413 -1.858 -1.004
## funcionldd (b) -0.912 5.272 -12.062 8.761 -0.491 -0.265
## Rhat Prior
##
## 1.001 normal(0,10)
##
## 1.000 normal(0,10)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
## 1.000 normal(-10,10)
## 1.001 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.342 0.072 2.201 2.484 2.342 3.529
## .F_c30 2.436 0.088 2.264 2.608 2.436 2.958
## .S_br23 1.765 0.063 1.642 1.889 1.765 3.143
## .S_c30 2.165 0.089 1.988 2.340 2.165 2.584
## .CV_Gral 1.049 0.456 0.212 1.937 1.049 0.570
## .Salud 4.334 0.205 3.932 4.738 4.334 2.341
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,10)
## 1.000 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.150 0.029 0.102 0.215 0.150 0.342
## .F_c30 0.080 0.027 0.030 0.138 0.080 0.118
## .S_br23 0.207 0.036 0.148 0.288 0.207 0.656
## .S_c30 0.094 0.033 0.018 0.160 0.094 0.134
## .CV_Gral 0.434 0.106 0.186 0.634 0.434 0.128
## .Salud 1.538 0.330 0.912 2.221 1.538 0.448
## .funcionalidad 0.006 0.010 0.000 0.038 0.022 0.022
## sintomas 0.109 0.041 0.041 0.203 1.000 1.000
## Rhat Prior
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
## 1.001 gamma(1,.5)[sd]
## 1.000 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MOD8.0
blavCompare(fitref, fit8.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 14 (17.5%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 914.979
##
## WAIC difference & SE:
## -1.763 1.085
##
## LOO estimates:
## object1: 919.086
## object2: 915.378
##
## LOO difference & SE:
## -1.854 1.094
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): -150.998
#Gana
#MODELO COMPUESTO 7.0 + 8.0 (Comorbilidad + Estado del tumor)
model_bayesiano7.0_8.0 <- '
# measurement model
funcionalidad =~
prior("normal(0,15)")*F_br23 + prior("normal(0,15)")*F_c30
sintomas =~
prior("normal(0,15)")*S_br23 + prior("normal(0,15)")*S_c30
# regressions
funcionalidad ~ a*sintomas + Comorbilidad
CV_Gral ~ c*Salud + e*sintomas + d*prior("normal(0,15)")*funcionalidad + Estado_del_tumor
Salud ~ prior("normal(-10,10)")*sintomas + b*funcionalidad
# residual correlations
'
fit7.0_8.0 <- bsem(
model = model_bayesiano7.0_8.0,
data = datos,
auto.var = TRUE,
auto.fix.first = TRUE,
auto.cov.lv.x = TRUE,
sample = SAMPLE,
burnin = BURNIN,
n.chains = CHAINS)
## Warning: There were 18 divergent transitions after warmup. See
## https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
## to find out why this is a problem and how to eliminate them.
## Warning: There were 17 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
## https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
## Warning: Examine the pairs() plot to diagnose sampling problems
## Warning: The largest R-hat is 1.17, indicating chains have not mixed.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#r-hat
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
## Warning: blavaan WARNING: at least one parameter has a psrf > 1.2.
## Computing posterior predictives...
## Warning: blavaan WARNING: Small effective sample sizes (< 100) for some
## parameters.
summary(fit7.0_8.0,standardized = TRUE)
## ** WARNING ** blavaan (0.4-1) did NOT converge after 2500 adapt+burnin iterations
## ** WARNING ** Proceed with caution
##
## Number of observations 80
##
## Number of missing patterns 1
##
## Statistic MargLogLik PPP
## Value -688.705 0.105
##
## Latent Variables:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad =~
## F_br23 1.000 0.204 0.466
## F_c30 1.412 0.153 1.148 1.749 0.288 0.695
## sintomas =~
## S_br23 1.000 0.328 0.578
## S_c30 0.725 6.053 -22.479 3.293 0.238 0.614
## Rhat Prior
##
##
## 1.010 normal(0,15)
##
##
## 3.528 normal(0,15)
##
## Regressions:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## funcionalidad ~
## sintomas (a) -0.581 3.903 -2.322 14.368 -0.935 -0.935
## Comorbildd 0.027 0.093 -0.127 0.184 0.130 0.062
## CV_Gral ~
## Salud (c) 0.677 0.120 0.391 0.855 0.677 0.706
## sintomas (e) -1.301 7.439 -16.432 11.568 -0.427 -0.238
## funcionldd (d) 0.300 4.531 -8.815 8.472 0.061 0.034
## Estd_dl_tm -0.173 0.167 -0.498 0.157 -0.173 -0.046
## Salud ~
## sintomas -4.058 11.729 -25.513 13.945 -1.332 -0.711
## funcionldd (b) 0.701 7.287 -13.124 11.958 0.143 0.076
## Rhat Prior
##
## 3.565 normal(0,10)
## 1.029 normal(0,10)
##
## 1.011 normal(0,10)
## 1.008 normal(0,10)
## 1.009 normal(0,10)
## 1.000 normal(0,10)
##
## 1.029 normal(-10,10)
## 1.016 normal(0,10)
##
## Intercepts:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 2.298 0.170 1.991 2.604 2.298 5.246
## .F_c30 2.373 0.233 1.957 2.780 2.373 5.721
## .S_br23 1.765 0.064 1.641 1.891 1.765 3.112
## .S_c30 2.164 0.090 1.989 2.340 2.164 5.589
## .CV_Gral 0.929 0.485 0.065 1.945 0.929 0.518
## .Salud 3.450 0.591 2.221 4.495 3.450 1.843
## .funcionalidad 0.000 0.000 0.000
## sintomas 0.000 0.000 0.000
## Rhat Prior
## 1.024 normal(0,32)
## 1.027 normal(0,32)
## 1.000 normal(0,32)
## 1.000 normal(0,32)
## 1.001 normal(0,10)
## 1.011 normal(0,10)
##
##
##
## Variances:
## Estimate Post.SD pi.lower pi.upper Std.lv Std.all
## .F_br23 0.150 0.029 0.101 0.216 0.150 0.783
## .F_c30 0.089 0.028 0.039 0.149 0.089 0.517
## .S_br23 0.214 0.053 0.146 0.369 0.214 0.665
## .S_c30 0.093 0.034 0.019 0.161 0.093 0.622
## .CV_Gral 0.410 0.107 0.154 0.612 0.410 0.127
## .Salud 1.355 0.346 0.625 2.038 1.355 0.386
## .funcionalidad 0.005 0.008 0.000 0.028 0.122 0.122
## sintomas 0.108 0.049 0.001 0.209 1.000 1.000
## Rhat Prior
## 1.005 gamma(1,.5)[sd]
## 1.012 gamma(1,.5)[sd]
## 1.424 gamma(1,.5)[sd]
## 1.013 gamma(1,.5)[sd]
## 1.009 gamma(1,.5)[sd]
## 1.008 gamma(1,.5)[sd]
## 1.060 gamma(1,.5)[sd]
## 1.224 gamma(1,.5)[sd]
#COMPARACION MODREF Vs MODCOMPUESTO 7.0 + 8.0
blavCompare(fitref, fit7.0_8.0)
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning: Some Pareto k diagnostic values are slightly high. See help('pareto-k-diagnostic') for details.
## Warning:
## 15 (18.8%) p_waic estimates greater than 0.4. We recommend trying loo instead.
## Warning:
## 20 (25.0%) p_waic estimates greater than 0.4. We recommend trying loo instead.
##
## WAIC estimates:
## object1: 918.504
## object2: 917.662
##
## WAIC difference & SE:
## -0.421 2.598
##
## LOO estimates:
## object1: 919.086
## object2: 918.368
##
## LOO difference & SE:
## -0.359 2.603
##
## Laplace approximation to the log-Bayes factor
## (experimental; positive values favor object1): 14.539
#Gana