There's a significant body of work in soil moisture accounting models. However your mention of temperature implies to me you might be addressing modeling of soil moisture subject to freezing and thawing of the soil profile. There is a significant body of work looking at the addition of frozen ground effects on soil moisture accounting models, as well as the parameterization of the models, including a-priori parameterization of both, based on soil properties. For example, papers such as:
Koren, V., Schaake, J., Mitchell, K., Duan, Q.-Y., Chen, F., Baker, J. M. (1999) A parameterization of snowpack and frozen ground intended for NCEP weather and climate models. J. Geophys. Res. 104(D16), 19 569–19 585.
Koren, V., Smith, M., Duan, Q. (2002) Use of a priori parameter estimates in the derivation of spatially consistent parameter sets of rainfall–runoff models. In: Calibration of Watershed Models, Water Science and Application 6 (ed. by Q. Duan, S. Sorooshian, H. Gupta, A. Rosseau & R. Turcotte), 239–254. AGU, Washington DC, USA.
Zhang C, Chen F, Sun L, Ma Z, Yao Y (2021) A new seasonal frozen soil water-thermal coupled migration model and its numerical simulation. PLoS ONE 16(11): e0258861. https://doi.org/10.1371/journal.pone.0258861
I can't help with respect to codes written in R or Matlab, but for current work you might take a look at:
https://water.noaa.gov/about/nwm, and
https://ral.ucar.edu/projects/wrf_hydro
The WRF-Hydro system makes codes available and invites collaborators to participate in modeling and model testing, code development and testing, integration and testing, and operational implementation activities.
Thanks for your answer, actually I have some ground-based data including soil moisture, soil temperature, and hourly precipitation. My goal is to model the SM based on other variables and then compare with the satellite derived SM. So, I'm looking for a code to model SM at ST above at least 5°C.
Be careful with satellite based soil moisture. It shows promise for moisture and energy fluxes between the land surface and atmospheric models. However, there are problems below about 5 cm from the soil surface. Which impacts soil moisture accounting models which need to model SM at depths down to and deeper than the root zone for agricultural purposes and much deeper for water supply involving aquifers, etc. There are also problems where the soil is covered by snow, etc. I can understand you wanting to avoid the impact frozen ground i.e. ST above at least 5°C. However I'd defer to Luca Brocca for the most recent research.
Soil moisture modeling can get complicated pretty quickly, so you might want make sure you're being specific in defining and communicating what you're trying to do.