caimiao0714
好的!我做了一下simulation,从结果上来看似乎非整数的weight同样能够运行,至于比例也主要是通过影响标准误进而影响p-value,不过从这里也可以看出如果weight直接按照归一化的方式取得很小的话,那么可能β会很不显著...
n=500
#weight1=c(1,1,...)
weight1<-rep(1,n)
#weight2=c(100,100,...)
weight2<-weight1*100
#weight3=c(0.99,2.31,0.03,...)
weight3<-abs(round(rnorm(n),2))
#weight4=c(99,231,3,...)
weight4<-weight3*100
x<-rnorm(n=n,sd=1)
y<-10*x+5+rnorm(n,sd=10)
y0<-1/(1+exp(-y))
y<-round(y0)
data<-data.frame(x,y,y0)
fit0<-glm(data = data,y~x,family = binomial(link = "logit"))
coef(fit0)
#(Intercept) x
#0.7941683 1.6303079
confint(fit0)
#Waiting for profiling to be done...
# 2.5 % 97.5 %
#(Intercept) 0.5662565 1.032330
#x 1.3327177 1.956054
fit1<-glm(data = data,y~x,weights = weight1,family = binomial(link = "logit"))
coef(fit1)
#(Intercept) x
#0.7941683 1.6303079
confint(fit1)
#Waiting for profiling to be done...
# 2.5 % 97.5 %
#(Intercept) 0.5662565 1.032330
#x 1.3327177 1.956054
fit2<-glm(data = data,y~x,weights = weight2,family = binomial(link = "logit"))
coef(fit2)
#(Intercept) x
#0.7941683 1.6303079
confint(fit2)
#Waiting for profiling to be done...
# 2.5 % 97.5 %
#(Intercept) 0.7709583 0.8174808
#x 1.5993421 1.6615557
fit3<-glm(data = data,y~x,weights = weight3,family = binomial(link = "logit"))
coef(fit3)
#(Intercept) x
#0.8426232 1.7929444
confint(fit3)
#Waiting for profiling to be done...
# 2.5 % 97.5 %
#(Intercept) 0.5751225 1.125583
#x 1.4425999 2.183978
#There were 22 warnings (use warnings() to see them)
fit4<-glm(data = data,y~x,weights = weight4,family = binomial(link = "logit"))
coef(fit4)
#(Intercept) x
#0.8426232 1.7929444
confint(fit4)
#Waiting for profiling to be done...
# 2.5 % 97.5 %
#(Intercept) 0.8152457 0.8701551
#x 1.7561727 1.8301234