# Error using msmFit in R

I am trying to analyze a time series data using the MS model with R.

I wrote the following codes and then got an error at the last line:

library(MSwM)
topix <- ts(tsdata\$topix, start=c(1975,1), frequency=12)
plot(topix,type = "l", xlab="year", main="TOPIX")
topixrate<-diff(log(topix))
levelmod <- lm(topixrate~1)
levelswmod = msmFit(levelmod, k=2, sw=c(T,T), p=0)

Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘msmFit’ for signature
‘"lm", "numeric", "integer", "numeric", "missing", "missing"’


Please show me how to solve this problem.