Extract latent process with standard error

Hello all,

I have a latent process in my model and I want to extract the estimates + sd.
I know I can extract the estimates by

samples <- extract(fit,names)
h_std <- colMeans(samples$h_std[,1:n]),

but I do not know how to extract the standard error.
I know I have access to them in

                        mean      se_mean           sd          2.5%           25%           50%           75%         97.5%     n_eff      Rhat
h_std[1]       -5.979764e-01 0.0190374220  0.602016142 -1.739978e+00 -1.001197e+00 -6.214541e-01 -1.970079e-01  5.476297e-01 1000.0000 0.9994820
h_std[2]       -6.171249e-02 0.0318269724  1.006457237 -2.121432e+00 -7.216970e-01 -6.276145e-02  6.389514e-01  1.882928e+00 1000.0000 0.9994714
h_std[3]       -1.315968e-02 0.0315094103  0.996415042 -1.976217e+00 -6.579907e-01  1.864857e-03  6.226525e-01  1.875075e+00 1000.0000 0.9989995
h_std[4]       -1.593478e-02 0.0308350221  0.975089015 -1.952526e+00 -6.411331e-01 -2.344308e-02  6.284351e-01  1.873554e+00 1000.0000 0.9990631
h_std[5]        7.105449e-02 0.0326051739  1.031066130 -1.896089e+00 -6.659897e-01  9.702147e-02  7.969232e-01  2.075422e+00 1000.0000 0.9999808
h_std[6]        8.348700e-02 0.0301578584  0.953675219 -1.823335e+00 -5.661741e-01  9.399826e-02  7.360847e-01  1.892828e+00 1000.0000 0.9990071
h_std[7]        1.013351e-01 0.0333141938  1.053487307 -2.106535e+00 -5.802876e-01  1.700795e-01  7.886953e-01  2.150203e+00 1000.0000 0.9990738

I have only managed to extract h_std[1],h_std[2],…, but is there a way to extract all the h_std in one go?



sum_df = summary(fit)$summary
sum_df[startsWith(rownames(sum_df), "h_std"), ]

Should give you just the rows that have h_std info in them. If you only want se_mean in those rows, you could do:

sum_df[startsWith(rownames(sum_df), "h_std"), "se_mean"]

That what you were looking for?

1 Like

Thanks for the response! This was exactly what I was looking for! :) Thank you very much!

1 Like