I would like someone to have a look over my code and fix it, so that I can calculate the correct parameters m, q, and p based on my real-life sales data. Here is the code:
[login to view URL] <-c(0.376000,0.937000,4.416000,22.497000,39.409000,51.630000,54.828000,54.132000,50.315000,42.628000,35.165000,26.379000,14.377000)
Sales <- diff([login to view URL])
sales <- [login to view URL][-1]
sales2 <- sales*sales
l <- length(Sales) #
T <- 1:l # T = [1,2,3,4,5,6,7,8,9,10,11,12,13]
# Bass GA
bassf <- function(x,theta) theta * ( ((theta+theta)^2 / theta) * exp(-(theta+theta) * T) ) /(1+(theta/theta)*exp(-(theta+theta)*x))^2 # f(t)
fitnessL <- function(theta,x,y) -sum((y-bassf(x,theta))^2)
GA3 <- ga(type="real-valued",fitness=fitnessL,x=T,y=Sales,lower=c(0,0,0),upper=c(9999999999,1,1),popSize=500,crossover=gareal_blxCrossover,maxiter=500,run=200,names=c("m","p","q"))
bassf <- function(x,theta) theta * ( ((theta+theta)^2 / theta) * exp(-(theta+theta)* x) ) /(1+(theta/theta)*exp(-(theta+theta)*x))^2
theta <- GA3@solution
salesfit <- bassf(0:15,theta)
When running the code in R, I always get a value for M that is not possible based on the assumptions of the bass model. In the end I also want to plot the bass model function and show the development from year 2002 (start date of the sales data) to the end of the sales data 2014 and forecast until 2020.
The data is in pcs sold millions.
Please dont hesitate if you have further questions
8 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön
How are you? I am very interested in your project. I have developed programs with R in 3 years and have many experiences. Please feel free to contact me. Thank you.