I am programming in R, and while performing logistic regression I am getting this error:
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
That's the code which I am using, I have checked all my factor and no one has less than two levels.
c1<-"campaign_type"
c2<-"campaign_status"
c3<-"advertiser_cost"
output.var<-"Success"
names(train)
[1] "campaign_type" "campaign_status" "connection_type" "cpa_price" "impressions"
[6] "clicks" "conversions" "advertiser_cost" "cpa_revenue" "profit"
[11] "revenue_ecpm" "cost_ecpm" "profit_ecpm" "ctr" "conversion_rate"
[16] "click_conversion_rate" "margin" "manager"
"sales_manager" "Success"
> glm(output.var~c1+c2+c3,family=binomial('logit'),data=train)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
> class(train[,c1])
[1] "factor"
> unique(train[,c1])
[1] CPA Optimized_CPM CPM
Levels: CPA CPM Optimized_CPM
> class(train[,c2])
[1] "factor"
> unique(train[,c2])
[1] Launched Paused
Levels: Launched Paused
> class(train[,c3])
[1] "numeric"
> class(train[,output.var])
[1] "integer"
> unique(train[,output.var])
[1] 0 1
As I said all my factors have 2 or more levels.
Can anyone tell me why I am getting this error?
thats a link address for the data: https://drive.google.com/file/d/0B-s59D9jsTcnVVppSlNQVE5PMGM/view?usp=sharing
Thanks