attach(abc)•>Clspr"> attach(abc)•>Clspr" />
欢迎来到天天文库
浏览记录
ID:38264689
大小:26.32 KB
页数:6页
时间:2019-06-07
《R语言菜鸟联系笔记 9》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、•基于平安银行从2013-1-4值2013-12-31的日收盘价,计算其日对数收益•>abc<-read.table("C:/Users/user/Desktop/5-1.txt",header=T)•>attach(abc)•>Clsprc•[1]15.9916.3016.0015.8615.8715.5417.0917.6117.8217.7418.3319.7020.4820.0519.4519.1521.07•[18]21.3821.3321.1022.4322.0121.7821.8620.8520.75
2、20.9020.8120.3019.6019.1220.0120.8521.02•[35]23.0023.0621.7523.9324.2523.7422.8622.6321.7222.0921.6722.2021.3521.5023.1022.9623.03•[52]22.7622.1422.1520.0220.1220.3920.4420.4519.9319.9419.4019.4118.9018.5618.7518.4919.10•[69]20.2420.2319.0819.4018.8318.7018.91
3、19.7320.3120.2520.3820.1320.1919.9219.2919.3020.31•[86]20.3920.9821.1021.1620.5220.6920.4221.6021.2821.2020.9920.9121.1320.8120.1319.5318.79•[103]19.0619.2419.7319.2411.1811.2810.159.989.769.609.979.759.609.339.379.378.99•[120]9.009.4010.3410.3410.5110.3810.14
4、9.829.439.429.969.769.819.649.419.689.59•[137]9.929.829.949.929.939.899.8510.3310.5010.4310.2010.5810.7911.0010.9110.9510.62•[154]10.9010.8810.6310.6410.6110.7511.2011.0811.0312.1312.4412.6913.4713.2113.2012.7912.79•[171]12.8812.2712.0311.6611.9011.8812.2112.5
5、512.2812.6912.4912.2112.0112.0012.2012.3312.05•[188]12.5813.0013.4313.1314.1214.4013.9013.8713.5613.6613.1513.2713.3313.4014.0513.3313.14•[205]13.3614.0913.8213.9913.9413.6713.5013.4713.5713.6213.6013.7513.5413.6013.4313.2913.19•[222]13.2912.8412.7212.5512.751
6、2.7212.7612.5011.9111.9511.7011.7211.4511.7511.7412.25•>length(Clsprc)•[1]237•>fun1<-function(a){•+#fr<-0•+r<-c()•+r[0]<-0•+for(iin1:(length(a)-1)){•+r[i+1]<-log(a[i+1]/a[i])•+#r[i+1]<-r[i]+r[i+1]•+}•+return(r)•+}•>fun1(Clsprc)•[1]NA0.0192015810-0.0185763856-0
7、.00878850600.0006303183-0.02101318960.0950761522•[8]0.02997342540.0118544995-0.00449944520.03271708500.07207957390.0388301644-0.0212196464•[15]-0.0303820837-0.01554435440.09554751220.0146056778-0.0023413731-0.01084149200.0611263081•[22]-0.0189024530-0.01050477
8、800.0036663652-0.0473045345-0.00480770160.0072029123-0.0043155186•[29]-0.0248127544-0.0350913198-0.02479465860.04549724100.04112179960.00812041720.0900198505•[36]0.0026052989-0.058
此文档下载收益归作者所有