Displaying 2 results from an estimated 2 matches for "bscoefsampl".
Did you mean:
bscoefsample
1997 Oct 17
1
R-beta: more model.matrix
....
The textbook mentioned using bootstrap samples of regression
coefficients for assessing variability. I decided to show them
reasonably effective ways of doing the resampling.
The following is a function I wrote to create bootstrap samples of
coefficients from a fitted linear regression model.
bsCoefSample <-
## Construct a bootstrap sample of coefficients from a
## fitted regression model
function(fittedModel, Nsampl, ...)
{
coef(fittedModel) +
qr.coef(qr(model.matrix(fittedModel)),
matrix(sample(resid(fittedModel),
length(resid(fittedModel)) * Nsampl,
repl =...
1997 Oct 28
1
R-beta: Assigning column names in a data frame
...fitted model, then
taking the QR decomposition of that. I discovered that it was in fact
easier to accomplish the bootstrapping in R because the QR
decomposition of the model matrix is stored with the fitted model.
So far, so good. Then I got fancy and returned the result as a
data frame.
"bsCoefSample" <-
## Construct a bootstrap sample of coefficients from a
## fitted regression model
function(fittedModel, Nsampl)
{
value <-
as.data.frame(t(coef(fittedModel) +
qr.coef(fittedModel$qr,
matrix(sample(resid(fittedModel),
length(resid(fittedModel)) * Nsam...