Content deleted Content added
→Density estimation in R with a diagonal bandwidth matrix: Added code for diagonal bandwidth KDE using ks library. |
|||
Line 139:
f <- npudens(~eruptions+waiting,data=faithful)
plot(f,view="fixed",neval=100,phi=30,main="",xtrim=-0.2)
</pre>
Computing kernel density estimates with diagonal bandwidth selectors is also available in the <tt>ks</tt> library, using the <tt>Hpi.diag()</tt> function. To produce a 3D plot similar to that from <tt>npudens()</tt>, the option <tt>display="persp"<tt> is added.
<pre style="overflow:auto;">
library(ks)
data(faithful)
H <- Hpi.diag(x=faithful)
fhat <- kde(x=faithful, H=H)
plot(fhat, display="persp")
</pre>
|