[R] pulling out coefficients

Rui Barradas ruipbarradas at sapo.pt
Mon Sep 23 22:43:00 CEST 2013


Hello,

Maybe something like the following.


cf <- vector("list", 500)
for (i in 1:500){
	s <- paste0("Chain",i)
	cf[[i]] <- mi.txt.i at imp[[s]]$cont.y.obs at model$coefficients
}


Hope this helps,

Rui Barradas

Em 23-09-2013 14:17, Andrea Lamont escreveu:
> Hello:
>
> I am running a simulation in which need to pull out the coefficients of a
> multiply imputed object for each simulation.
>
> The coefficientscould be called using the following command:
> mi.txt.i at imp$Chain1$cont.y.obs at model$coefficients
>
> THis gives me the coefficients for the first imputation (Chain 1). What I
> would like to do, however, is pull out the coefficients for all Chains but
> cannot figure out how.In other words, I want the coefficients from
> Chain1-Chain500 saved in a matrix.
>
> mi.txt.i at imp$Chain1$cont.y.obs at model$coefficients
> mi.txt.i at imp$Chain2$cont.y.obs at model$coefficients
> mi.txt.i at imp$Chain3$cont.y.obs at model$coefficients
> ...
> mi.txt.i at imp$Chain500$cont.y.obs at model$coefficients
>
> I tried using paste:
>
> for (i in 1:500){
> s=paste("Chain",i)
> mi.txt.i at imp$s$cont.y.obs at model$coefficients
> ...}
>
> But that did not work.  I also tried other variations of this looping with
> no avail.
>
> Thoughts on how to use a loop to call coefficients?
>
> Thanks,
>



More information about the R-help mailing list