有人可以解释如何在函数中计算R包中的Cover列吗?xgboostxgb.model.dt.tree
在文档中,它说Cover "是衡量受分割影响的观察数量的指标".
当您运行xgboost此函数的文档中给出的以下代码时,Cover树0的节点0为1628.2500.
data(agaricus.train, package='xgboost')
#Both dataset are list with two items, a sparse matrix and labels
#(labels = outcome column which will be learned).
#Each column of the sparse Matrix is a feature in one hot encoding format.
train <- agaricus.train
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
#agaricus.test$data@Dimnames[[2]] represents the column names of …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用来自Franzese&Hays(2007)的横截面时间序列数据的空间计量经济模型论文中的数据来估计R中的一些空间模型.我将重点放在表4中给出的结果(见下文).使用lm我能够复制他们的OLS,S-OLS和S-2SLS模型的结果.然而,在试图估计S-ML(空间最大似然)模型时,我遇到了麻烦.

如果我使用GLM模型,某些解释变量存在一些微小的差异,但是对于空间滞后的估计系数(下面显示的输出)有相当大的余量.我不完全确定为什么GLM在这种情况下不是正确的估算方法.使用GLS我得到类似于GLM的结果(可能相关).
require(MASS)
m4<-glm(lnlmtue~lnlmtue_1+SpatLag+DENSITY+DEIND+lngdp_pc+UR+TRADE+FDI+LLVOTE+LEFTC+TCDEMC+GOVCON+OLDAGE+factor(cc)+factor(year),family=gaussian,data=fh)
summary(m4)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.199091355 3.924227850 1.835 0.068684 .
lnlmtue_1 0.435487985 0.080844033 5.387 0.000000293 ***
SpatLag -0.437680018 0.101078950 -4.330 0.000028105 ***
DENSITY 0.007633016 0.010268468 0.743 0.458510
DEIND 0.040270153 0.032304496 1.247 0.214618
Run Code Online (Sandbox Code Playgroud)
我尝试使用该splm软件包,但这会导致更大的一致性(输出如下所示).而且,我无法在模型中包含固定效果.
require(splm)
m4a<-spml(lnlmtue~lnlmtue_1+DENSITY+DEIND+lngdp_pc+UR+TRADE+FDI+LLVOTE+LEFTC+ TCDEMC+GOVCON+OLDAGE,data=fh,index=c("cc","year"),listw=mat2listw(wmat),
model="pooling",spatial.error="none",lag=T)
summary(m4a)
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
(Intercept) 1.79439070 0.78042284 2.2993 0.02149 *
lnlmtue_1 0.75795987 0.04828145 15.6988 < 2e-16 ***
DENSITY -0.00026038 0.00203002 -0.1283 0.89794
DEIND -0.00489516 …Run Code Online (Sandbox Code Playgroud) 我想在逻辑回归中得到ROC的最佳截止点作为数字而不是两条交叉曲线.使用下面的代码,我可以得到将显示最佳点的图,但在某些情况下,我只需要将该点作为可用于其他计算的数字.以下是代码行:
library(Epi)
ROC( form = IsVIP ~ var1+var2+var3+var4+var5, plot="sp", data=vip_data )
Run Code Online (Sandbox Code Playgroud)
谢谢
我有Pandas一系列10000行,其中填充了单个字母,从A到Z.但是,我想使用Pandas为A,B和C创建虚拟数据帧get_dummies.我该怎么做呢?
我不想为列中的所有行值获取假人,然后选择特定列,因为该列包含其他冗余数据,最终导致内存错误.
在回归中,我试图对单位特定的时间趋势进行建模,但我一直遇到困难。在R当我估计用单位和年份固定效应模型就像lm(y~x+factor(unit)+factor(time))我得到完全正常的结果。但是,当我尝试这样做时,lm(y~x+factor(unit)*factor(year))我遇到了NA's所产生的麻烦。
使用一些模拟数据来说明:
# Unit of analysis are countries
country<-c(rep("Isthmus",10),rep("Nambutu",10),rep("San Monique",10))
ccode<-c(rep(1,10),rep(2,10),rep(3,10))
year <- c(rep(2000:2009,3)) # Time
x1<-rnorm(30)*ccode
x2<-runif(30)
y<-0.5*x1-0.3*x2+rnorm(30) # Outcome variable
df=data.frame(country,ccode,year,y,x1,x2)
Run Code Online (Sandbox Code Playgroud)
分别使用单位和时间、国家和年份的固定效应来估计模型:
m0<-lm(y~x1+x2+factor(ccode)+factor(year),df);summary(m0)
# Part of the regression output:
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.92780 0.68231 -1.360 0.1928
x1 0.59290 0.10058 5.895 0.0000226 ***
x2 -0.36457 0.96036 -0.380 0.7092
factor(ccode)2 0.95383 0.48675 1.960 0.0677 .
factor(ccode)3 0.46050 0.46475 0.991 0.3365
factor(year)2001 0.15222 0.87295 0.174 0.8638
Run Code Online (Sandbox Code Playgroud)
这里没有问题。现在我使用特定于单位的时间趋势来估计模型:
m1<-lm(y~x1+x2+factor(year)*factor(ccode),df);summary(m1) …Run Code Online (Sandbox Code Playgroud) 我有两个形状文件;一个是点文件(世界的一些信息),另一个是 21 个国家/地区的形状文件。
我需要提取属于一个国家的点。我必须在 QGIS 或 ArcGIS 中重复此步骤 21 次。
有没有什么方法可以在 R 中做到这一点,如果是在批处理中,那就太好了,因为我也必须对其他 4 个数据集重复此操作。提前致谢