2016-07-25 21 views
0

Ich habe ein festes Design-Regressionsproblem, das ich versuche, Bootstrap BCa Konfidenzintervalle für R zu verwenden. Hier ist ein Beispiel (mit lmRob), aber das ist nur zur Veranschaulichung:R: Bootstrap BCa Konfidenzintervalle für feste Design-Regression

require(robust) 
data(stack.dat) 
stack.rob <- lmRob(Loss ~ ., data = stack.dat) 

summary(stack.rob) 

Call: 
lmRob(formula = Loss ~ ., data = stack.dat) 

Residuals: 
    Min  1Q Median  3Q  Max 
-8.6299 -0.6713 0.3594 1.1507 8.1740 

Coefficients: 
      Estimate Std. Error t value Pr(>|t|)  
(Intercept) -37.65246 5.00256 -7.527 8.29e-07 *** 
Air.Flow  0.79769 0.07129 11.189 2.91e-09 *** 
Water.Temp 0.57734 0.17546 3.291 0.00432 ** 
Acid.Conc. -0.06706 0.06512 -1.030 0.31757  
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 1.837 on 17 degrees of freedom 
Multiple R-Squared: 0.6205 

Test for Bias: 
      statistic p-value 
M-estimate  2.751 0.6004 
LS-estimate  2.640 0.6197 

Es gibt das Boot und die Bootstrap-Pakete in R (und auch Code als gegeben here, aber beide leiten nicht-parametrischen Bootstrap BCA Konfidenzintervall. Dies ist jedoch eine festes Design Regression Setup. I Ich frage mich daher, ob es für Bootstrap-BCa-Konfidenzintervalle eine Fixed-Design-Regression gibt.Ein Beispiel für ein R-Paket oder ähnliches, das lm verwendet, wäre ebenfalls in Ordnung.

Danke!

+0

Vielleicht kann dies [SO Frage] (http://stackoverflow.com/questions/7588388/adjusted-bootstrap-confidence-intervals-bca-with-parametric-bootstrap-in-boot) – Marcel10

+0

Ich habe Probleme mit diesem Beispiel. Wenn es "parametrische" Regression sagt, bedeutet es, dass es von der normalen Verteilung resampling ist. Ich möchte aus den Residuen resample. Ich finde die Boot-Funktion Art von schwer zu folgen. Danke noch einmal! – user3236841

+0

Das Boot-Paket basiert auf dem Buch: Bootstrap-Methoden und ihre Anwendung von A. C. Davison und D. V. Hinkley (1997). Dieser [link] (http://www.epfl.ch/davison/BMA/CUPsample.pdf) enthält einen Teil dieses Buches. Zum Glück enthält es den parametrischen und nicht-parametrischen Bootstrap. – Marcel10

Antwort

0

Ich glaube, dass ich eine Antwort haben, aus dem Beispiel in R Journal of 2002.

require(boot) 
require(robust) 
data(stackloss) 

stack.rob <- lmRob(stack.loss ~ ., data = stackloss) 

lmRob.coef <- function(data, y, pred) { 
    mod <- lmRob(formula = as.formula(eval(paste(y,"~", paste(pred,collapse="+")))) , data = data, control = lmRob.control(mxr = 1000, mxf = 1000, mxs = 1000)) 
    coef(mod) 
} 

lmRob.results <- function(data, y, pred) { 
    mod <- lmRob(formula = as.formula(eval(paste(y,"~", paste(pred,collapse="+")))) , data = data) 
    data.frame(fitted = fitted(mod), residuals = resid(mod)) 
} 

fit.dat <- lmRob.results(data = stackloss, y = "stack.loss", pred = c("Air.Flow", "Water.Temp", "Acid.Conc.")) 

model.fun <- function(data, i, y, pred, fitted.results) { 
    dat <- cbind(data, fitted.results) 
    dat[, y] <- dat$fitted + dat$residuals[i] 
    lmRob.coef(data = dat, y = y, pred = pred) 
} 

lmRob.boot <- boot(data = stackloss, statistic = model.fun, R = 999, y = "stack.loss", pred = c("Air.Flow", "Water.Temp", "Acid.Conc."), fitted.results = fit.dat) 

boot.ci(boot.out=lmRob.boot, type="bca", index=4) 

BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS 
Based on 999 bootstrap replicates 

CALL : 
boot.ci(boot.out = lmRob.boot, type = "bca", index = 4) 

Intervals : 
Level  BCa   
95% (-0.2644, 0.2963) 
Calculations and Intervals on Original Scale 

Nächstes Ziel Modifizieren Gewichte für die verschiedenen Fälle, in das Modell aufzunehmen.