楼主: beiwei
2279 3

[程序分享] code for nonlinear least square using newton raphson method [推广有奖]

  • 0关注
  • 2粉丝

VIP

已卖:129份资源

本科生

37%

还不是VIP/贵宾

-

威望
0
论坛币
1644 个
通用积分
1.0433
学术水平
2 点
热心指数
2 点
信用等级
0 点
经验
1076 点
帖子
49
精华
0
在线时间
91 小时
注册时间
2005-4-23
最后登录
2025-4-28

楼主
beiwei 发表于 2012-12-4 06:53:01 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
NLS.pdf (102.99 KB, 需要: 10 个论坛币)

找到这个东东以后我骂了句粗话,早找到就好了,写这个code写得我晕了,function不同的要要稍微改改。

必须跟大家分享了。


二维码

扫码加我 拉你入群

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

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

关键词:Nonlinear nonlinea Nonline Square Method method least

已有 1 人评分经验 收起 理由
ltx5151 + 20 根据规定进行奖励

总评分: 经验 + 20   查看全部评分

沙发
beiwei(未真实交易用户) 发表于 2012-12-4 07:02:55
精彩部分,免费分享,欲知详情请下载全文。

#Exponential model
fun=function(th,x){
y = th[2]+((th[1]-th[2])*exp(-th[3]*x))
return(y)
}
fun(th,x) #try it out -- should give you fitted values
#Calculate the residual sum of squares
resid=function(th,x,y){
yhat=fun(th,x)
rss=t(y-yhat)%*%(y-yhat)
return(rss)
}
resid(th,x,y) #try it out -- should give a scalar for output
#Calulate the Jacobian matrix
firder=function(th,x){
j1=exp(-th[3]*x)
j2=1-j1
j3=-x*(th[1]-th[2])*exp(-th[3]*x)
j=cbind(j1,j2,j3)
return(j)
}
firder(th,x)
#Calculate the Second Derivatives
secder=function(th,x){
h11=rep(0,times=length(x))
h21=h11
h22=h11
h31=-x*exp(-th[3]*x)
h32=-h31
h33=(x**2)*((th[1]-th[2])*exp(-th[3]*x))
hmat=cbind(h11,h21,h22,h31,h32,h33)
return(hmat)
}
secder(th,x)
#Gradient evaluated at "th"
grad=function(th,x,y){
fd=firder(th,x)
hm=secder(th,x)
yhat=fun(th,x)
r=y-yhat

藤椅
aibieli731001(未真实交易用户) 发表于 2012-12-4 08:07:28
10个币?

板凳
yqweng(未真实交易用户) 在职认证  发表于 2012-12-4 08:54:08
具体什么用处?

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-7 23:39