Spline model with calender year as independent variable

I have never performed non linear regression models.

I want to find out whether mortality rate (variable "mortality_rate") changed over the years (variable "Year"). Since the relationship between Year and mortality_rate is not linear (see figure), I want to run a spline model, with Year as independent and mortality_rate as dependent variable. How can run a spline model with 20 knots?
enter image description here

I have the following data in R:

dat <- structure(list(Year = c(1998, 1999, 2000, 2001, 2002, 2003, 2004, 
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 
2016, 2017, 2018), mortality_rate = c(0.0088, 0.0077, 0.0082, 
0.0075, 0.0076, 0.0075, 0.0066, 0.0061, 0.0059, 0.0054, 0.0054, 
0.0058, 0.0056, 0.006, 0.0053, 0.0061, 0.0052, 0.0055, 0.0069, 
0.0074, 0.0073)), row.names = c(NA, 21L), class = "data.frame")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.