0
は想定内の列の上にループ機能(元のテーブルには、はるかに多くの列があります):http://pastebin.com/igeMTaSBR:私たちは、変数の各2ペアがお互いにテストする必要があり、我々はテーブルを以下しているRスクリプト
どのように私ができますRのループを作成して、スクリプトの1行または2行ごとに関数を適用します。
例コード:つの可変ケースについて
library(urca)
library(lmtest)
# Load data (See link)
table = read.csv("test.csv", header = TRUE, sep=",")
table = data.frame(table)
table
# For each column in the table (a1-d2), do
VARselect(table$column,lag.max = 10,type="both")
# For each two sequent pairs in the table (a1+a2, b1+b2,c1+c2,d1+d2), do
grangertest(table$a1, table$a2, order = 1, na.action = na.omit)
1つの変数の場合は、 'sapply'または' lapply'を使用してください: 'lapply(table、function(i)VARselect(i、lag.max = 10、type =" both "))'。 – lmo