Which one is the first and which one the second function?

I'm not familiar with `lavaan`

, so can't really help you on that aspect, what I do see is that with the example file `summary()$PE`

is a data.frame, so to take values out you need to specify both which rows and which columns.

Also, `boot`

can handle a function that returns a singe statistics for each replicate, or a vector (where each element is a different statistics to estimate), but not a data.frame (what would it mean?).

As to your `smry$PE[22:23,"est"]`

it seems to work with the example data:

```
> boot_statistic <- function(dataset, coefficients) {
+ d = dataset[coefficients,]
+ model = Model_EN2
+ fit_boot <- lavaan::sem(model, d)
+ {sink(nullfile()); smry <- summary(fit_boot);sink()} # recover summary without printing
+ return(smry$PE[22:23,"est"])
+ }
> (res <- boot::boot(data = PoliticalDemocracy, statistic = boot_statistic, R = 10))
ORDINARY NONPARAMETRIC BOOTSTRAP
Call:
boot::boot(data = PoliticalDemocracy, statistic = boot_statistic,
R = 10)
Bootstrap Statistics :
original bias std. error
t1* 0.1198065 0.003608058 0.06622563
t2* 0.4667026 -0.003862914 0.05968241
Warning messages:
1: In lav_object_post_check(object) :
lavaan WARNING: some estimated lv variances are negative
2: In lav_object_post_check(object) :
lavaan WARNING: some estimated lv variances are negative
> boot::boot.ci(res, type="perc", index=1)
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 10 bootstrap replicates
CALL :
boot::boot.ci(boot.out = res, type = "perc", index = 1)
Intervals :
Level Percentile
95% ( 0.0418, 0.3229 )
Calculations and Intervals on Original Scale
Warning : Percentile Intervals used Extreme Quantiles
Some percentile intervals may be unstable
Warning message:
In norm.inter(t, alpha) : extreme order statistics used as endpoints
> boot::boot.ci(res, type="perc", index=2)
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 10 bootstrap replicates
CALL :
boot::boot.ci(boot.out = res, type = "perc", index = 2)
Intervals :
Level Percentile
95% ( 0.3352, 0.5205 )
Calculations and Intervals on Original Scale
Warning : Percentile Intervals used Extreme Quantiles
Some percentile intervals may be unstable
Warning message:
In norm.inter(t, alpha) : extreme order statistics used as endpoints
```