r - Loop does not print function output -


i'm trying make loop gives me bootstrapped confidence intervals regression analysis 1 intercept , 3 coefficients. programming bootstrapping function worked well.

the problem have adress each object of regression within function boot.ci index (like index=1), because boot.ci doesn't know names of regression model coefficients.

so did following:

for (i in 2:inputnumberobjects)   {    cat(paste("boot confidence intervals coefficient ", inputnamesobjects[i], ":\n\n", sep=""))    boot.ci(bootresults, type = "bca", index=i) ### result coefficients   } 

before loop spefified number of objects , names of objects.

the problem is, function somehow seems ignore boot.ci function within loop.

for example if names of objects inputnamesobjects <- c("a", "b", "c", "d")

then following output:

boot confidence intervals coefficient a:  boot confidence intervals coefficient b:  boot confidence intervals coefficient c:  boot confidence intervals coefficient d: 

what didn't get, results of boot.ci

if i#m not using loop , instead use like:

boot.ci(bootresults, type = "bca", index=2) 

everything works fine.

any ideas?

i'm using example data function boot.ci since haven't included any. functions need forced print when they're inside other functions, using function print. copy format of this:

library(boot) ratio <- function(d, w) sum(d$x * w)/sum(d$u * w) city.boot <- boot(city, ratio, r = 999, stype = "w", sim = "ordinary")  (i in letters[1:5]) {    cat("this number:\n", i, "\n")    print(boot.ci(city.boot, conf = c(0.90, 0.95),type = c("bca"))) } 

notice don't need paste inside of cat. in general avoid cat print gentler function. using cat can lead annoying messages hard later.

in future, please supply reproducible examples! (and let know packages you're using!)


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -