Hi R-experts,

I want to use the jackknife function from the bootstrap package onto a
linear model.
I can't figure out how to do that. The manual says the following:

# To jackknife functions of more  complex data structures, 
# write theta so that its argument x
#  is the set of observation numbers  
#  and simply  pass as data to jackknife the vector 1,2,..n. 
# For example, to jackknife
# the correlation coefficient from a set of 15 data pairs:      
                        
   xdata <- matrix(rnorm(30),ncol=2)
   n <- 15
   theta <- function(x,xdata){ cor(xdata[x,1],xdata[x,2]) }
   results <- jackknife(1:n,theta,xdata)


So I tried:

  DF <- as.data.frame(matrix(rnorm(250), ncol=5))
  attach(DF)
  model.lm <- formula(V1 ~ V2 + V3 + V4)
  n <- 50
  theta <- function(x, xdata){ lm(model.lm, data=xdata) }
  results <- jackknife(1:n,theta,xdata=DF)

I was not able to find a similar example on the web, so I would really
appreciate some help.

TIA, Mark

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to