resid_calc

options(warn = -1)

set up

library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(lmerTest)
Loading required package: lme4
Loading required package: Matrix

Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':

    lmer
The following object is masked from 'package:stats':

    step
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ forcats   1.0.0     ✔ readr     2.1.5
✔ ggplot2   3.5.1     ✔ stringr   1.5.1
✔ lubridate 1.9.3     ✔ tibble    3.2.1
✔ purrr     1.0.2     ✔ tidyr     1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ tidyr::expand() masks Matrix::expand()
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
✖ tidyr::pack()   masks Matrix::pack()
✖ tidyr::unpack() masks Matrix::unpack()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(modelr)
library(purrr)
library(emmeans)
Welcome to emmeans.
Caution: You lose important information if you filter this package's results.
See '? untidy'
library(gridExtra)

Attaching package: 'gridExtra'

The following object is masked from 'package:dplyr':

    combine
library(writexl)
library(gt)
library(webshot2)
library(broom.mixed)
library(lubridate)
load(file="Z:/Isaac/Visual Features/1-5/step2.RData")
aug_res_60
# A tibble: 19,890 × 19
   feature sow   time_group_60 datetime            hour     ttf mean_value
   <fct>   <fct> <fct>         <dttm>              <fct>  <dbl>      <dbl>
 1 Area    1     1             2025-04-01 09:13:30 9     -17.9      58046.
 2 Area    1     2             2025-04-01 10:00:01 10    -17.0      56895.
 3 Area    1     3             2025-04-01 11:00:00 11    -16.0      58349.
 4 Area    1     4             2025-04-01 12:00:00 12    -15.0      50050.
 5 Area    1     5             2025-04-01 13:00:02 13    -14.0      47858.
 6 Area    1     6             2025-04-01 14:00:02 14    -13.0      50943.
 7 Area    1     7             2025-04-01 15:00:01 15    -12.0      50301.
 8 Area    1     8             2025-04-01 16:00:01 16    -11.0      53684.
 9 Area    1     9             2025-04-01 17:00:01 17    -10.0      47713.
10 Area    1     10            2025-04-01 18:00:00 18     -9.03     54449.
# ℹ 19,880 more rows
# ℹ 12 more variables: sd_value <dbl>, var_value <dbl>, n_obs <int>,
#   .fitted <dbl>, .fixed <dbl>, .mu <dbl>, .offset <dbl>, .sqrtXwt <dbl>,
#   .sqrtrwt <dbl>, .weights <dbl>, .wtres <dbl>, .resid <dbl>
aug_resid <- aug_res_60$.resid[16]
aug_resid
[1] 2096.505
y <- aug_res_60$mean_value[16]
est <- aug_res_60$.fitted[16]
obs_resid <- y-est
obs_resid
[1] 2096.505
aug_resid
[1] 2096.505
df_60_min_vars$fixed$estimate[1]
[1] 65462.66
aug_res_60$.fixed[16]
      16 
65462.66