機器學習 -- 使用 R 軟體

統計軟體 R

簡介

安裝

操作方式

變數與運算

有序數列

向量

矩陣

多維陣列

複數

因子

串列

資料框

時間數列

流程控制

輸出入

呼叫

函數

2D 繪圖

3D 繪圖

互動介面

套件列表

其他語言呼叫

R 的應用

集合

邏輯推論

模糊邏輯

機率邏輯

檢定

搜尋

優化算法

線性代數

決策樹

人工智慧

分群分類

SVM 向量機

神經網路

遺傳演算法

資料採礦

訊號處理

影像處理

語音處理

自然語言

機器學習

機器人

生物統計

數位訊號處理

方程式求解

數值分析

微積分

微分方程

線性規劃

圖形理論

統計推論

字串處理

正規表示式

視窗程式

網頁程式

文件格式

貝氏網路

訊息

機率統計書

相關網站

參考文獻

最新修改

簡體版

English

Q learning

set.seed(100)
# Simple Simulation on 1000 subjects
sim<-matrix(0,nrow=1000,ncol=7)
colnames(sim)<-c("H1","A1","Y1","H2","A2","Y2","IS2")
sim<-as.data.frame(sim)
# Randomly generate stage 1 covariates and stage 1 and 2 treatments
sim[,c("H1","A1","A2")]<-2*rbinom(1000*3,1,0.5)-1
# Generate stage 2 covariates based on H1 and T1
expit<-exp(0.5*sim$H1+0.5*sim$A1)/(1+exp(0.5*sim$H1+0.5*sim$A1))
sim$H2<-2*rbinom(1000,1,expit)-1
# Assume stage 1 outcome Y1 is 0
# Generate stage 2 outcome Y2
sim$Y2<-0.5*sim$A2+0.5*sim$A2*sim$A1-0.5*sim$A1+rnorm(1000)
# Randomly assign 500 subjects to S2
sim[sample(1000,500),"IS2"]<-1
sim[sim$IS2==0,c("A2","Y2")]<-NA
# Define models for both stages
s2Formula<-Y2~H1*A1+A1*A2+A2:H2
s1Formula<-Y1~H1*A1
## Fixed Xi as 0.05
qLearn(s2Formula,s1Formula,sim,s2Treat="A2",interact=c("A1","H2"), 
s2Indicator="IS2",s1Method="Fixed Xi",fixedXi=0.05,bootNum=100)

參考文獻

  1. CRAN Task View: Machine Learning & Statistical Learning
  2. mlr - Machine Learning in R

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License