0

I'm really puzzled by the weighting argument in glm. I realise that this question has been asked before but Im still confused about what the weights argument does or how it works. For example, in the code below my dependant variable PCL_Sum2 is binary and highly imbalanced. I would like both levels to be equally weighted. How would I accomplish this?

Final_Frame.df <- read.csv("no_subset.csv")

Omitted_Nas.df<-na.omit(Final_Frame.df)

This yields 278 remaining observations. Then when I go ahead and perform the regression:

prelim_model<-glm(PCL_Sum2~Mean_social_combined +
  Mean_traditional_time+
  Mean_Passive_Use_Updated+
  factor(Gender)+
  factor(Ethnicity)+
  factor(Age)+
  factor(Location)+
  factor(Income)+
  factor(Education)+
  factor(Working_Home)+
  Perceived_Fin_Risk+
  Anxiety_diagnosed+
  Depression_diagnosed+
  Lived_alone+
  Mean_Active_Use_Updated, data=Omitted_Nas.df<-na.omit(Final_Frame.df), weights=??? family = binomial())

summary(prelim_model)

I've tried setting weights = 0.5, 0.5 but I always get the following error:

Error in model.frame.default(formula = PCL_Sum2 ~ Mean_social_combined + : variable lengths differ (found for '(weights)')

Any help would be greatly appreciated!

Socsi2
  • 33
  • 3
  • What you are asking for doesn't make sense. You want to pretend to have 50% of each level of `PCL_Sum2`, when in your data you don't. – user2554330 Apr 07 '21 at 21:43
  • I have substantially more observations=0 than are equal to 1, which is why I would like to re-weight the variable so both classes are equal. – Socsi2 Apr 07 '21 at 21:54
  • There is no need to use weighting to deal with what I would call a small relative imbalance of outcomes. The Intercept should be the only feature of the output that will be affected. – IRTFM Apr 07 '21 at 22:44

0 Answers0