Search code examples
rstatisticslinear-regressionweightinglogistf

Having weights shown as an unused argument in logistf R function


I kept getting a problem for the following code; "weights=weight" was shown as an unused argument. How should I solve the problem?

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]

Also, is there a way to perform the whole process shown above 30, 60, or 100 times and generate time (or count), x_0, x_1, and result for each time? Any suggestion would be great. Thanks.


Solution

  • I managed to run the following code without problems (R v 3.0.0 logistf v 1.10):

    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])
    }))