Hello everyone!
I've trying to write an code to show travel demanding forecast. My model is Multinomial Logit Model. I need some help on my coding.
My data frame as follows: I have 17 variables and 121 obs (rows) but I'm minimizing it into 7 variables and 5.obs
FModeFr Age Drlicense Work Income PosAuto CostCar
1 1 2 1 3 3 1 1000
2 5 2 1 5 2 4 1400
3 2 2 1 5 1 1 4900
4 1 2 1 2 2 1 5000
5 1 2 1 3 3 4 3000
I'm not using any packages and library.
OutPut <-data.frame(PCar,PBus,PTaxi,PSharedtaxi,PWalk,SCar,SBus,STaxi,SSharedtaxi,SWalk)
write.table(OutPut,"Output.csv",quote=F,col.names=T,append=T,sep=",")
LL <-colSums(SCarlog(PCar)+SBuslog(PBus)+STaxilog(PTaxi)+SSharedtaxilog(PSharedtaxi)+SWalk*log(PWalk))
}
b0 <-numeric(12)
res_BFGS <-optim(b0,fr, method="BFGS", hessian=TRUE, control=list(fnscale=-1))
show <-function(res,b0){
b <-res$par
hhh <-res$hessian
tval <-b/sqrt(-diag(solve(hhh)))
L0 <-hh*log(1/5)
LL <-res$value
ERROR:
Error in fn(par, ...) :
dims [product 121] do not match the length of object [0]