导航:首页 > 数据行情 > r语言对股票数据判别分析

r语言对股票数据判别分析

发布时间:2022-11-16 13:27:43

‘壹’ 如何用R语言提取股票行情数据

最上边一行菜单栏倒数第二个“高级”-“关联任务定义”-选取最右边从上到下第二个按钮,找到2009年决算任务安装路径-确定。 然后 最上边一行菜单栏正数第二个“录入”-“上年数据提取”即可 提取完了,注意修改与去年不同的科目代码!

‘贰’ R语言quantmod包下载的股票数据中如何确定某一数据的日期

筛选到这个行,然后输出

‘叁’ 如何用R语言的quantmod包获取一系列股票的历史日线数据

我举个例子供你参考:
> install.packages('quantmod') # 安装安装quantmod包
> require(quantmod)#引用quantmod包
> getSymbols("GOOG",src="yahoo",from="2013-01-01", to='2013-04-24') #从雅虎财经获取google的股票数据
> chartSeries(GOOG,up.col='red',dn.col='green') #显示K线图

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

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

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

‘伍’ 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,相关系数R绝对值越大,颜色越深(红正,蓝负)。统计学中,P值越小相关性越显着,一般来说 一个*代表显着相关(P值为0.01,选取不同参数可能不一样)、两个**代表极显着相关(P值为0.001)、三个***代表极极显着相关(P值为0.0001). 图中还可以看出,相关系数R的绝对值0.67(变量P50与T之间)以上的都显着相关,至少一个*。符合一般关于相关系数R值的显着性统计。

‘柒’ 如何用R语言提取股票行情数据

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

DIA.Open 当日开盘价格

DIA.High 当日最高价格

DIA.Low 当日最低价格

DIA.Close 当日收盘价格

DIA.Volume 当日股票交易量

DIA.Adjusted 当日调整后的价格

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

用quantomd包
然后getsymbols函数

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

‘玖’ R语言基本数据分析

R语言基本数据分析
本文基于R语言进行基本数据统计分析,包括基本作图,线性拟合,逻辑回归,bootstrap采样和Anova方差分析的实现及应用。
不多说,直接上代码,代码中有注释。
1. 基本作图(盒图,qq图)
#basic plot
boxplot(x)
qqplot(x,y)
2. 线性拟合
#linear regression
n = 10
x1 = rnorm(n)#variable 1
x2 = rnorm(n)#variable 2
y = rnorm(n)*3
mod = lm(y~x1+x2)
model.matrix(mod) #erect the matrix of mod
plot(mod) #plot resial and fitted of the solution, Q-Q plot and cook distance
summary(mod) #get the statistic information of the model
hatvalues(mod) #very important, for abnormal sample detection
3. 逻辑回归

#logistic regression
x <- c(0, 1, 2, 3, 4, 5)
y <- c(0, 9, 21, 47, 60, 63) # the number of successes
n <- 70 #the number of trails
z <- n - y #the number of failures
b <- cbind(y, z) # column bind
fitx <- glm(b~x,family = binomial) # a particular type of generalized linear model
print(fitx)

plot(x,y,xlim=c(0,5),ylim=c(0,65)) #plot the points (x,y)

beta0 <- fitx$coef[1]
beta1 <- fitx$coef[2]
fn <- function(x) n*exp(beta0+beta1*x)/(1+exp(beta0+beta1*x))
par(new=T)
curve(fn,0,5,ylim=c(0,60)) # plot the logistic regression curve
3. Bootstrap采样

# bootstrap
# Application: 随机采样,获取最大eigenvalue占所有eigenvalue和之比,并画图显示distribution
dat = matrix(rnorm(100*5),100,5)
no.samples = 200 #sample 200 times
# theta = matrix(rep(0,no.samples*5),no.samples,5)
theta =rep(0,no.samples*5);
for (i in 1:no.samples)
{
j = sample(1:100,100,replace = TRUE)#get 100 samples each time
datrnd = dat[j,]; #select one row each time
lambda = princomp(datrnd)$sdev^2; #get eigenvalues
# theta[i,] = lambda;
theta[i] = lambda[1]/sum(lambda); #plot the ratio of the biggest eigenvalue
}

# hist(theta[1,]) #plot the histogram of the first(biggest) eigenvalue
hist(theta); #plot the percentage distribution of the biggest eigenvalue
sd(theta)#standard deviation of theta

#上面注释掉的语句,可以全部去掉注释并将其下一条语句注释掉,完成画最大eigenvalue分布的功能
4. ANOVA方差分析

#Application:判断一个自变量是否有影响 (假设我们喂3种维他命给3头猪,想看喂维他命有没有用)
#
y = rnorm(9); #weight gain by pig(Yij, i is the treatment, j is the pig_id), 一般由用户自行输入
#y = matrix(c(1,10,1,2,10,2,1,9,1),9,1)
Treatment <- factor(c(1,2,3,1,2,3,1,2,3)) #each {1,2,3} is a group
mod = lm(y~Treatment) #linear regression
print(anova(mod))
#解释:Df(degree of freedom)
#Sum Sq: deviance (within groups, and resials) 总偏差和
# Mean Sq: variance (within groups, and resials) 平均方差和
# compare the contribution given by Treatment and Resial
#F value: Mean Sq(Treatment)/Mean Sq(Resials)
#Pr(>F): p-value. 根据p-value决定是否接受Hypothesis H0:多个样本总体均数相等(检验水准为0.05)
qqnorm(mod$resial) #plot the resial approximated by mod
#如果qqnorm of resial像一条直线,说明resial符合正态分布,也就是说Treatment带来的contribution很小,也就是说Treatment无法带来收益(多喂维他命少喂维他命没区别)
如下面两图分别是
(左)用 y = matrix(c(1,10,1,2,10,2,1,9,1),9,1)和
(右)y = rnorm(9);
的结果。可见如果给定猪吃维他命2后体重特别突出的数据结果后,qq图种resial不在是一条直线,换句话说resial不再符合正态分布,i.e., 维他命对猪的体重有影响。

‘拾’ 用r语言做数据分析好学吗

非常好学。输入几行代码,即可得到结果。
R不但数据分析好用,而且作图能力极好,推荐你用。

下面是R数据分析的一些代码,包括数据导入、方差分析、卡方测验、线性模型及其误差分析。希望可以帮到你:
1.1导入数据
install.packages('xslx')
library(xlsx)
Sys.setlocale("LC_ALL", "zh_cn.utf-8")
a=read.xlsx2('d:/1.xlsx',1,header=F)
head(a)显示前六行
class(a$y)/str(a)查看列/全集数据类型
a$y=as.numeric(a$y)转换数据类型
1.2方差分析(F test)
with(a,tapply(liqi,tan,shapiro.test))正态性检验
library(car)leveneTest(liqi~tan,a)方差齐性检验
q=aov(liqi~tan*chong,a)方差分析(正态型)
summary(q)
TukeyHSD(q)多重比较
1.3卡方测验(Pearson Chisq)
a1=summarySE(a,measurevar='y', groupvars=c('x1','x2'))卡方检验(逻辑型/计数型)
aa=a1$y
aaa=matrix(a2,ncol=2)
aaa= as.table(rbind(c(56,44), c(36,64), c(48,52),c(58,42)))
dimnames(aaa)= list(group=c("不添加抗性","不添加敏感","添加抗性","添加敏感"),effect=c("存活","死亡"))
aaa=xtabs(data=a,~x+y)
chisq.test(a)误差分析(卡方测验,Pearson法)
install.packages("rcompanion")
library(rcompanion)
pairwiseNominalIndependence(a)多重比较
1.4线性模型及其误差分析(Wald Chisq)
q=lm(data=a,y~x1*x2)一般线性模型(正态性)
summary(q)
q=glm(data=a,y~x1*x2,family = gaussian(link='identity'))广义线性模型(正态性)
summary(q)
q=glm(data=a,y~x1*x2,family = binomial(link='logit'))广义线性模型(逻辑型,二项分布)
summary(q)
q=glm(data=a,y~x1*x2,family = poisson(link='log'))广义线性模型(计数型,泊松分布)
summary(q)
install.packages('lmerTest')一般线性混合效应模型(正态性)
library(lmerTest)
install packages(‘lme4’)
library(lme4)
q=lmer(data=a,y~x1*(1|x2))
q=lmer(data=a,y~x1*(1|x2),family = gaussian(link='identity'))广义线性混合效应模型(正态性)
q=glmer(data=a,y~x1*(1|x2),family = binomial(link='logit'))广义线性混合效应模型(逻辑型,二项分布)
q=glmer(data=a,y~x1*(1|x2),family = poisson(link='log'))广义线性混合效应模型(计数型,泊松分布)
summary(q)
install.packages('car')
install.packages('openxlsx')
library(car)
install.packages('nlme')
library(nlme)
Anova(q,test='Chisq')线性模型的误差分析(似然比卡方测验,Wald法)
lsmeans(q,pairwise~chuli,adjust = "tukey")线性模型的多重比较(tukey法)

阅读全文

与r语言对股票数据判别分析相关的资料

热点内容
股票风险警示多久退市 浏览:963
万安科技股票明日走势 浏览:887
连续跌停板后又连续超涨停板的股票 浏览:250
短线长期持有的股票推荐 浏览:22
股票涨停停牌是什么预兆 浏览:9
如何从白马股中选出价值投资股票 浏览:893
新股票账户能买中小板的股票吗 浏览:114
世界股票投资书籍推荐 浏览:829
亏损股票为什么不退市 浏览:919
资产重组成功股票还跌是为什么 浏览:655
苹果股票软件怎么玩 浏览:726
为什么股票软件不能上网 浏览:594
股票涨停开板又涨停的k线颜色 浏览:968
浮游憾树股票走势 浏览:445
有一只股票一元钱的吗 浏览:278
宁德时代股票历史资金流向 浏览:354
万东医疗股票上市发行价 浏览:576
如何查询股票买入时间点 浏览:746
南国置业股票重组多少个亿 浏览:79
今日银行股票 浏览:662