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!