EVOLUTION-MANAGER
Edit File: smooth.f.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Smooth Distributions on Data Points</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for smooth.f {boot}"><tr><td>smooth.f {boot}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Smooth Distributions on Data Points </h2> <h3>Description</h3> <p>This function uses the method of frequency smoothing to find a distribution on a data set which has a required value, <code>theta</code>, of the statistic of interest. The method results in distributions which vary smoothly with <code>theta</code>. </p> <h3>Usage</h3> <pre> smooth.f(theta, boot.out, index = 1, t = boot.out$t[, index], width = 0.5) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>theta</code></td> <td> <p>The required value for the statistic of interest. If <code>theta</code> is a vector, a separate distribution will be found for each element of <code>theta</code>. </p> </td></tr> <tr valign="top"><td><code>boot.out</code></td> <td> <p>A bootstrap output object returned by a call to <code>boot</code>. </p> </td></tr> <tr valign="top"><td><code>index</code></td> <td> <p>The index of the variable of interest in the output of <code>boot.out$statistic</code>. This argument is ignored if <code>t</code> is supplied. <code>index</code> must be a scalar. </p> </td></tr> <tr valign="top"><td><code>t</code></td> <td> <p>The bootstrap values of the statistic of interest. This must be a vector of length <code>boot.out$R</code> and the values must be in the same order as the bootstrap replicates in <code>boot.out</code>. </p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>The standardized width for the kernel smoothing. The smoothing uses a value of <code>width*s</code> for epsilon, where <code>s</code> is the bootstrap estimate of the standard error of the statistic of interest. <code>width</code> should take a value in the range (0.2, 1) to produce a reasonable smoothed distribution. If <code>width</code> is too large then the distribution becomes closer to uniform. </p> </td></tr></table> <h3>Details</h3> <p>The new distributional weights are found by applying a normal kernel smoother to the observed values of <code>t</code> weighted by the observed frequencies in the bootstrap simulation. The resulting distribution may not have parameter value exactly equal to the required value <code>theta</code> but it will typically have a value which is close to <code>theta</code>. The details of how this method works can be found in Davison, Hinkley and Worton (1995) and Section 3.9.2 of Davison and Hinkley (1997). </p> <h3>Value</h3> <p>If <code>length(theta)</code> is 1 then a vector with the same length as the data set <code>boot.out$data</code> is returned. The value in position <code>i</code> is the probability to be given to the data point in position <code>i</code> so that the distribution has parameter value approximately equal to <code>theta</code>. If <code>length(theta)</code> is bigger than 1 then the returned value is a matrix with <code>length(theta)</code> rows each of which corresponds to a distribution with the parameter value approximately equal to the corresponding value of <code>theta</code>. </p> <h3>References</h3> <p>Davison, A.C. and Hinkley, D.V. (1997) <em>Bootstrap Methods and Their Application</em>. Cambridge University Press. </p> <p>Davison, A.C., Hinkley, D.V. and Worton, B.J. (1995) Accurate and efficient construction of bootstrap likelihoods. <em>Statistics and Computing</em>, <b>5</b>, 257–264. </p> <h3>See Also</h3> <p><code><a href="boot.html">boot</a></code>, <code><a href="exp.tilt.html">exp.tilt</a></code>, <code><a href="tilt.boot.html">tilt.boot</a></code> </p> <h3>Examples</h3> <pre> # Example 9.8 of Davison and Hinkley (1997) requires tilting the resampling # distribution of the studentized statistic to be centred at the observed # value of the test statistic 1.84. In the book exponential tilting was used # but it is also possible to use smooth.f. grav1 <- gravity[as.numeric(gravity[, 2]) >= 7, ] grav.fun <- function(dat, w, orig) { strata <- tapply(dat[, 2], as.numeric(dat[, 2])) d <- dat[, 1] ns <- tabulate(strata) w <- w/tapply(w, strata, sum)[strata] mns <- as.vector(tapply(d * w, strata, sum)) # drop names mn2 <- tapply(d * d * w, strata, sum) s2hat <- sum((mn2 - mns^2)/ns) c(mns[2] - mns[1], s2hat, (mns[2]-mns[1]-orig)/sqrt(s2hat)) } grav.z0 <- grav.fun(grav1, rep(1, 26), 0) grav.boot <- boot(grav1, grav.fun, R = 499, stype = "w", strata = grav1[, 2], orig = grav.z0[1]) grav.sm <- smooth.f(grav.z0[3], grav.boot, index = 3) # Now we can run another bootstrap using these weights grav.boot2 <- boot(grav1, grav.fun, R = 499, stype = "w", strata = grav1[, 2], orig = grav.z0[1], weights = grav.sm) # Estimated p-values can be found from these as follows mean(grav.boot$t[, 3] >= grav.z0[3]) imp.prob(grav.boot2, t0 = -grav.z0[3], t = -grav.boot2$t[, 3]) # Note that for the importance sampling probability we must # multiply everything by -1 to ensure that we find the correct # probability. Raw resampling is not reliable for probabilities # greater than 0.5. Thus 1 - imp.prob(grav.boot2, index = 3, t0 = grav.z0[3])$raw # can give very strange results (negative probabilities). </pre> <hr /><div style="text-align: center;">[Package <em>boot</em> version 1.3-22 <a href="00Index.html">Index</a>]</div> </body></html>