Re: [R] Inquiry about bandwidth rescaling in Ksmooth
Dear Bert, Thank you very much for your quick reply. I have tested this, and it indeed appears to be the source of the discrepancy I observed. My apologies for overlooking this in the documentation and thank you for clarifying. Cheers, Jan From: Bert Gunter Sent: Thursday, 26 October 2023 20:19 To: Jan Failenschmid Cc: r-help@r-project.org Subject: Re: [R] Inquiry about bandwidth rescaling in Ksmooth Apologies in advance if my comments don't help, in which case, no need to respond, but I noted in ?ksmooth: "bandwidth the bandwidth. The kernels are scaled so that their quartiles (viewed as probability densities) are at ± 0.25*bandwidth." So, could this be a source of the discrepancies you cited? Given that ?ksmooth explicitly says: "Note: This function was implemented for compatibility with S, although it is nowhere near as slow as the S function. Better kernel smoothers are available in other packages such as KernSmooth." One wonder why you bother with it at all? (That was rhetorical -- do not answer). Cheers, Bert On Thu, Oct 26, 2023 at 11:06 AM Jan Failenschmid via R-help wrote: > > Dear Sir, Madam, or to whom this may concern, > > my name is Jan Failenschmid and I am a Ph.D. student at Tilburg University. > For my project I have been looking into different types of kernel regression > estimators and corresponding R functions. > While comparing different functions I noticed that stats::ksmooth returned > different estimates for the same bandwidth > as other kernel regression estimators that should be equivalent (i.e. the > local polynomial estimators KernSmooth::locpoly and > locpol::locpol with degree 0). However, when optimizing the bandwidth of > ksmooth separately using the same loss function, I find comparable estimates > to the other two estimators for a (larger) different bandwidth. To confirm > this, I wrote my own Nadaraya-Watson kernel regression estimator, which is > consistent with the two local polynomial estimators and shows the same > discordance with ksmooth. > > This led me to the suspicion that the bandwidth that is passed to kmooth is > rescaled or transformed within the function. Unfortunately, I was not able to > confirm this with either the code of the function or the documentation. It > would be of great help to me if you could clarify this for me. > > Thank you very much for your time and help in advance. > > Kind regards, > > Jan Failenschmid > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Inquiry about bandwidth rescaling in Ksmooth
Apologies in advance if my comments don't help, in which case, no need to respond, but I noted in ?ksmooth: "bandwidth the bandwidth. The kernels are scaled so that their quartiles (viewed as probability densities) are at ± 0.25*bandwidth." So, could this be a source of the discrepancies you cited? Given that ?ksmooth explicitly says: "Note: This function was implemented for compatibility with S, although it is nowhere near as slow as the S function. Better kernel smoothers are available in other packages such as KernSmooth." One wonder why you bother with it at all? (That was rhetorical -- do not answer). Cheers, Bert On Thu, Oct 26, 2023 at 11:06 AM Jan Failenschmid via R-help wrote: > > Dear Sir, Madam, or to whom this may concern, > > my name is Jan Failenschmid and I am a Ph.D. student at Tilburg University. > For my project I have been looking into different types of kernel regression > estimators and corresponding R functions. > While comparing different functions I noticed that stats::ksmooth returned > different estimates for the same bandwidth > as other kernel regression estimators that should be equivalent (i.e. the > local polynomial estimators KernSmooth::locpoly and > locpol::locpol with degree 0). However, when optimizing the bandwidth of > ksmooth separately using the same loss function, I find comparable estimates > to the other two estimators for a (larger) different bandwidth. To confirm > this, I wrote my own Nadaraya-Watson kernel regression estimator, which is > consistent with the two local polynomial estimators and shows the same > discordance with ksmooth. > > This led me to the suspicion that the bandwidth that is passed to kmooth is > rescaled or transformed within the function. Unfortunately, I was not able to > confirm this with either the code of the function or the documentation. It > would be of great help to me if you could clarify this for me. > > Thank you very much for your time and help in advance. > > Kind regards, > > Jan Failenschmid > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Inquiry about bandwidth rescaling in Ksmooth
Dear Sir, Madam, or to whom this may concern, my name is Jan Failenschmid and I am a Ph.D. student at Tilburg University. For my project I have been looking into different types of kernel regression estimators and corresponding R functions. While comparing different functions I noticed that stats::ksmooth returned different estimates for the same bandwidth as other kernel regression estimators that should be equivalent (i.e. the local polynomial estimators KernSmooth::locpoly and locpol::locpol with degree 0). However, when optimizing the bandwidth of ksmooth separately using the same loss function, I find comparable estimates to the other two estimators for a (larger) different bandwidth. To confirm this, I wrote my own Nadaraya-Watson kernel regression estimator, which is consistent with the two local polynomial estimators and shows the same discordance with ksmooth. This led me to the suspicion that the bandwidth that is passed to kmooth is rescaled or transformed within the function. Unfortunately, I was not able to confirm this with either the code of the function or the documentation. It would be of great help to me if you could clarify this for me. Thank you very much for your time and help in advance. Kind regards, Jan Failenschmid [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.