根据其余变量对每个变量V1 ... V40进行建模,例如V1 = f(V2 ... V40)

时间:2018-07-20 12:26:40

标签: r dataframe r-caret

我有一个数据框,它是按如下方式创建的。

library("MASS")
mu <- rep(0,40)
Sigma <- matrix(.7, nrow=40, ncol=40) + diag(40)*.3
rawvars <- mvrnorm(n=10000, mu=mu, Sigma=Sigma)
cov(rawvars); cor(rawvars)
pvars <- pnorm(rawvars)
colnames(pvars)<-c("v1","v2","v3","v4","v5","v6","v7","v8","v9","v10","v11","v12","v13","v14","v15","v16","v17","v18","v19","v20","v21","v22","v23","v24","v25","v26","v27","v28","v29","v30","v31","v32","v33","v34","v35","v36","v37","v38","v39","v40")



df <- data.frame(timestamp = seq(as.POSIXct('2013-08-02 12:00'),
                                 as.POSIXct('2018-07-19 05:00'), len = 10000))
dataset <- data.frame(df,pvars)
rm("pvars","df","rawvars", "Sigma", "mu")

看起来像这样。 Sample Image

如何将每个变量V1 ... V40建模为其余变量的函数,例如R中的非线性回归模型(例如随机森林)的V1 = f(V2 ... V40),并为每个模型确定最重要的变量。

我可以使用插入符号。但我正在寻找for循环。

0 个答案:

没有答案