Weekly assignments submitted via Canvas
treat
coefficient is capturing the differences between treated and control states before the policy was set in place. The interpretation of the coefficient would be as follows: “On average, NY and CA had an average subscription rate that was 5.4 percentage points higher than other states prior to the implementation of the policy / in April 2022.” Or, you could also say: “On average, a person in NY and CA has a probability of subscription that is 5.4 percentage points higher than a person in another state, before the implementation of the policy / in April 2022”set.seed(100)
ct = train(factor(unsubscribe) ~ . - id, data = train.data,
method = "rpart",
tuneGrid = expand.grid(cp = seq(0,0.015, length = 50)),
trControl = trainControl(method = "cv", number = 10))
ct$bestTune
pred.values = ct %>% predict(test.data)
mean(pred.values == test.data$unsubscribe)
ct
= 0.007 and accuracy is 63.9%
Change tuneGrid
according to specifications:
tuneGrid = expand.grid(
mtry = 3:11,
splitrule = "variance",
min.node.size = 1
)
Run RF:
rfcv = train(Sales ~ ., data = carseats.train,
method = "ranger",
trControl = trainControl("cv", number = 10),
importance = "permutation",
tuneGrid = tuneGrid)
Get best tuning parameter (10 in Windows):
rfcv$bestTune
Get appropriate measure of performance (RMSE = 1.48):
rmse(rfcv, carseats.test)