[R] boot and coefficients
Mpiktas
mpiktas at delfi.lt
Wed Nov 20 16:19:25 CET 2002
Hi,
> R1.61, WinNT
>
> Dear listers - I am trying to implement the SPLUS example for boostrapping
> coefficients from a linear model -
>
> boot(data.frame, coef(eval(model$call)))
>
> I get errors saying that my statistic is not defined and that the
> replicates are not defined. Changing this to -
>
> boot(recTTM, statisitic=coef(eval(mod$call)),R=999)
>
> still gives the error about the statistic. Clearly I do not understand
> what the statisitic is and how to make the coefficients a function as in
> the examples in the help... can someone guide me on syntax?
>
Try ?boot. There are some examples and good explanation of arguments
boot function needs.
As for a simple explanation, in your case (with default parameters)
statistic must be a function of two arguments, first argument the data,
and second the vector of indices which define the bootstrap sample. For
example let us say that our data is my.data, and we want to bootstrap
linear regression coefficients, where dependent variable is the first
column of my.data, and independent variables are the rest columns of
my.data. Then the call to boot function would be
boot(my.data,statistic=boot.fun,R=999),
where
boot.fun <-
function(data,ind) {
coef(lsfit(data[ind,-1],data[ind,1],intercept=TRUE))
#Note: we could use the lm, but if we only need the regression
#coefficients, lsfit is faster
}
Hope it helps
Vaidotas Zemlys
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list