I am new to R, and I am running the multinomial logistic regression in R, but it keeps showing the error:
library(nnet)
train <-read.csv("train.csv", header = TRUE)
train <-multinom(Crime_code~Year+Month+Day+Weekday+Time+Hour+Area+District+Longitude+Latitude,data=train,size=11,maxit=1700,weights=1700)
## Error in model.frame.default(formula = Crime_code ~ Year + Month + Day + : variable lengths differ (found for '(weights)')
summary(train)
## Error in object[[i]] : object of type 'closure' is not subsettable
Here is the data structure:
str(train)
'data.frame': 1760097 obs. of 12 variables:
$ DR : int 120215758 160512269 112104909 121523303 162107991
161407795 180409993 130911557 120405961 160221815 ...
$ Year : int 2012 2015 2011 2012 2016 2016 2018 2013 2011 2016 ...
$ Month : int 8 9 1 12 2 2 5 6 9 12 ...
$ Day : int 5 1 18 9 24 24 18 3 1 12 ...
$ Weekday : int 6 1 1 6 2 2 4 0 3 0 ...
$ Time : int 2345 800 5 1200 1630 910 1910 1240 2000 1800 ...
$ Hour : int 23 8 0 12 16 9 19 12 20 18 ...
$ Area : int 2 5 21 15 21 14 4 9 4 2 ...
$ District : int 201 513 2105 1583 2185 1453 489 964 416 233 ...
$ Longitude : num -118 -118 -119 -118 -119 ...
$ Latitude : num 34.1 33.8 34.2 34.1 34.2 ...
$ Crime_code: int 624 354 220 745 310 624 626 624 230 420 ...