楼主: dujiaomao
2987 4

help(density.lf [推广有奖]

  • 0关注
  • 0粉丝

本科生

0%

还不是VIP/贵宾

-

威望
0
论坛币
1468 个
通用积分
25.6120
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
456 点
帖子
25
精华
0
在线时间
102 小时
注册时间
2005-5-27
最后登录
2025-12-5

楼主
dujiaomao 发表于 2007-6-12 00:22:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
###########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)
二维码

扫码加我 拉你入群

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

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

关键词:Density Help elp sit Simulation Help Density

回帖推荐

yiyo900 发表于4楼  查看完整内容

histogram bin (hb) biased cross-validation (bcv) Sheather & Jones pilot estimation of derivatives (sj). fit=density(x,width="nrd",window="gaussian",n=81,from=-4,to=4) xdensity1=density(x,n=81,width=0.4544,from=-4,to=4,cut=o.75) xdensity2=density.lf(x,n=81,width=0.4544,from=-4,to=4,deg=0,cut=0.75) 毕竟function density与density.lf并不相同.

yiyo900 发表于2楼  查看完整内容

use renorm=T,the integral will be estimated numerically and rescaled. fit1$y fit2$y 1)bandwidth 3)weight function

本帖被以下文库推荐

沙发
yiyo900 发表于 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.

已有 1 人评分论坛币 学术水平 热心指数 收起 理由
crystal8832 + 10 + 1 + 1 精彩帖子

总评分: 论坛币 + 10  学术水平 + 1  热心指数 + 1   查看全部评分

藤椅
dujiaomao 发表于 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

板凳
yiyo900 发表于 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并不相同.

已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
crystal8832 + 10 + 1 + 1 + 1 精彩帖子

总评分: 论坛币 + 10  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

报纸
m8843620 发表于 2011-5-25 11:50:37
路过 学习一下

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 21:56