Skip to content

Boottest looking for the data in the wrong place when running inside a function #155

@Yuval-OS

Description

@Yuval-OS

See this reproducible code:
It works without a function, but when used inside a function it says it cannot find data_obj.
When I define data_obj in the global directory, it works fine.

requireNamespace("fwildclusterboot")
data(voters)

feols_fit <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = voters)
boot1 <- boottest(feols_fit, B = 9999, param = "treatment", clustid = "group_id1")
summary(boot1)

boot_func <- function(data_obj) {
feols_fit1 <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = data_obj)
boot1 <- boottest(feols_fit1,
B = 9999,
param = "treatment",
clustid = "group_id1")
return(summary(boot1))
}

boot_func(voters)
data_obj <- voters
boot_func(voters)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions