全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
5349 3
2013-05-28
现在我用极大似然估计已经算出各个参数值,但是这些参数的t检验值是怎么求的啊?能不能给我公式,还有我的函数中出现了这样的一个问题
错误于optim(params, LL, method = "BFGS", hessian = TRUE, control = list(fnscale = -1)) :
  non-finite finite-difference value [6]
二维码

扫码加我 拉你入群

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

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

全部回复
2013-5-29 07:02:13
Here is an example to calculate the tValues.

set.seed(2013)
# random generate simulation data with GPD distribution with 3 parameters
alpha<- 1; beta<- 2;

n<- 100;
err<- rnorm(n, sd=0.5)
x <-  rnorm(n)



# model y defined as
y<- alpha+beta*x + err

data<- data.frame(x, y)
write.csv(data, 'c:\\temp\\data.csv')


# define -2*loglikelihood function
LL<-function(params){
  alpha<- params[1]; beta<- params[2]; sigma<- params[3]
  
  linkfun<- alpha+beta*data$x
  
  error<-  data$y-linkfun
  
  ;
  
  f<- (1/(sigma*sqrt(2*pi))) * exp(-0.5*(error/sigma)**2)
  
  ll<- sum(log(f))
  return(-ll)
}

#optimized with initial condistion


modelResults<- optim(c(0,0,5), LL, method = "BFGS", hessian = TRUE)

std<- sqrt(diag(solve(modelResults$hessian)))
tValue<- modelResults$par/std
estiamtes<- cbind(modelResults$par, tValue)
estiamtes
二维码

扫码加我 拉你入群

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

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

2013-5-29 10:38:15
bobguy 发表于 2013-5-29 07:02
Here is an example to calculate the tValues.

set.seed(2013)
x谢谢阿
二维码

扫码加我 拉你入群

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

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

2016-8-12 18:52:24
bobguy 发表于 2013-5-29 07:02
Here is an example to calculate the tValues.

set.seed(2013)
谢谢,学习了!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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