Re: [R] test logistic regression model

2022-11-20 Thread Mitchell Maltenfort
, or present both and highlight the difference in outcome. A > third option is to gather more data. > > Tim > > -Original Message- > From: R-help On Behalf Of Bert Gunter > Sent: Sunday, November 20, 2022 1:06 PM > To: Mitchell Maltenfort > Cc: R-help > Subject: R

Re: [R] test logistic regression model

2022-11-20 Thread Ebert,Timothy Aaron
- From: R-help On Behalf Of Bert Gunter Sent: Sunday, November 20, 2022 1:06 PM To: Mitchell Maltenfort Cc: R-help Subject: Re: [R] test logistic regression model [External Email] I think (2) might be a bad idea if one of the "sparse"categories has high predictive power. You'll l

Re: [R] test logistic regression model

2022-11-20 Thread Bert Gunter
I think (2) might be a bad idea if one of the "sparse"categories has high predictive power. You'll lose it when you pool, will you not? Also, there is the problem of subjectively defining "sparse." However, 1) seems quite sensible to me. But IANAE. -- Bert On Sun, Nov 20, 2022 at 9:49 AM Mitchel

Re: [R] test logistic regression model

2022-11-20 Thread Mitchell Maltenfort
Two possible fixes occur to me 1) Redo the test/training split but within levels of factor - so you have the same split within each level and each level accounted for in training and testing 2) if you have a lot of levels, and perhaps sparse representation in a few, consider recoding levels to po

Re: [R] test logistic regression model

2022-11-20 Thread Bert Gunter
small reprex: set.seed(5) dat <- data.frame(f = rep(c('r','g'),4), y = runif(8)) newdat <- data.frame(f =rep(c('r','g','b'),2)) ## convert values in newdat not seen in dat to NA is.na(newdat$f) <-!( newdat$f %in% dat$f) lmfit <- lm(y~f, data = dat) ##Result: > predict(lmfit,newdat) 1

Re: [R] test logistic regression model

2022-11-20 Thread Rui Barradas
Às 15:29 de 20/11/2022, Gábor Malomsoki escreveu: Dear Bert, Yes, was trying to fill the not existing categories with NAs, but the suggested solutions in stackoverflow.com unfortunately did not work. Best regards Gabor Bert Gunter schrieb am So., 20. Nov. 2022, 16:20: You can't predict res

Re: [R] test logistic regression model

2022-11-20 Thread Gábor Malomsoki
Dear Bert, Yes, was trying to fill the not existing categories with NAs, but the suggested solutions in stackoverflow.com unfortunately did not work. Best regards Gabor Bert Gunter schrieb am So., 20. Nov. 2022, 16:20: > You can't predict results for categories that you've not seen before > (

Re: [R] test logistic regression model

2022-11-20 Thread Bert Gunter
You can't predict results for categories that you've not seen before (think about it). You will need to remove those cases from your test set (or convert them to NA and predict them as NA). -- Bert On Sun, Nov 20, 2022 at 7:02 AM Gábor Malomsoki wrote: > Dear all, > > i have created a logistic

[R] test logistic regression model

2022-11-20 Thread Gábor Malomsoki
Dear all, i have created a logistic regression model, on the train df: mymodel1 <- glm(book_state ~ TG_KraftF5, data = train, family = "binomial") then i try to predict with the test df Predict<- predict(mymodel1, newdata = test, type = "response") then iget this error message: Error in model.fr