r glm - Error in names(coef) <- xnames only for 2 columns in data
문제
I am getting the below error when i run the R code for glm():
> fmla = 'status_id~ratings'
> logisticmodel <- glm(fmla, data = playdata, family=binomial(link="logit"))
Could you please correct me where I have gone wrong, I googled a lot on it and the only answer is generally naming convention, however, this is not case for me since I tried with changing the data by placing all the values as 2's and it worked - so it is not a naming issue with variables.
Below is the data description:
> str(playdata)
'data.frame': 24160 obs. of 13 variables:
$ idd : int 57251659 63385939 51939145 64339389 33725679 47000250 62738883 33725679 53589441 36670488 ...
$ status_id : int 1 1 1 1 1 1 1 1 1 1 ...
$ id : int 22820543 22953283 22919397 22699949 22658030 22720403 22581860 22915483 22621108 22651736 ...
$ group_id : int 2 2 2 2 2 2 2 2 2 2 ...
$ created_date : POSIXct, format: "2017-03-31 12:45:10" "2017-04-04 10:50:11" "2017-04-03 16:40:04" "2017-03-28 14:40:48" ...
$ question_id : int 20073221 20219031 20185301 19948471 19906458 18651404 19816152 20175471 19865888 19897662 ...
$ surftoanswertime: int 533 484 98 476 388 0 741 757 2222 381 ...
$ skiprate : num 0.981 0.95 0.993 0.875 0.966 ...
$ ratings :integer64 0 0 1 2 0 0 1 1 ...
$ pos :integer64 0 0 1 2 0 0 1 0 ...
$ negratings :integer64 0 0 0 0 0 0 0 1 ...
$ cf : num NA NA 1 1 NA NA 1 0 NA 1 ...
$ cf1 : num -1 -1 1 1 -1 -1 1 0 -1 1 ...
Actual formula is as below - only the ratings and negratings are throwing the above error.
fmla = 'status_id~skiprate+ratings+negratings+surftoanswertime+cf1'
Could you please help me in understanding and correcting the error.
> logisticmodel <- glm(fmla, data = playdata, family=binomial(link="logit"))
Error in names(coef) <- xnames : names() applied to a non-vector
In addition: Warning messages:
1: In glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, :
non-finite coefficients at iteration 1
2: glm.fit: algorithm did not converge
If I use more columns I am getting the below error:
Error in `*tmp*`[fit$pivot] : object of type 'closure' is not subsettable
In addition: Warning messages:
1: In glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, :
non-finite coefficients at iteration 1
2: glm.fit: algorithm did not converge
올바른 솔루션이 없습니다
제휴하지 않습니다 datascience.stackexchange