# Fix my code in R for a bass diffusion model

Hi,

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[1] * ( ((theta[2]+theta[3])^2 / theta[2]) * exp(-(theta[2]+theta[3]) * T) ) /(1+(theta[3]/theta[2])*exp(-(theta[2]+theta[3])*x))^2 # f(t)

fitnessL <- function(theta,x,y) -sum((y-bassf(x,theta))^2)

library(GA)

maxiter=500

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"))

summary(GA3)

bassf <- function(x,theta) theta[1] * ( ((theta[2]+theta[3])^2 / theta[2]) * exp(-(theta[2]+theta[3])* x) ) /(1+(theta[3]/theta[2])*exp(-(theta[2]+theta[3])*x))^2

theta <- GA3@solution

salesfit <- bassf(0:15,theta)

salesfit

Total_customer <-cumsum(salesfit)

Total_customer

plot(Total_customer,type="l")

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

Habilidades: Coding, Matemática, Programming, Análise estatística, Estatísticas

( 2 comentários ) Bergneustadt, Germany

ID do Projeto: #17983331

## 7 freelancers estão ofertando em média \$184 para esse trabalho

sumbali

I'm an Engineer in Statistics and Applied Economics, i've got many skills and expertise that will allow me achieving perfectly all the projects and assignments because my priority is your satisfaction I am a master of Mais

\$200 USD in 3 dias
(137 Comentários)
6.4
schoudhary1553

This is Vibrant Webtech and I was glad to see that you're looking for help for project Fix my code in R for a bass diffusion model. I've delivered more than 400 + projects in the last 5 years and this makes me very c Mais

\$250 USD in 4 dias
(30 Comentários)
5.8
Yknox

Dear employer. I am Jin.S, developer . I've just read your job post and I'm very interested. I'm a certificated freelancer with almost 1100 good reviews from clients. I m quite experienced in Mathematics, Programm Mais

\$155 USD in 3 dias
(23 Comentários)
5.6
Developer000

Feel fee to contact me for Fix my code in R for a bass diffusion [login to view URL] me message to discuss further more details .We provide the commments,images,videos,demos and live sessions in order to help the clients.M Mais

\$150 USD in 3 dias
(14 Comentários)
4.4
engineeringexp

I am an expert in R programming check my reviews award me and I will do my best........................................................................................................................................... Mais

\$31 USD in 3 dias
(4 Comentários)
2.7
KashirinA

⭐⭐⭐⭐⭐⭐hello i can finish your project in short time⭐⭐⭐⭐⭐⭐ This is my profile::https://www.freelancer.com/u/bengalTIGER1106 i am new freelancer but my speed is rocket speed so i can help your project beautiful and pe Mais

\$300 USD em 1 dia
(0 Comentários)
0.0
bidroid

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.

\$200 USD in 3 dias
(0 Comentários)
0.0