Thanks for the question and response.
I have the exact same issue, just that instead of 4 variables i have 8 variables as below:
N_for_KPI <- c(683,538,2225,1458,294,307,922,781)
N <- c(1951,1564,5683,4507,819,862,2479,2511)
Wave <- factor(c("A","A","B","B","C","C"))
Brand <- factor(c(0,1,0,1,0,1))
data = data.frame(N_for_KPI,N)
Proportion <-N_for_KPI / N
Proportion
fit <- glm(Proportion~Wave*Brand, family=binomial, weights=N)
summary(fit)
Although i got the significance results, i got an error:
> N_for_KPI <- c(683,538,2225,1458,294,307,922,781)
> N <- c(1951,1564,5683,4507,819,862,2479,2511)
> Wave <- factor(c("A","A","B","B","C","C"))
> Brand <- factor(c(0,1,0,1,0,1))
> Proportion <-N_for_KPI / N
> Proportion
[1] 0.3500769 0.3439898 0.3915186 0.3234968 0.3589744 0.3561485
0.3719242 0.3110315
> fit <- glm(Proportion~Wave*Brand, family=binomial, weights=N)
Error in model.frame.default(formula = Proportion ~ Wave * Brand,
weights = N, :
variable lengths differ (found for 'Wave')
> summary(fit)
Call:
glm(formula = Proportion ~ Wave * Brand, family = binomial, weights
= N)
Deviance Residuals:
[1] 0 0 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.9422 0.1047 -28.096 <2e-16 ***
WaveB 0.0394 0.1203 0.328 0.743
Brand1 -0.1574 0.1507 -1.045 0.296
WaveB:Brand1 -0.4487 0.1786 -2.512 0.012 *
Signif. codes: 0 ‘*’ 0.001 ‘’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 4.5383e+01 on 3 degrees of freedom
Residual deviance: -4.9938e-13 on 0 degrees of freedom
AIC: 35.137
Number of Fisher Scoring iterations: 3
In addition to the error, when I changed to a new sample sizes for N_for_KPI and N, the significant result didn't change
Can you please help to advise how to fit 8 variables in this model?
Thank you so much in advance!!