楼主: fengbjmu
2919 3

[学习心得] 三次样条插值 cubic spline interpolation [推广有奖]

  • 3关注
  • 16粉丝

已卖:6367份资源

博士生

54%

还不是VIP/贵宾

-

威望
0
论坛币
27040 个
通用积分
502.9753
学术水平
41 点
热心指数
48 点
信用等级
28 点
经验
6445 点
帖子
201
精华
0
在线时间
301 小时
注册时间
2016-10-22
最后登录
2025-7-9

楼主
fengbjmu 发表于 2022-6-25 22:49:05 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
今天学习了三次样条插值的原理,以及stata实现,延伸阅读有matlab以及excel的例子,大家感兴趣可以阅读~

帖子也分为三部分:

一、三次样条插值cubic spline interpolation原理
二、三次样条插值的stata实现
1. mata方法
2. csipolate方法
三、延伸阅读

~~~~~~~~~~~~~~
一、三次样条插值cubic spline interpolation原理

简单来说,为了对缺失的数据点进行插值,同时保证我们插值之后的图形在原有的数据点上一阶导数和二阶导数都是相等的【也就是图形看起来是平滑、没有跳点的,我们就需要使用三次样条插值。这也是这种插值方法的优势所在。

原理步骤为,在两个真实数据点之间插值,采用三次多项式拟合的方法进行拟合;其次对于真实数据点在左右两侧拟合的三次多项式加以限制,即两侧一阶导数和二阶导数相等。

这样得到三次多项式拟合的参数。

二、三次样条插值的stata实现
1. mata方法:上传了一个附件do,也可以看下面的文本。 spline.do (1.14 KB, 需要: 1 个论坛币)


use "https://www.dropbox.com/s/3y3h39dwbgghusp/stata_spline.dta?dl=0"

mata // This line launches the mata system inside Stata

X = st_data((1,36),"x") // This pulls in the x quarterly markers data.

Y = st_data((1,36),"y") // This pulls in the quarterly y data we want to interpolate between.

XX = st_data(.,"xx") // This pulls in the xx monthly markers we want to interpolate at.

A = spline3(X,Y) // This generates the cubic spline coefficients matrix, and stores it in A.

B = spline3eval(A,XX) // This performs the interpolation, and store the values in B.

st_store(.,"yy",B) // This pushes the inpolated figures in B back into the yy variable in Stata.

end



2. csipolate方法:
ssc install csipolate

csipolate creates newvar by averaging non-missing values of yvar and using natural cubic spline interpolation of missing values of yvar, given xvar. That is,  provided that xvar is not missing,



三、延伸阅读

https://columbiaeconomics.com/2012/06/06/stata-do-file-for-cubic-spline-interpolation/





二维码

扫码加我 拉你入群

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

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

关键词:interp Spline inter ATION cubic

沙发
hufg1983(未真实交易用户) 在职认证  发表于 2022-6-26 10:51:50
谢谢分享

藤椅
nkunku(真实交易用户) 发表于 2022-6-27 05:36:13
谢谢分享

板凳
DAY·DAY(未真实交易用户) 在职认证  发表于 2022-9-4 22:00:36
谢谢分享

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-28 06:32