Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Specifying number of trials, bootstrap

$
0
0

For an assignment, I am applying mixture modeling with the mixtools package on R. When I try to figure out the optimal amount of components with bootstrap. I get the following error

Error in boot.comp(y, x, N = NULL, max.comp = 2, B = 5, sig = 0.05, arbmean = TRUE,  : 
Number of trials must be specified!

I found out that I have to fill an N: An n-vector of number of trials for the logistic regression type logisregmix. If NULL, then N is an n-vector of 1s for binary logistic regression.

But, I don't know how to find out what the N is in fact to make my bootstrap working.

Link to my codes: https://www.kaggle.com/blastchar/telco-customer-churn

My codes:

data <- read.csv("Desktop/WA_Fn-UseC_-Telco-Customer-Churn.csv", stringsAsFactors = FALSE,
             na.strings = c("NA", "N/A", "Unknown*", "NULL", ".P"))
data <- droplevels(na.omit(data))
data <- data[c(1:5032),]
testdf <- data[c(5033:7032),]
data <- subset(data, select = -customerID)
set.seed(100)
library(plyr)
library(mixtools)
data$Churn <- revalue(data$Churn, c("Yes"=1, "No"=0))
y <- as.numeric(data$Churn)
x <- model.matrix(Churn ~ . , data = data)
x <- x[, -1] #remove intercept
x <-x[,-c(7, 11, 13, 15, 17, 19, 21)] #multicollinearity


a <- boot.comp(y, x, N = NULL, max.comp = 2, B = 100,
           sig = 0.05, arbmean = TRUE, arbvar = TRUE,
           mix.type = "logisregmix", hist = TRUE)

Below there is more information about my predictors:

dput(x[1:4,]) structure(c(0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 34, 2, 45, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 29.85, 56.95, 53.85, 42.3, 29.85, 1889.5, 108.15, 1840.75), .Dim = c(4L, 23L), .Dimnames = list(c("1", "2", "3", "4"), c("genderMale", "SeniorCitizen", "PartnerYes", "DependentsYes", "tenure", "PhoneServiceYes", "MultipleLinesYes", "InternetServiceFiber optic", "InternetServiceNo", "OnlineSecurityYes", "OnlineBackupYes", "DeviceProtectionYes", "TechSupportYes", "StreamingTVYes", "StreamingMoviesYes", "ContractOne year", "ContractTwo year", "PaperlessBillingYes", "PaymentMethodCredit card (automatic)", "PaymentMethodElectronic check", "PaymentMethodMailed check", "MonthlyCharges", "TotalCharges" )))

My response variable is binary

I hope you guys can help me out!


Viewing all articles
Browse latest Browse all 201839

Trending Articles