Question
Use R software to show parallel results using both the logistic and Gompertz functions ('SSlogis' and 'SSgompertz') , use the self-starting and report: the data
Use R software
to show parallel results using both the logistic and Gompertz functions('SSlogis' and 'SSgompertz'), use the self-starting and report: the data and the two fitted lines all on the same plot for comparisonreasons , the confidence intervals of parameters and tests indicating if any of them is zero, residual plots and diagnostics, methods to identify which of the twomodelsis bettere.g. based on RMSE
#Years
year<-c(1800,1810,1820,1830,1840,1850,1860,1870,1880
,1890,1900,1910,1920,1930,1940,1950,1960,1970
,1980,1990,2000,2010,2020)
#The population
pop<-c(3800,4800,7500,28000,212300,397700,749100,
1200000,1600000,2100000,2400000,2810173,
3668412,4842325,5256106,6371766,7823194,
8875083,9262078,9295297,9938444,9883640,10077331)
#Adding a column x with ranges from 0 to 220
#1810 - 1800 = 10 This means there is a 10 years interval between 1800 and 1810.
#Similarly 2020 - 1800 = 220. This means that there is an interval of 220 years between 1800 and 2020.
use this column for 'SSgompertz'
> data
x
0
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
i want to combine those functions and compare which one is better
hint:
# "SSgompertz"
?SSgompertz
#Asym, b2, and b3 are names of objects the gradient matrix with respect to these names is attached as an attribute named gradient.
#Adding a column x with ranges from 0 to 220
#1810 - 1800 = 10 This means there is a 10 years interval between 1800 and 1810.
#Similarly 2020 - 1800 = 220. This means that there is an interval of 220 years between 1800 and 2020.
data<- read.csv(file.choose())
SSgompertz(seq(10,20,by=2)/100, Asym=2, b2=5, b3=1.3)
with(list(Asymptote=2, b2=5, b3=1.3),SSgompertz(seq(10,20,by=2)/100, Asymptote, b2, b3))
output<-nls(Pop ~ SSgompertz(x, Asymptote, b2, b3),data=data.frame(x=(11:20), Pop=sort(log(11:20)+1)))
plot(pop ~ x, data = data)
curve(predict(output, newdata = data.frame(x = x)), add = TRUE)
hint:
SSlogis
model2 <- nls(pop~SSlogis(year,a,b,c))
new.data <- data.frame(year = seq(min(year),max(year),len = 100))
plot(year,pop, col= "Red", main = "Logistic Graph", xlab = "Year", ylab = "Population")
lines(new.data$year,predict(model2,newdata = new.data), col= "Blue")
summary(model2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started