當前位置:首頁 » 股市行情 » r語言模擬股票價格
擴展閱讀
睡眠面膜可以天天做嗎 2025-06-27 11:35:51
股票代碼1314 2025-06-27 11:33:24
北京賓士官網 2025-06-27 11:06:43

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函數

分析論文 要看你研究方向
如果是看影響因素 一般回歸就行
如果看股票波動和預測 可能需要時間序列