Hi I'm going by the steps in this file to fit a CBD Model to US Male data, sourced from the HMD. Currently I have the error that my argument data is not of the class StMoMoData.
CBDfit <- fit(CBD, data = USData, ages.fit = 60:89)
Error in fit.StMoMo(CBD, data = USData, ages.fit = 60:89) :
Argument data needs to be of class StMoMoData.
I have tried downloading the HMD data straight from R using the demography package. I have also tried saving the HMD data as a .csv file and reading that into R. Any other thoughts?
There is a function in the package to create objects of class StMoMoData. The function is StMoMoData
... This is how to use it:
StMoMoData(data, series = names(data$rate)[1], type = c("central", "initial"))
Take a look in the documentation to learn further.. It's difficult to help you more, since you didn't provide a reproducible example or a bit of your code... But there is an example in the documentation:
library(demography)
NZdata <- hmd.mx(country = "NZL_NP", username = username, password = password,
label = "New Zealand")
NZStMoMo <- StMoMoData(NZdata, series = "male")
summary(NZStMoMo)