当前位置:首页 » 股市行情 » r语言模拟股票价格
扩展阅读
十连阳股票怎么看 2025-06-27 06:47:49
200006 2025-06-27 06:46:59

r语言模拟股票价格

发布时间: 2021-06-19 22:42:19

Ⅰ 怎么利用r语言做em算法估计混合双参数指数分布的数值模拟

建议你先看一下这本书:
Modeling Survival Data Using Frailty Models

chap 2. Some Parametric Methods
2.1 Introction . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Exponential Distribution . . . . . . . . . . . . . . . . . . . 20
2.3 Weibull Distribution . . . . . . . . . . . . . . . . . . . . . 21
2.4 Extreme Value Distributions . . . . . . . . . . . . . . . . 23
2.5 Lognormal . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.6 Gamma . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.7 Loglogistic . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.8 Maximum Likelihood Estimation . . . . . . . . . . . . . 30
2.9 Parametric Regression Models

chap 6. Estimation Methods for Shared Frailty Models
6.1 Introction . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.2 Inference for the Shared Frailty Model . . . . . . . . . . 106
6.3 The EM Algorithm . . . . . . . . . . . . . . . . . . . . . . . 108
6.4 The Gamma Frailty Model . . . . . . . . . . . . . . . . . . . 110
6.5 The Positive Stable Frailty Model . . . . . . . . . . . . . . 111
6.6 The Lognormal Frailty Model . . . . . . . . . . . . . . . . . 113
6.6.1 Application to Seizure Data . . . . . . . . . . . . . . . 113
6.7 Modified EM (MEM) Algorithm for Gamma Frailty Models 114
6.8 Application

然后用最基本的package "survival"
并参考你的模型可能用到的一些functions:
survreg(formula, data, weights, subset,na.action, dist="weibull",....)
survreg.distributions include "weibull", "exponential", "gaussian",
"logistic","lognormal" and "loglogistic"
frailty(x, distribution="gamma", ...)
distribution: either the gamma, gaussian or t distribution may be specified.
frailty.gamma(x, sparse = (nclass > 5), theta, df, eps = 1e-05,
method = c("em","aic", "df", "fixed"),...)

Ⅱ 请问如何用R语言做大量次数的几何布朗运动的模拟(参数μ,σ已知)

这上网搜应该搜的到吧,比如这篇文章"
股票价格行为关于几何布朗运动的模拟--基于中国上证综指的实证研究
",照着几何布朗运动的公式直接写代码应该就行了吧,代码逻辑都很清晰。

下面是照着这片文章模拟一次的代码,模拟多次的话,外面再套个循环应该就行了。然后再根据均方误差(一般用这个做准则的多)来挑最好的。
话说你的数据最好别是分钟或者3s切片数据,不然R这速度和内存够呛。
N <- 2000 #模拟的样本数
S0 <- 2000 #初始值
mu <- 0.051686/100
sigma <- 1.2077/100
St <- rep(0,N)
epsion <- rnorm(N,0,1) #正态分布随机数
for(i in 1:N) {
if(i == 1) {
delta_St <- mu * S0 + sigma * S0 * epsion[i]
St[i] <- S0 + delta_St
}else {
delta_St <- mu * St[i-1] + sigma * St[i-1] * epsion[i]
St[i] <- St[i-1] + delta_St
}
}
Final_St <- c(S0,St) #最终结果
plot(Final_St,type = "l")

Ⅲ R语言怎么把股票日收盘价转换成对数收益率

知道一系列收盘价向量X,length=1000,求对数收益率的R语言代码
acf(int[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly

acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly
log return')

Box.test(int[,2], lag = 5, type = "Ljung-Box")
Box.test(int[,2], lag = 10, type = "Ljung-Box")
Box.test(int.l[,2], lag = 5, type = "Ljung-Box")
Box.test(int.l[,2], lag = 10, type = "Ljung-Box")

运行结错误办

> int <- read.table("d-intc7208.txt", head=T)
错误于file(file, "rt") : 打链结
外: 警告信息:
In file(file, "rt") :
打文件'd-intc7208.txt': No such file or directory

+ acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int monthly
错误: 意外符号 in:
"
acf(int.l[,2], lag.max = 15,type = "correlation", plot = TRUE,main='int"
> log return')
错误: 意外符号 in "log return"

Ⅳ 如何用R 语言 建立 股票价格的时间序列

在下想用R语言对股票价格进行时间序列分析
问题出在第一步,如何将股票价格转换为时间序列。
我想用的语句是 pri <- ts (data, start=(), frequency= )
但是我不知道frequency 项该如何填?
因为股票的交易日是一周五天的。 那么这个frequency 该如何设置呢?
我知道通常frequency= 12 为月度数据,frequency= 4 为季度数据,frequency= 1 为年度数据 但日数据怎么写我就不知道了

初学R语言,还望各位大侠多多帮助。

Ⅳ 如何用R语言提取股票行情数据

你好,关于股票价格有关的开盘价格,当日最高价格,当日最低价格,收盘价格,股票交易量;和调整后的价格;

DIA.Open 当日开盘价格

DIA.High 当日最高价格

DIA.Low 当日最低价格

DIA.Close 当日收盘价格

DIA.Volume 当日股票交易量

DIA.Adjusted 当日调整后的价格

Ⅵ 正在学习用R语言编写股票自动交易软件,但是对股票以及R语言都知之甚少。求高手指点。

我和你一样,也在学,大智慧新一代,通达信,和飞狐这几个你任选一个先学,以后慢慢的都会了。飞狐相对要复杂一些,要想编出功能更强大的公式,飞狐里还会用到VBS和JS脚本,还会用到C语言,别的公式不会用到这些。

Ⅶ 求助,如何用R语言实现期权定价二叉树模型

二项期权定价模型假设股价波动只有向上和向下两个方向,且假设在整个考察期内,股价每次向上(或向下)波动的概率和幅度不变。模型将考察的存续期分为若干阶段,根据股价的历史波动率模拟出正股在整个存续期内所有可能的发展路径

Ⅷ 如何在r语言中抓取股票数据并分析论文

用quantomd包
然后getsymbols函数

分析论文 要看你研究方向
如果是看影响因素 一般回归就行
如果看股票波动和预测 可能需要时间序列