在logistf R函数中将权重显示为未使用的参数
我一直遇到以下代码的问题;“weights=weight”显示为未使用的参数。我该如何解决这个问题在logistf R函数中将权重显示为未使用的参数,r,statistics,linear-regression,weighting,logistf,R,Statistics,Linear Regression,Weighting,Logistf,我一直遇到以下代码的问题;“weights=weight”显示为未使用的参数。我该如何解决这个问题 x_0 <- rbinom(1,100, 0.01) x_1 <- rbinom(1,100, 0.1) x <- c(0,0,1,1) y <- c(0,1,0,1) weight <- c(100-x_0, x_0, 100-x_1, x_1) result <- logistf(y ~ x, weights=weight)$coef[2] x
x_0 <- rbinom(1,100, 0.01)
x_1 <- rbinom(1,100, 0.1)
x <- c(0,0,1,1)
y <- c(0,1,0,1)
weight <- c(100-x_0, x_0, 100-x_1, x_1)
result <- logistf(y ~ x, weights=weight)$coef[2]
x_0我成功地运行了以下代码,没有出现任何问题(R v 3.0.0 logistf v 1.10):
arr我的工作区中没有一个logistf
,但它使用glm(…,family=“binomial”)
rtest我的R版本是2.9.2;我想我应该重新安装它。谢谢。如果我想在代码中添加另一个logistf模型以进行比较,我应该怎么做?(然后在list函数中有两个不同的“res”参数。)您可以在列表中添加任意数量的参数:list(count=I,x_0=x_0,x_1=x_1,res=logistf(y~x,weights=weight)$coef[2],res_2=logistf(y~x,weights=weight)$coef[2],res_3=logistf(y~x,weights=weights)$coef[2])
每一个都将对应于结果数组中的一列。再次感谢。我认为每一个加上“res”都与“res”有关
arr <- t(sapply(1:30, function(i){
x_0 <- rbinom(1,100, 0.01)
x_1 <- rbinom(1,100, 0.1)
x <- c(0,0,1,1)
y <- c(0,1,0,1)
weight <- c(100-x_0, x_0, 100-x_1, x_1)
list(count=i,x_0=x_0,x_1=x_1, res= logistf(y ~ x, weights=weight)$coef[2])
}))
rtest <- replicate(10,
{x_0 <- rbinom(1,100, 0.01)
x_1 <- rbinom(1,100, 0.1)
x <- c(0,0,1,1)
y <- c(0,1,0,1)
weight <- c(100-x_0, x_0, 100-x_1, x_1)
result <- glm(y ~ x, weights=weight, family="binomial")$coef[2]} )
rtest
#------------
x x x x x x x x
1.694596 2.281485 1.843585 18.220418 18.410200 18.113934 18.724469 1.162464
x x
1.650681 2.504379