全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2961 4
2007-06-12
###########question one,, I don't know why xdensity1$y and

########## xdensity2$y are the same for different degree. Thanks



z=seq(-4,4,by=0.1)
library(locfit)
data=dnorm(z)
x=rnorm(2000)
xdensity1=density.lf(x,n=81,width=0.4544,deg=1,from=-4,to=4)
xdensity2=density.lf(x,n=81,width=0.4544,deg=0,from=-4,to=4)

xdensity1$y
xdensity2$y

############Question two: local_density performs more bad than ##########Rosenblatt_Parzen ??

text1=c("Rosenblatt-Parzen and local density method 500 times")

z=seq(-4,4,by=0.1)

data=dnorm(z)

library(locfit)

madevector1=1:500

madevector2=1:500

bd_simulation=function(){

for(i in 1:500){

x=rnorm(250)

xdensity1=density(x,bw=0.2272,kernel="gaussian",n=81,from=-4,to=4)

xdensity2=density.lf(x,n=81,width=0.4544,deg=1,from=-4,to=4)

madevector1=mean(abs(xdensity1$y-data))

madevector2=mean(abs(xdensity2$y-data))

}

madevector=data.frame(Rosenblatt_Parzen=madevector1,local_density=madevector2)

return(madevector)



}





y=bd_simulation()

boxplot(data.frame(y))

title(text1,cex.main=1.2)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2007-6-16 10:50:00

1.Local likelihood density estimates may not integrate exactly to 1.

use renorm=T,the integral will be estimated numerically and rescaled.

fit1=density.lf(x,n=81,width=0.4544,from=-4,to=4,deg=0,renorm=T)

fit1$y

fit2=density.lf(x,n=81,width=0.4544,from=-4,to=4,deg=1,renorm=T)

fit2$y

2.在下述条件相同之下比较,就会得到你要的结果.

1)bandwidth

2)degree of local polynomial

3)weight function

4)fitting criterion.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-6-19 23:41:00

非常感谢兄弟的建议

还想请问一下就是

xdensity1=density(x,bw="nrd",kernel="gaussian",n=81,from=-4,to=4)
xdensity2=density.lf(x,n=81,width=0.4544,deg=0,from=-4,to=4,renorm=T)

如果width选择好的话,前两段应该是一样的

请问width如何在R里选择,比如说选择nrd, plug_in, cv

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-6-20 10:54:00

1.目前我安装的是s-plus,s-plus的bandwidth methods有

histogram bin (hb)

normal reference density (nrd)

biased cross-validation (bcv)

unbiased cross-validation (ucv)

Sheather & Jones pilot estimation of derivatives (sj).

选择方式如下:

fit=density(x,width="nrd",window="gaussian",n=81,from=-4,to=4)

2.下面两段会接近,但不会完全相同.

xdensity1=density(x,n=81,width=0.4544,from=-4,to=4,cut=o.75)

xdensity1$y

xdensity2=density.lf(x,n=81,width=0.4544,from=-4,to=4,deg=0,cut=0.75)

xdensity2$y

毕竟function density与density.lf并不相同.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-5-25 11:50:37
路过 学习一下
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群