Open bpbond opened 4 months ago
Once we have the daily data in wide form (as above, with one row per day in June 2022, and one column per variable)...
Linear regression model would be something like this:
mod <- lm(sap flow_2.5cm ~ wx_par_den15 + wx_tempavg15 + wx_windspeed15, data = data_daily_wide)
P.S. a presentation I put together on linear regression is here - https://rpubs.com/bpbond/830637 - may be useful
TMP_C_20220601-20220630_L1_v1-0.csv ~TMP_C_20220701-20220731_L1_v1-0.csv~ ~TMP_C_20220801-20220831_L1_v1-0.csv~
TMP_2022_L1_v1-0_metadata.txt
) we see that the weather data for this site are in the "GCW" filesGCW_W_20220601-20220630_L1_v1-0.csv ~GCW_W_20220701-20220731_L1_v1-0.csv~ ~GCW_W_20220801-20220831_L1_v1-0.csv~
[x] Then you can bind (
rbind
ordplyr::bind_rows
) the data into a single data frame-> data_15min
[x] Filter (subset) the data for the variables that we're interested in:
wx_par_den15
(photosynthetically active radiation),wx_tempavg15
(air temperature),wx_windspeed15
(wind speed), plus the thing we're trying to predict:sapflow_2.5cm
(sapflow velocity)[x] Compute daily DAYTIME averages for all variables, something like this (you'll probably want to use time-handling functions in the
lubridate
package)[x] Reshape these data (I suggest
tidyr::pivot_wider()
function) to put them in a form suitable for model-fitting: