Skip to content

autoReg.glm not working when sample weights incorporated #3

@stanleyrazor

Description

@stanleyrazor

Hi,
the autoReg function throws an error when the model is of the form:
glm(y ~ x1 + x2, weights = w, data=data, family='binomial')

The error being:

Error in map():
ℹ In index: 1.
Caused by error in model.frame.default():
! 'data' must be a data.frame, environment, or list
Run rlang::last_trace() to see where the error occurred.

  1. After digging deeper, the issue seems to stem from the function: fit2model, about line 77
    dataname = as.character(fit$call)[length(as.character(fit$call))]
    What happens is that, if you incorporate sample weights into the model, it appears as the last object in fit$call, and therefore dataname gets a vector of weights instead of the dataset used in fitting the model.

  2. Another the issue seems to be coming from fit2list, as it fits a lm/glm model in about line 18, 21-22, with only, formula, data and family being parameters, there should probably be a ... so that extra parameters e.g weights are incorporated.

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