Open Jigarci3 opened 4 years ago
Look at the dimensions of Data2, before you do you calculate the predicted value. Then look at the results of the predict function. It looks like the data frame and the predict function have different dimensions.
If you are having a hard time with the with() and predict() functions you can also calculate the predicted probabilities using the logit formula.
I find it a little more intuitive because you can see the steps:
m.logit <- glm( Admission ~ LSAT + Essay + GPA, data = df, family = "binomial")
coefficients <- coefficients( m.logit )
covariates <- c( 1, mean(df$LSAT ), mean(df$Essay), mean(df$GPA) )
B <- sum( coefficients * covariates )
p <- 1 / ( 1 + exp( -B ) )
p
Hello, I am getting an error when I try to run the predict function to find the probability change for an average state- has anyone else been able to run it?
Here is my code:
The error i receive is: Error in
$<-.data.frame
(*tmp*
, Adoption_Prop, value = c(1
= 0.35531731324293, : replacement has 49 rows, data has 1Thanks!